{
"$type": "site.standard.document",
"canonicalUrl": "https://isabelroses.com/blog/self-healing-urls",
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreihlqcjo5icy23gl3q65fsxtqud6wm4ar5frmkhxdwgkkyj4irxeoy"
},
"mimeType": "image/png",
"size": 10320
},
"description": "Creating self-healing URLs within my Vue.js website",
"path": "/blog/self-healing-urls",
"publishedAt": "2023-12-10T00:00:00.000Z",
"site": "at://did:plc:qxichs7jsycphrsmbujwqbfb/site.standard.publication/3mn5hmwkcmb22",
"tags": [
"vuejs",
"learning",
"webdev"
],
"textContent": "I have been working on the creation of this version of my website for a while and when I finally thought I was done, I was introduced to the concept of self-healing URLs.\n\nSelf-healing URLs are designed in a way that if a user was to type in a URL as\nlong as a certain part of the URL is correct, the user will be redirected to the\ncorrect page. This is useful for when a user is trying to access a page that has\nbeen moved or deleted.\n\nFor example, if a user was to type in <domain>/blog/gaoengioa-2 they would be redirected to <domain>/blog/self-healing-urls-2 as the only important part of the URL is the \"2\" in this case, which refers to the second blog post by ID.\n\nTo implement this I had to make a few changes to my code. The original way that\nthe post data was being fetched was by using the slug of the post. This meant\nthat if the slug was incorrect, the post would not be found and the user would\nbe redirected to a 404 page. To fix this I had to change the way that the post\nwas being fetched to use the ID of the post instead. This meant that if the slug\nwas incorrect, the post would still be found and the user would be redirected to\nthe correct page.\n\nThen all that was left was to ensure all links were using the new slug format.\nThis was done by changing the way that the slug was being created. Instead of\nusing the title of the post, the slug was created using the title and the ID of\nthe post. This meant that the slug would always be unique and would always be\nthe same for the same post.\n\nInspiration\n\nThe original idea for this post comes from: https://www.youtube.com/watch?v=a6lnfyES-LA",
"title": "Self-Healing URLs"
}