Rehype plugin to extract meta data from an HTML document.
npm install rehype-extract-meta
import { unified } from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import rehypeExtractMeta from 'rehype-extract-meta'
const processor = unified()
.use(rehypeParse)
.use(rehypeExtractMeta)
.use(rehypeStringify)
const htmlString = `<html>...</html>`
const vfile = processor.processSync(htmlString)
console.log(vfile.data.meta)
Running the above code with a valid htmlString
will return a VFile
containing the extracted contents in its data.meta
property, conforming to
the type Meta
.
This package exports a single plugin function.
Extract meta data from HTML.
Transform (Transformer
).
Data property (TypeScript type).
lang
(string
) - Language stringdate
(string
) - Document datetitle
(string
) - Document titledescription
(string
) - Document descriptionkeywords
(string[]
) - Document keywordsauthor
(string
) - Document authorpublisher
(string
) - Document publishercopyright
(string
) - Document copyrightpageUrl
(string
) - Page URLimageUrl
(string
) - Image URLfeedUrl
(string
) - Feed URL
This package is fully typed with TypeScript.
It exports the additional type Meta
.
Rehype plugin to extract meta data from an HTML document.