An open API service indexing awesome lists of open source software.

https://github.com/timlrx/remark-webembed

Remark plugin to embed web content using markdown directives
https://github.com/timlrx/remark-webembed

embed markdown mdx remark remark-plugin

Last synced: 3 months ago
JSON representation

Remark plugin to embed web content using markdown directives

Awesome Lists containing this project

README

        

# Remark Webembed

[remark](https://github.com/wooorm/remark) plugin to embed web content using [markdown directives](https://github.com/remarkjs/remark-directive).

Out of the box support for [oembed](https://oembed.com/) and custom providers. Automatically wraps the iframe into a responsive container.

Can be used on the server or in the browser (though certain oembed API providers block cross-origin requests).

## Installation

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.

```js
npm install remark-webembed
```

## Usage

```js
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import remarkDirective from 'remark-directive'
import rehypeStringify from 'rehype-stringify'
import remarkWebembed from 'remark-Webembed'

unified()
.use(remarkParse)
.use(remarkDirective)
.use(remarkWebembed, options)
.use(remarkRehype)
.use(rehypeStringify)
.process(markdown)
```

## Sample web embed

Input:

```md
::embed[https://www.youtube.com/watch?v=32I0Qso4sDg]
```

HTML Output:

```html









```

## API

`remark().use(remarkWebembed, [options])`

### options

#### options.queryParams

Type: `object`.

Query parameters passed to the oembed API. If `maxWidth` or `maxHeight` is specified, it will be applied to the iframe container as well.

Check the oembed provider's documentation for supported query parameters.