-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Fix: transfered misplaced blog pages that caused broken links #6644
Conversation
…ommunity to announcements
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
duplicate of #6643 |
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.
The problem is not the file name. And it MUST not be changed. This should come from the withSidebarCrossLinks component.
i've tested out the new checks and code that i wrote by temporarily deleting the update-v8-5.4.md from the announcements folder, and heading to http://localhost:3000/en/blog/announcements/nodejs-certified-developer-program like #6641 mentions and now the update-v8-5.4 doesn't render (and all other invalid links don't as well) |
@ovflowd @AugustinMauroy i'd like to have your feedback on a couple of ideas to make sure that we don't include blog md that isn't in the right folder: Idea 1:what if we add a check in blogData.mjs const pathnameCategory = dirname(filename).split('/').pop();
if (pathnameCategory === category) {
// add whats needed
const publishYear = new Date(date).getUTCFullYear();
// etc etc
return {
title,
author,
username,
date: new Date(date),
categories,
slug
};
} else return {}; then in _readLine.on('close', () => {
const post = getFrontMatter(filename, rawFrontmatter[filename][1]);
if (Object.keys(post).length > 0) {
posts.push(post);
}
if (posts.length === filenames.length) {
resolve({
categories: [...blogCategories],
posts
});
}
}); Idea 2:having a check in _readLine.on('close', () => {
const post = getFrontMatter(filename, rawFrontmatter[filename][1]);
const fileCategory = dirname(filename).split('/').pop();
if (fileCategory === post.categories[0]) {
posts.push(post);
}
if (posts.length === filenames.length) {
resolve({
categories: [...blogCategories],
posts
});
}
}); |
TBH I think all of these solutions are overkill. These specific blog posts seems to be very edge scenarios. IMHO we should simply add redirects to them on our |
Claudio take a look to the issue. the issue from crosslink with category. Not from "miss placed post". Md/mdx file mustn't not change place. |
@AugustinMauroy i actually disagree on that, if you open update-v8-5.4.md and v5-to-v7.md their category clearly states announcements but they are placed in the community folder, the slugs being generated are getting the categories from the file itself and not the pathname |
@ovflowd In that case this PR can be merged safely as it simply puts the blog posts in their right folder according to their category and adds a few minor changes to the withSidebarCrossLinks.tsx which i can revert if you want, there's no need to add anything to the redirects.json, if you open up the files you can clearly see that they have the category of announcements but are placed in the community folder |
Any progress here? |
@unclebay143 so far im waiting for feedback to know which direction to take if there's any or if this is ready to be accepted but based on @ovflowd last comment I THINK this PR can be safely merged and achieves its purpose |
Sorry, I was out on a company event, I'll try to review this asap. |
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 don't think the changes on components/withSidebarCrossLinks.tsx
are needed. The previous logic does pretty much the same, you're just complicating things a bit 😅
I do believe you could keep the check of if sidebarNavigation is not defined or the list of items is empty. But these are edge cases that should genuinely not happen.
+ You're moving files but you didn't add redirects from the OLD links to the new ones. (Please update redirects.json) adding the old links to go to the new ones 🙇
I have reverted the changes to the update-v8-5.4.md clearly have the category of announcements but was placed in the community folder there's no need for adding it to redirects.json since simply placing it in its rightful folder fixes the issue its slug now matches its filepath and we can now access it as the next blog post from the http://localhost:3000/en/blog/announcements/nodejs-certified-developer-program link and not have a dead link for a an existing blog post |
Alright! Awesome, thanks for explaining! |
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.
LGTM! Thanks for the contribution and moving the files to the right place 🙇
Lighthouse Results
|
Description
Transfered v5-to-v7.md and update-v8-5.4.md from community directory to announcements directory, the category in those files is announcements and being misplaced cause broken links
Validation
I've ran npx turbo serve and checked the links, i've gone through the blog directory and verified that there are no more misplaced blog pages in other categories
update-v8-5.4.md
v5-to-v7.md
Related Issues
Fixes #6641
Check List
npx turbo format
to ensure the code follows the style guide.npx turbo test
to check if all tests are passing.npx turbo build
to check if the website builds without errors.