From 8ada93c3c54640dad1bd659607e6c1723477b0a1 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 18 Sep 2023 13:11:03 +0200 Subject: [PATCH] Refactor some more --- readme.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 42e26d0..95f46fb 100644 --- a/readme.md +++ b/readme.md @@ -328,6 +328,8 @@ This example uses the utility [`vfile-matter`][vfile-matter], which is specific to YAML. To support other data languages, look at this utility for inspiration. +`my-unified-plugin-handling-yaml-matter.js`: + ```js /** * @typedef {import('unist').Node} Node @@ -372,11 +374,11 @@ key: value …and using the plugin with an `example.js` containing: ```js -import {read} from 'to-vfile' -import {unified} from 'unified' import remarkParse from 'remark-parse' import remarkFrontmatter from 'remark-frontmatter' import remarkStringify from 'remark-stringify' +import {read} from 'to-vfile' +import {unified} from 'unified' import myUnifiedPluginHandlingYamlMatter from './my-unified-plugin-handling-yaml-matter.js' const file = await unified() @@ -471,10 +473,11 @@ To add other node types, register them by adding them to `FrontmatterContentMap`: ```ts -import type {Literal} from 'mdast' +import type {Data, Literal} from 'mdast' interface Toml extends Literal { type: 'toml' + data?: TomlData } declare module 'mdast' {