New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(blog): slug/pathname aliases for blog posts #8356
base: main
Are you sure you want to change the base?
Changes from 4 commits
921a57c
add4de2
bb0ceb9
d5d8523
e7f1c4c
68d729c
ab1cf60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,6 +274,20 @@ export default async function pluginContentBlog( | |
}, | ||
}); | ||
|
||
if (metadata.aliases) { | ||
johnnyreilly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
metadata.aliases.forEach((alias) => { | ||
addRoute({ | ||
path: alias, | ||
component: blogPostComponent, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, this would create two pages with the same content? Isn't it simpler to set up redirects instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @Josh-Cena, The context for this is in @slorber's comment here: #8311 (reply in thread)
Does this make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes that makes sense to me, and we'll likely want to add something similar to individual docs for consistency |
||
exact: true, | ||
modules: { | ||
sidebar: aliasedSource(sidebarProp), | ||
content: metadata.source, | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
blogItemsToMetadata[id] = metadata; | ||
}), | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should accept such value 😅
This code is unlikely to yield a great pathname
normalizeUrl([baseUrl, routeBasePath, alias])
and the tests do not cover these edge cases.
The question to me is: do we want to support relative aliases?
Is this really useful? I mean, you create a relative alias, then update the slug, and then you end up with a different alias. That might be a source of bug/confusion?
If we do want relative aliases, there's a
resolvePathname
util that could probably be applied to compute the final non-relative pathname of the alias.But I would suggest to keep it simple for now and only accept absolute pathname aliases in validation? If someone wants a relative alias someday and has great reason to add it, we'll do an update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not - will amend