-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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(content-blog): make footnote reference DOM ID unique on post listing page #7212
Conversation
Hi @AkiraVoid! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-7212--docusaurus-2.netlify.app/ |
@AkiraVoid Please remember to sign the CLA so this can be properly reviewed. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
||
export default function plugin(): Transformer { | ||
return (root, vfile) => { | ||
const suffix = `-${simpleHash(vfile.path!, 6)}`; |
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.
Using the file path as the ID suffix may always not be desirable, because if the file is moved, the anchor ID changes. However, I think it's fine because (1) file movements should be rare and (2) nobody links to a footnote anchor anyways. If we don't do it this way we have to have a "global state" that's persisted between all Remark plugin instances which seems even more cumbersome.
Implementation looks fine but wonder if we really need this in Docusaurus? There is a limited number of users using footnotes, and also many docusaurus blogs using What's the use case for rendering footnotes in the list view? Can you explain what you are trying to do exactly? I think this use-case is likely too niche and this plugin can be applied in userland through blog plugin config |
@slorber They already have this in userland, but I recommmended them to send this to core, because we can't let every user who stumbled upon it to fix it in user-land, considering not everyone may have the time/capability. It's, again, about making Docusaurus an intuitive tool that "just works".
|
ok, why not 🤷♂️ can we have a unit test for it to ensure it keeps working over time? |
Motivation
Duplicated footnote references of many blog posts in blog list page will cause duplicated DOM
id
attributes, so I made a remark plugin to fix this.Have you read the Contributing Guidelines on pull requests?
No.
Test Plan
I wrote three blog posts under
website/_dogfooding/_blog tests
nameddup-footnote.md
. Opening them in route/tests/blog
, click each footnote reference, now they will navigate users to right place.https://deploy-preview-7212--docusaurus-2.netlify.app/tests/blog/page/4
Related PRs