Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
astro-rehype-relative-markdown-links
Advanced tools
A rehype plugin built for Astro that aims to transform relative links in MD and MDX files into the proper URL path
This is a rehype plugin built for Astro that aims to transform relative links in MD and MDX files into their final output paths.
🚨 This is experimental and build exclusively for Astro. I have made a couple assumptions. They are:
src/content/<content_collection>
src/pages/<content_collection>/[...slug].astro
If you have a markdown files at src/content/blog/post.md
with the content of:
[relative link](./other-markdown.md)
The resulting HTML should be:
<a href="/blog/other-markdown">relative link</a>
It supports links with Query Strings and Hashes (e.g. [relative link](./other-markdown.md?query=test#hash)
).
Tested with Node.js v18 and v20 and Astro 2.x+.
Yarn
yarn add astro-rehype-relative-markdown-links
PNPM
pnpm add astro-rehype-relative-markdown-links
NPM
npm install astro-rehype-relative-markdown-links
astro.config.mjs
import rehypeAstroRelativeMarkdownLinks from "astro-rehype-relative-markdown-links";
// ...everything else
export default defineConfig({
// ...everything else
markdown: {
rehypePlugins: [rehypeAstroRelativeMarkdownLinks],
},
});
To set custom options, pass an object to the plugin like below:
const options = {
contentPath: "", // where you store your content relative to the root directory. default: 'src/content'
basePath: "", // the base path of your astro project. should match path passed in astro config (https://docs.astro.build/en/reference/configuration-reference/#base). default: '/'
};
export default defineConfig({
// ...everything else
markdown: {
rehypePlugins: [[rehypeAstroRelativeMarkdownLinks, options]],
},
});
Using Yarn in example (sorry).
DEBUG=astro-rehype-relative-markdown-links yarn build
# or
DEBUG=astro-rehype-relative-markdown-links yarn dev
rehype-astro-relative-markdown-links
in the past. I've changed this due to rehype's naming guidelines.v0.8.0 (2024-03-19)
Merged pull requests:
FAQs
A rehype plugin built for Astro that aims to transform relative links in MD and MDX files into the proper URL path
The npm package astro-rehype-relative-markdown-links receives a total of 2,212 weekly downloads. As such, astro-rehype-relative-markdown-links popularity was classified as popular.
We found that astro-rehype-relative-markdown-links demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.