JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 141
  • Score
    100M100P100Q74604F
  • License MIT

Rehype plugin to extract meta data from an HTML page

Package Exports

  • rehype-extract-meta

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rehype-extract-meta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rehype-extract-meta

Build Coverage Size

Rehype plugin to extract meta data from an HTML page.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm install rehype-extract-meta

Use

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)

Running the above code with a valid htmlString will return a VFile containing the extracted contents in its data property.

VFile {
  data: {
    title: '...',        // String
    date: '...',         // Date|String
    author: '...',       // String
    publisher: '...',    // String
    description: '...',  // String
    image: '...',        // URL
    keywords: ['...'],   // Array
    lang: '...',         // String
    url: '...'           // URL
  },
  messages: [],
  history: [],
  cwd: '...',
  value: '...'
}

Tests

Run npm test to run tests.

Run npm coverage to produce a test coverage report.

License

MIT © Goran Spasojevic