Skip to content

Commit

Permalink
Fix internal links in RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermercer committed Mar 5, 2025
1 parent fb2eb70 commit 8eca260
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 3 deletions.
84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"minimist": "^1.2.8",
"node-fetch": "^2.0.0",
"prism-themes": "^1.9.0",
"rehype-rewrite": "^4.0.2",
"rehype-stringify": "^10.0.1",
"remark": "^15.0.1",
"remark-footnotes": "^4.0.1",
Expand Down
14 changes: 11 additions & 3 deletions src/utils/renderMarkdown.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@

import { remark } from 'remark';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import remarkEmdash from 'lib/plugins/remark/emdash';
import rehypeRewrite from 'rehype-rewrite';
import rehypeStringify from 'rehype-stringify';
import { remark } from 'remark';
import remarkGfm from 'remark-gfm';
import remarkRehype from 'remark-rehype';


const md = remark()
.use(remarkGfm)
.use(remarkEmdash as any)
.use(remarkRehype)
.use(rehypeRewrite, {
rewrite: (node) => {
if(node.type == 'element' && node.tagName == 'a' && node.properties.href!.toString().startsWith('/')) {
node.properties.href = `https://tylermercer.net${node.properties.href}`;
}
}
})
.use(rehypeStringify);

export default async function renderMarkdown(markdown: string): Promise<string> {
Expand Down

0 comments on commit 8eca260

Please sign in to comment.