remark-prepend-url
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i remark-prepend-url

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

5.36 kB

Total Files

6

Last publish

Collaborators

  • alxjpzmn