Skip to content
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(docs, blog): Markdown link resolution does not support hot reload #10185

Merged
merged 5 commits into from
May 31, 2024

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented May 31, 2024

Motivation

Fix #10152

The bug only happens during the dev experience because we "hot reload" the site.

When we create 1.md and then reference it with a link such as [1][./1.md] is another file, we get a markdown link resolution error.

This happens because the "sourceToPermalink" map (that we use for resolving markdown links) is not updated when we reload/re-read the site's files, for both the docs and blog plugins.

Note: the solution I applied is not elegant, and relies on mutable map update side-effects. I don't know yet how to solve it properly considering the configureWebpack hook is only called once and it's not really safe to read loadedContent from there, but I'll try to figure this out! Maybe this will require creating a new plugin lifecycle or using some moreadvanced Webpack features? 🤷‍♂️

Note: I also refactored the data structure from Record<string,string> to Map<string,string> for perf reasons.

Test Plan

Unit tests keep passing + my local experience has

Test links

https://deploy-preview-10185--docusaurus-2.netlify.app/

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label May 31, 2024
@slorber slorber requested a review from Josh-Cena as a code owner May 31, 2024 15:14
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 31, 2024
Copy link

netlify bot commented May 31, 2024

[V2]

Name Link
🔨 Latest commit 112ff4f
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6659e95f5c43e600081e9da7
😎 Deploy Preview https://deploy-preview-10185--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented May 31, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 68 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 59 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 69 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 62 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 69 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/tags 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

netlify bot commented May 31, 2024

[V2]

Name Link
🔨 Latest commit 39caf6b
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6659ef86d6613a0008804e66
😎 Deploy Preview https://deploy-preview-10185--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented May 31, 2024

Size Change: 0 B

Total Size: 1.72 MB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/codeTranslations.json 2 B
website/.docusaurus/docusaurus.config.mjs 27.1 kB
website/.docusaurus/globalData.json 107 kB
website/.docusaurus/i18n.json 930 B
website/.docusaurus/registry.js 276 kB
website/.docusaurus/routes.js 180 kB
website/.docusaurus/routesChunkNames.json 120 kB
website/.docusaurus/site-metadata.json 2.17 kB
website/build/assets/css/styles.********.css 112 kB
website/build/assets/js/main.********.js 855 kB
website/build/index.html 38.1 kB

compressed-size-action

@slorber slorber merged commit a7afd9c into main May 31, 2024
32 checks passed
@slorber slorber deleted the slorber/tem-fix-source-to-permalink branch May 31, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relative markdown links contain file extensions
2 participants