0.0.9 • Published 2 years ago

remark-image-cid-to-url v0.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

remark image CID to URL

Transform a given image ID to a URL by a given function.

install

$ npm i -S remark-image-cid-to-url

example

// These lines make "require" available
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const test = require('tape');
import remarkParse from 'remark-parse'
import cidToURL from 'remark-image-cid-to-url'
const remark = require('remark');

const markdown = `
# Title

Take a look at this scenery:

![scenery](&Pe5kTo/V/w4MToasp1IuyMrMcCkQwDOdyzbyD5fy4ac=.sha256)
`;

test('it transforms a CID with a function', t => {
    t.plan(1);

    const output = remark()
        .use(cidToURL(blobId => {
            return 'http://foo.bar/blob/' + encodeURIComponent(blobId)
        }))
        .use(remarkParse, { commonmark: true })
        .processSync(markdown).contents;
        // this is markdown content

    t.ok(output.includes('foo.bar/blob/'),
        'should include the transformed URL')
});
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago