1.0.1 • Published 10 months ago

remark-prepend-url v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

remark-prepend-url

This is a simple remark plugin that allows you to prepend an absolute url (https://acme.com) to relative links (/posts).

Useful if you're using a static site generator like Astro with .mdx files and you'd like to prepare them for a full-text RSS feed.

Install

npm install remark-prepend-url

Use

remark().use(remarkPrependUrl, new URL("https://acme.com"));

Given the following example.md

...a [link]('/posts') for you.

Using remark-prepend-url like below:

import rehypeStringify from "rehype-stringify";
import remarkParse from "remark-parse";
import { read } from "to-vfile";
import { unified } from "unified";

const file = await unified()
  .use(remarkParse)
  .use(remarkPrependUrl, new URL("https://acme.com"))
  .use(remarkStringify)
  .process(await read("example.md"));

console.log(String(file));

will yield:

...a [link]('https://acme.com/posts') for you.

TypeScript

remark-prepend-url contains TypeScript type definitions. The package is ready for use with TypeScript.

License

Distributed under the MIT License.

1.0.1

10 months ago

1.0.0

10 months ago

0.1.0

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.1

10 months ago