This commit is contained in:
2026-01-19 19:13:27 +01:00
commit 9d0442e88f
4968 changed files with 1142016 additions and 0 deletions

18
node_modules/remark-mdx-frontmatter/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,18 @@
# MIT License
Copyright © 2021 Remco Haszing
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the “Software”), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

94
node_modules/remark-mdx-frontmatter/README.md generated vendored Normal file
View File

@@ -0,0 +1,94 @@
# remark-mdx-frontmatter
[![github actions](https://github.com/remcohaszing/remark-mdx-frontmatter/actions/workflows/ci.yaml/badge.svg)](https://github.com/remcohaszing/remark-mdx-frontmatter/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/remcohaszing/remark-mdx-frontmatter/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/remark-mdx-frontmatter)
[![npm version](https://img.shields.io/npm/v/remark-mdx-frontmatter)](https://www.npmjs.com/package/remark-mdx-frontmatter)
[![npm downloads](https://img.shields.io/npm/dm/remark-mdx-frontmatter)](https://www.npmjs.com/package/remark-mdx-frontmatter)
A [remark](https://remark.js.org) plugin for converting frontmatter metadata into MDX exports
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [Options](#options)
- [Compatibility](#compatibility)
- [License](#license)
## Installation
This package depends on the AST output by
[remark-frontmatter](https://github.com/remarkjs/remark-frontmatter)
```sh
npm install remark-frontmatter remark-mdx-frontmatter
```
## Usage
This remark plugin takes frontmatter content, and outputs it as JavaScript exports. Both YAML and
TOML frontmatter data are supported.
For example, given a file named `example.mdx` with the following contents:
```mdx
---
hello: frontmatter
---
Rest of document
```
The following script:
```js
import { readFile } from 'node:fs/promises'
import { compile } from '@mdx-js/mdx'
import remarkFrontmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
const { value } = await compile(await readFile('example.mdx'), {
jsx: true,
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter]
})
console.log(value)
```
Roughly yields:
```jsx
export const frontmatter = {
hello: 'frontmatter'
}
export default function MDXContent() {
return <p>Rest of document</p>
}
```
## API
The default export is a [remark](https://remark.js.org) plugin.
### Options
- `default`: The default value to export if no frontmatter data is found. (Default: `undefined`).
- `name`: The identifier name of the variable the frontmatter data is assigned to. (Default:
`frontmatter`).
- `parsers`: A mapping A mapping of node types to parsers. Each key represents a frontmatter node
type. The value is a function that accepts the frontmatter data as a string, and returns the
parsed data. By default `yaml` nodes will be parsed using [`yaml`](https://github.com/eemeli/yaml)
and `toml` nodes using [`toml`](https://github.com/BinaryMuse/toml-node).
In addition it supports `unist-util-mdx-define`
[options](https://github.com/remcohaszing/unist-util-mdx-define#options).
## Compatibility
This project is compatible with Node.js 18 or greater.
## License
[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)

View File

@@ -0,0 +1,38 @@
import { type Root } from 'mdast';
import { type Plugin } from 'unified';
import { define } from 'unist-util-mdx-define';
type FrontmatterParsers = Record<string, (value: string) => unknown>;
export interface RemarkMdxFrontmatterOptions extends define.Options {
/**
* The default value to export if no frontmatter data is found.
*
* @default undefined
*/
default?: unknown;
/**
* If specified, the YAML data is exported using this name. Otherwise, each
* object key will be used as an export name.
*/
name?: string;
/**
* A mapping of node types to parsers.
*
* Each key represents a frontmatter node type. The value is a function that accepts the
* frontmatter data as a string, and returns the parsed data.
*
* By default `yaml` nodes will be parsed using [`yaml`](https://github.com/eemeli/yaml) and
* `toml` nodes using [`toml`](https://github.com/BinaryMuse/toml-node).
*/
parsers?: FrontmatterParsers;
}
/**
* A remark plugin to expose frontmatter data as named exports.
*
* @param options
* Optional options to configure the output.
* @returns
* A unified transformer.
*/
declare const remarkMdxFrontmatter: Plugin<[RemarkMdxFrontmatterOptions?], Root>;
export default remarkMdxFrontmatter;
//# sourceMappingURL=remark-mdx-frontmatter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"remark-mdx-frontmatter.d.ts","sourceRoot":"","sources":["../src/remark-mdx-frontmatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAG9C,KAAK,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;AAEpE,MAAM,WAAW,2BAA4B,SAAQ,MAAM,CAAC,OAAO;IACjE;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,EAAE,MAAM,CAAC,CAAC,2BAA2B,CAAC,CAAC,EAAE,IAAI,CAwBtE,CAAA;AAED,eAAe,oBAAoB,CAAA"}

View File

@@ -0,0 +1,31 @@
import { valueToEstree } from 'estree-util-value-to-estree';
import { parse as parseToml } from 'toml';
import { define } from 'unist-util-mdx-define';
import { parse as parseYaml } from 'yaml';
/**
* A remark plugin to expose frontmatter data as named exports.
*
* @param options
* Optional options to configure the output.
* @returns
* A unified transformer.
*/
const remarkMdxFrontmatter = ({ name = 'frontmatter', parsers, ...options } = {}) => {
const allParsers = {
yaml: parseYaml,
toml: parseToml,
...parsers
};
return (ast, file) => {
let data = options.default;
const node = ast.children.find((child) => Object.hasOwn(allParsers, child.type));
if (node) {
const parser = allParsers[node.type];
const { value } = node;
data = parser(value);
}
define(ast, file, { [name]: valueToEstree(data, { preserveReferences: true }) }, options);
};
};
export default remarkMdxFrontmatter;
//# sourceMappingURL=remark-mdx-frontmatter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"remark-mdx-frontmatter.js","sourceRoot":"","sources":["../src/remark-mdx-frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAA;AA8BzC;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAAiD,CAAC,EAC1E,IAAI,GAAG,aAAa,EACpB,OAAO,EACP,GAAG,OAAO,EACX,GAAG,EAAE,EAAE,EAAE;IACR,MAAM,UAAU,GAAuB;QACrC,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,GAAG,OAAO;KACX,CAAA;IAED,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACnB,IAAI,IAAI,GAAG,OAAO,CAAC,OAAO,CAAA;QAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhF,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAEpC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAe,CAAA;YACjC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QAED,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC3F,CAAC,CAAA;AACH,CAAC,CAAA;AAED,eAAe,oBAAoB,CAAA"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=remark-mdx-frontmatter.test.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"remark-mdx-frontmatter.test.d.ts","sourceRoot":"","sources":["../src/remark-mdx-frontmatter.test.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,21 @@
import { compile } from '@mdx-js/mdx';
import remarkFrontmatter from 'remark-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
import { testFixturesDirectory } from 'snapshot-fixtures';
testFixturesDirectory({
directory: new URL('../fixtures', import.meta.url),
prettier: true,
write: true,
tests: {
'expected.jsx'(file, options) {
return compile(file, {
remarkPlugins: [
[remarkFrontmatter, ['yaml', 'toml']],
[remarkMdxFrontmatter, options]
],
jsx: true
});
}
}
});
//# sourceMappingURL=remark-mdx-frontmatter.test.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"remark-mdx-frontmatter.test.js","sourceRoot":"","sources":["../src/remark-mdx-frontmatter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,iBAAiB,MAAM,oBAAoB,CAAA;AAClD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,qBAAqB,CAAC;IACpB,SAAS,EAAE,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAClD,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,KAAK,EAAE;QACL,cAAc,CAAC,IAAI,EAAE,OAAO;YAC1B,OAAO,OAAO,CAAC,IAAI,EAAE;gBACnB,aAAa,EAAE;oBACb,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBACrC,CAAC,oBAAoB,EAAE,OAAO,CAAC;iBAChC;gBACD,GAAG,EAAE,IAAI;aACV,CAAC,CAAA;QACJ,CAAC;KACF;CACF,CAAC,CAAA"}

56
node_modules/remark-mdx-frontmatter/package.json generated vendored Normal file
View File

@@ -0,0 +1,56 @@
{
"name": "remark-mdx-frontmatter",
"version": "5.2.0",
"description": "A remark plugin for converting frontmatter metadata into MDX exports",
"author": "Remco Haszing <remcohaszing@gmail.com>",
"license": "MIT",
"type": "module",
"exports": "./dist/remark-mdx-frontmatter.js",
"main": "./dist/remark-mdx-frontmatter.js",
"repository": "remcohaszing/remark-mdx-frontmatter",
"bugs": "https://github.com/remcohaszing/remark-mdx-frontmatter/issues",
"homepage": "https://github.com/remcohaszing/remark-mdx-frontmatter#readme",
"funding": "https://github.com/sponsors/remcohaszing",
"keywords": [
"frontmatter",
"markdown",
"markdown-frontmatter",
"mdast",
"mdx",
"remark",
"remark-plugin",
"toml",
"unified",
"yaml"
],
"files": [
"dist",
"src",
"!test*"
],
"scripts": {
"prepack": "tsc --build",
"pretest": "tsc --build",
"test": "c8 node --test --enable-source-maps --test-reporter junit --test-reporter-destination junit.xml --test-reporter spec --test-reporter-destination stdout"
},
"dependencies": {
"@types/mdast": "^4.0.0",
"estree-util-value-to-estree": "^3.0.0",
"toml": "^3.0.0",
"unified": "^11.0.0",
"unist-util-mdx-define": "^1.0.0",
"yaml": "^2.0.0"
},
"devDependencies": {
"@mdx-js/mdx": "^3.0.0",
"@remcohaszing/eslint": "^11.0.0",
"c8": "^10.0.0",
"mdast-util-mdx": "^3.0.0",
"prettier": "^3.0.0",
"remark-cli": "^12.0.0",
"remark-frontmatter": "^5.0.0",
"remark-preset-remcohaszing": "^3.0.0",
"snapshot-fixtures": "^1.0.0",
"typescript": "^5.0.0"
}
}

View File

@@ -0,0 +1,21 @@
import { compile } from '@mdx-js/mdx'
import remarkFrontmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
import { testFixturesDirectory } from 'snapshot-fixtures'
testFixturesDirectory({
directory: new URL('../fixtures', import.meta.url),
prettier: true,
write: true,
tests: {
'expected.jsx'(file, options) {
return compile(file, {
remarkPlugins: [
[remarkFrontmatter, ['yaml', 'toml']],
[remarkMdxFrontmatter, options]
],
jsx: true
})
}
}
})

View File

@@ -0,0 +1,70 @@
import { valueToEstree } from 'estree-util-value-to-estree'
import { type Literal, type Root } from 'mdast'
import { parse as parseToml } from 'toml'
import { type Plugin } from 'unified'
import { define } from 'unist-util-mdx-define'
import { parse as parseYaml } from 'yaml'
type FrontmatterParsers = Record<string, (value: string) => unknown>
export interface RemarkMdxFrontmatterOptions extends define.Options {
/**
* The default value to export if no frontmatter data is found.
*
* @default undefined
*/
default?: unknown
/**
* If specified, the YAML data is exported using this name. Otherwise, each
* object key will be used as an export name.
*/
name?: string
/**
* A mapping of node types to parsers.
*
* Each key represents a frontmatter node type. The value is a function that accepts the
* frontmatter data as a string, and returns the parsed data.
*
* By default `yaml` nodes will be parsed using [`yaml`](https://github.com/eemeli/yaml) and
* `toml` nodes using [`toml`](https://github.com/BinaryMuse/toml-node).
*/
parsers?: FrontmatterParsers
}
/**
* A remark plugin to expose frontmatter data as named exports.
*
* @param options
* Optional options to configure the output.
* @returns
* A unified transformer.
*/
const remarkMdxFrontmatter: Plugin<[RemarkMdxFrontmatterOptions?], Root> = ({
name = 'frontmatter',
parsers,
...options
} = {}) => {
const allParsers: FrontmatterParsers = {
yaml: parseYaml,
toml: parseToml,
...parsers
}
return (ast, file) => {
let data = options.default
const node = ast.children.find((child) => Object.hasOwn(allParsers, child.type))
if (node) {
const parser = allParsers[node.type]
const { value } = node as Literal
data = parser(value)
}
define(ast, file, { [name]: valueToEstree(data, { preserveReferences: true }) }, options)
}
}
export default remarkMdxFrontmatter