-
Notifications
You must be signed in to change notification settings - Fork 155
fix some broken images in remote mdx, use ast replacing instead regex #434
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
Conversation
📦 Next.js Bundle Analysis for @graphprotocol/docsThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
website/src/remarkReplaceLinks.ts
Outdated
visit( | ||
tree, | ||
[ | ||
{ type: 'mdxJsxTextElement', name: 'img' }, | ||
{ type: 'mdxJsxFlowElement', name: 'img' }, | ||
], | ||
(node: any) => { | ||
const attrs = node.attributes as { name: string; value: string }[] | ||
const srcAttr = attrs.find((attr) => attr.name === 'src')! | ||
if (srcAttr.value.includes('.gitbook/assets/')) { | ||
srcAttr.value = srcAttr.value.replace( | ||
/.*\.gitbook\/assets\//, | ||
`https://raw.githubusercontent.com/${assetsBasePath}.gitbook/assets/` | ||
) | ||
} | ||
} | ||
) | ||
visit(tree, 'image', (node) => { | ||
if (node.url.includes('../assets/')) { | ||
node.url = node.url.replace(/.*\.\.\/assets\//, `https://raw.githubusercontent.com/${assetsBasePath}assets/`) | ||
} | ||
}) |
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.
This is not really about "links"; should it go in a separate Remark plugin?
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.
Left a nitpicky comment.
found here https://thegraph.com/docs/en/substreams/concepts-and-fundamentals/fundamentals/ by @saihaj