@@ -31,9 +31,41 @@ function Img(h, node) {
3131 };
3232}
3333
34+function Link(h, node) {
35+ const url = node.url;
36+
37+ if (
38+ url.includes("https://urbit.org") ||
39+ url.startsWith("/") ||
40+ url.startsWith("#")
41+ ) {
42+ return {
43+ type: "element",
44+ tagName: "a",
45+ properties: {
46+ href: url,
47+ },
48+ children: node.children,
49+ };
50+ } else {
51+ return {
52+ type: "element",
53+ tagName: "a",
54+ properties: {
55+ target: "_blank",
56+ rel: "noopener",
57+ href: url,
58+ },
59+ children: node.children,
60+ };
61+ }
62+}
63+
3464const options = {
65+ allowDangerousHtml: true,
3566 handlers: {
3667 image: Img,
68+ link: Link,
3769 },
3870 sanitize: merge(github, {
3971 // remove user-content from github.json to remark-slug work as expected
@@ -45,14 +77,14 @@ const options = {
4577// Converts markdown strings into markdown HTML/React components
4678export default async function Markdown({ post }, disablePlugins) {
4779 const result = await remark()
48− .use(remarkParse, options)
80+ .use(remarkParse)
4981 .use(remarkprism, {
5082 plugins: !disablePlugins ? ["show-invisibles"] : [],
5183 })
5284 .use(gfm)
5385 .use(slug)
5486 .use(heading)
55− .use(remarkRehype, { allowDangerousHtml: true })
87+ .use(remarkRehype, options)
5688 .use(rehypeRaw)
5789 .use(rehypeStringify)
5890 .process(post.content);