mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 01:02:35 +02:00
fix: allow links to JSON in .md files to be transformed as asset links (#4827)
* fix: fix links to JSON from .md files closes #3561 It seems to be a common problem that many people are having see: https://stackoverflow.com/questions/65307533/link-to-static-json-file Co-authored-by: Anthony McCaigue <anthony@nquiringminds.com> Co-authored-by: Alois Klink <alois@nquiringminds.com> * Add dogfooding examples * actually fix * oops Co-authored-by: Alois Klink <alois@nquiringminds.com> Co-authored-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
parent
2528226eeb
commit
ab1dada1aa
8 changed files with 33 additions and 1 deletions
|
@ -47,7 +47,12 @@ function toAssetRequireNode(node: Link, assetPath: string, filePath: string) {
|
|||
const hash = parsedUrl.hash ?? '';
|
||||
const search = parsedUrl.search ?? '';
|
||||
|
||||
const href = `require('${inlineMarkdownLinkFileLoader}${
|
||||
const href = `require('${
|
||||
// A hack to stop Webpack from using its built-in loader to parse JSON
|
||||
path.extname(relativeAssetPath) === '.json'
|
||||
? `${relativeAssetPath.replace('.json', '.raw')}!=`
|
||||
: ''
|
||||
}${inlineMarkdownLinkFileLoader}${
|
||||
escapePath(relativeAssetPath) + search
|
||||
}').default${hash ? ` + '${hash}'` : ''}`;
|
||||
const children = stringifyContent(node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue