feat: complete MDX migration, stabilize routing and lead capture

Former-commit-id: ab5cc38c97e5f73d6e821465b90d199fb6e6edc9
This commit is contained in:
2026-05-03 21:06:47 +02:00
parent b13f628b55
commit f2fdea96ec
7175 changed files with 371649 additions and 1078689 deletions

View File

@@ -0,0 +1 @@
../../vfile@6.0.3/node_modules/vfile

View File

@@ -0,0 +1,4 @@
export { matter } from "./lib/index.js";
export type Options = import("./lib/index.js").Options;
export type YamlOptions = import("./lib/index.js").YamlOptions;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":";sBACa,OAAO,gBAAgB,EAAE,OAAO;0BAChC,OAAO,gBAAgB,EAAE,WAAW"}

View File

@@ -0,0 +1,6 @@
/**
* @typedef {import('./lib/index.js').Options} Options
* @typedef {import('./lib/index.js').YamlOptions} YamlOptions
*/
export {matter} from './lib/index.js'

View File

@@ -0,0 +1,43 @@
/**
* Parse the YAML front matter in a file and expose it as `file.data.matter`.
*
* If no matter is found in the file, nothing happens, except that
* `file.data.matter` is set to an empty object (`{}`).
*
* If the file value is an `Uint8Array`, assumes it is encoded in UTF-8.
*
* @param {VFile} file
* Virtual file.
* @param {Readonly<Options> | null | undefined} [options={}]
* Configuration (optional).
* @returns {undefined}
* Nothing.
*/
export function matter(file: VFile, options?: Readonly<Options> | null | undefined): undefined;
/**
* Configuration (optional).
*/
export type Options = {
/**
* Remove the YAML front matter from the file (default: `false`).
*/
strip?: boolean | null | undefined;
/**
* Configuration for the YAML parser, passed to `yaml` as `x` in
* `yaml.parse('', x)` (default: `{}`).
*/
yaml?: Readonly<YamlOptions> | null | undefined;
};
/**
* Flatten a TypeScript record.
*/
export type Prettify<Type> = { [Key in keyof Type]: Type[Key]; } & {};
/**
* Options for the YAML parser.
*
* Equivalent to `DocumentOptions`, `ParseOptions`, `SchemaOptions`, and `ToJsOptions`.
*/
export type YamlOptions = Prettify<yaml.DocumentOptions & yaml.ParseOptions & yaml.SchemaOptions & yaml.ToJSOptions>;
import type { VFile } from 'vfile';
import yaml from 'yaml';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;GAcG;AACH,6BAPW,KAAK,YAEL,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAElC,SAAS,CAwBrB;;;;;;;;YAlEa,OAAO,GAAG,IAAI,GAAG,SAAS;;;;;WAE1B,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS;;;;;qBAMzC,IAAI,IAEJ,GAAE,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAC,GAAG,EAAE;;;;;;0BAKrC,QAAQ,CAAC,oBAAe,GAAG,iBAAY,GAAG,kBAAa,GAAG,gBAAW,CAAC;2BA3B3D,OAAO;iBAiCd,MAAM"}

View File

@@ -0,0 +1,80 @@
/**
* @import {VFile} from 'vfile'
* @import {
* DocumentOptions,
* ParseOptions,
* SchemaOptions,
* ToJSOptions as ToJsOptions
* } from 'yaml'
*/
/**
* @typedef Options
* Configuration (optional).
* @property {boolean | null | undefined} [strip=false]
* Remove the YAML front matter from the file (default: `false`).
* @property {Readonly<YamlOptions> | null | undefined} [yaml={}]
* Configuration for the YAML parser, passed to `yaml` as `x` in
* `yaml.parse('', x)` (default: `{}`).
*/
/**
* @template Type
* Type.
* @typedef {{[Key in keyof Type]: Type[Key]} & {}} Prettify
* Flatten a TypeScript record.
*/
/**
* @typedef {Prettify<DocumentOptions & ParseOptions & SchemaOptions & ToJsOptions>} YamlOptions
* Options for the YAML parser.
*
* Equivalent to `DocumentOptions`, `ParseOptions`, `SchemaOptions`, and `ToJsOptions`.
*/
import yaml from 'yaml'
const regex = /^---(?:\r?\n|\r)(?:([\s\S]*?)(?:\r?\n|\r))?---(?:\r?\n|\r|$)/
/** @type {Readonly<Options>} */
const emptyOptions = {}
/** @type {Readonly<YamlOptions>} */
const emptyYamlOptions = {}
/**
* Parse the YAML front matter in a file and expose it as `file.data.matter`.
*
* If no matter is found in the file, nothing happens, except that
* `file.data.matter` is set to an empty object (`{}`).
*
* If the file value is an `Uint8Array`, assumes it is encoded in UTF-8.
*
* @param {VFile} file
* Virtual file.
* @param {Readonly<Options> | null | undefined} [options={}]
* Configuration (optional).
* @returns {undefined}
* Nothing.
*/
export function matter(file, options) {
const options_ = options || emptyOptions
const strip = options_.strip
const yamlOptions = options_.yaml || emptyYamlOptions
let document = String(file)
const match = regex.exec(document)
if (match) {
file.data.matter = yaml.parse(match[1] || '', yamlOptions) || {}
if (strip) {
document = document.slice(match[0].length)
file.value =
file.value && typeof file.value === 'object'
? new TextEncoder().encode(document)
: document
}
} else {
file.data.matter = {}
}
}

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) Titus Wormer <tituswormer@gmail.com>
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.

View File

@@ -0,0 +1,21 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -z "$NODE_PATH" ]; then
export NODE_PATH="/Volumes/Alpha SSD/Coding/e-tib.com/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/node_modules:/Volumes/Alpha SSD/Coding/e-tib.com/node_modules/.pnpm/yaml@2.8.3/node_modules:/Volumes/Alpha SSD/Coding/e-tib.com/node_modules/.pnpm/node_modules"
else
export NODE_PATH="/Volumes/Alpha SSD/Coding/e-tib.com/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/node_modules:/Volumes/Alpha SSD/Coding/e-tib.com/node_modules/.pnpm/yaml@2.8.3/node_modules:/Volumes/Alpha SSD/Coding/e-tib.com/node_modules/.pnpm/node_modules:$NODE_PATH"
fi
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../../../../../yaml@2.8.3/node_modules/yaml/bin.mjs" "$@"
else
exec node "$basedir/../../../../../yaml@2.8.3/node_modules/yaml/bin.mjs" "$@"
fi

View File

@@ -0,0 +1,77 @@
{
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"bugs": "https://github.com/vfile/vfile-matter/issues",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"dependencies": {
"vfile": "^6.0.0",
"yaml": "^2.0.0"
},
"description": "vfile utility to parse the YAML front matter in a file",
"devDependencies": {
"@types/node": "^22.0.0",
"c8": "^10.0.0",
"prettier": "^3.0.0",
"remark-cli": "^12.0.0",
"remark-preset-wooorm": "^11.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"xo": "^0.60.0"
},
"exports": "./index.js",
"files": [
"index.d.ts.map",
"index.d.ts",
"index.js",
"lib/"
],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"keywords": [
"file",
"frontmatter",
"matter",
"utility",
"util",
"vfile-util",
"vfile",
"virtual",
"yaml"
],
"license": "MIT",
"name": "vfile-matter",
"prettier": {
"bracketSpacing": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"remarkConfig": {
"plugins": [
"remark-preset-wooorm"
]
},
"repository": "vfile/vfile-matter",
"scripts": {
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --100 --reporter lcov -- npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"sideEffects": false,
"typeCoverage": {
"atLeast": 100,
"strict": true
},
"type": "module",
"version": "5.0.1",
"xo": {
"prettier": true
}
}

View File

@@ -0,0 +1,272 @@
# vfile-matter
[![Build][badge-build-image]][badge-build-url]
[![Coverage][badge-coverage-image]][badge-coverage-url]
[![Downloads][badge-downloads-image]][badge-downloads-url]
[![Size][badge-size-image]][badge-size-url]
[vfile][github-vfile] utility parse YAML front matter.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`matter(file[, options])`](#matterfile-options)
* [`Options`](#options)
* [`YamlOptions`](#yamloptions)
* [Types](#types)
* [Compatibility](#compatibility)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package parses YAML frontmatter,
when found in a file,
and exposes it as `file.data.matter`.
It can optionally strip the frontmatter,
which is useful for languages that do not understand frontmatter,
but stripping can make it harder to deal with languages that *do* understand it,
such as markdown,
because it messes up positional info of warnings and errors.
## When should I use this?
Frontmatter is a metadata format in front of content.
Its typically written in YAML and is often used with markdown.
This mechanism works well when you want authors,
that have some markup experience,
to configure where or how the content is displayed or supply metadata about
content.
When using vfiles with markdown,
you are likely also using [remark][github-remark],
in which case you should use [`remark-frontmatter`][github-remark-frontmatter],
instead of
stripping frontmatter.
## Install
This package is [ESM only][github-gist-esm].
In Node.js (version 16+),
install with [npm][npmjs-install]:
```sh
npm install vfile-matter
```
In Deno with [`esm.sh`][esmsh]:
```js
import {matter} from 'https://esm.sh/vfile-matter@5'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {matter} from 'https://esm.sh/vfile-matter@5?bundle'
</script>
```
## Use
Say our document `example.html` contains:
```html
---
layout: solar-system
---
<h1>Jupiter</h1>
```
…and our module `example.js` looks as follows:
```js
import {read} from 'to-vfile'
import {matter} from 'vfile-matter'
const file = await read('example.html')
matter(file, {strip: true})
console.log(file.data)
console.log(String(file))
```
…now running `node example.js` yields:
```js
{ matter: { layout: 'solar-system' } }
```
```html
<h1>Jupiter</h1>
```
## API
This package exports the identifier [`matter`][api-matter].
It exports the [TypeScript][] types
[`Options`][api-options] and
[`YamlOptions`][api-yaml-options].
There is no default export.
### `matter(file[, options])`
Parse the YAML front matter in a file and expose it as `file.data.matter`.
If no matter is found in the file,
nothing happens,
except that `file.data.matter` is set to an empty object (`{}`).
If the file value is an `Uint8Array`,
assumes it is encoded in UTF-8.
###### Parameters
* `file`
([`VFile`][github-vfile])
— virtual file
* `options`
([`Options`][api-options], default: `{}`)
— configuration
###### Returns
Nothing (`undefined`).
### `Options`
Configuration (TypeScript type).
###### Fields
* `strip`
(`boolean`, default: `false`)
— remove the YAML front matter from the file
* `yaml`
([`YamlOptions`][api-yaml-options], default: `{}`)
— configuration for the YAML parser,
passed to [`yaml`][github-yaml] as `x` in `yaml.parse('', x)`
### `YamlOptions`
Options for the YAML parser (TypeScript type).
Equivalent to the combination of
[`DocumentOptions`](https://eemeli.org/yaml/#document-options),
[`ParseOptions`](https://eemeli.org/yaml/#parse-options),
[`SchemaOptions`](https://eemeli.org/yaml/#schema-options),
and
[`ToJsOptions`](https://eemeli.org/yaml/#tojs-options).
###### Type
```ts
type YamlOptions = DocumentOptions &
ParseOptions &
SchemaOptions &
ToJsOptions
```
## Types
To type `file.data.matter` with [TypeScript][],
you can augment `DataMap` from `vfile` as follows:
```ts
declare module 'vfile' {
interface DataMap {
matter: {
// `file.data.matter.string` is typed as `string | undefined`.
title?: string | undefined
}
}
}
// You may not need this,
// but it makes sure the file is a module.
export {}
```
## Compatibility
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
`vfile-matter@5`,
compatible with Node.js 16.
## Contribute
See [`contributing.md`][health-contributing] in [`vfile/.github`][health]
for ways to get started.
See [`support.md`][health-support] for ways to get help.
This project has a [code of conduct][health-coc].
By interacting with this repository,
organization,
or community you agree to abide by its terms.
## License
[MIT][file-license] © [Titus Wormer][wooorm]
<!-- Definitions -->
[api-matter]: #matterfile-options
[api-options]: #options
[api-yaml-options]: #yamloptions
[badge-build-image]: https://github.com/vfile/vfile-matter/workflows/main/badge.svg
[badge-build-url]: https://github.com/vfile/vfile-matter/actions
[badge-coverage-image]: https://img.shields.io/codecov/c/github/vfile/vfile-matter.svg
[badge-coverage-url]: https://codecov.io/github/vfile/vfile-matter
[badge-downloads-image]: https://img.shields.io/npm/dm/vfile-matter.svg
[badge-downloads-url]: https://www.npmjs.com/package/vfile-matter
[badge-size-image]: https://img.shields.io/bundlejs/size/vfile-matter
[badge-size-url]: https://bundlejs.com/?q=vfile-matter
[esmsh]: https://esm.sh
[file-license]: license
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[github-remark]: https://github.com/remarkjs/remark
[github-remark-frontmatter]: https://github.com/remarkjs/remark-frontmatter
[github-vfile]: https://github.com/vfile/vfile
[github-yaml]: https://github.com/eemeli/yaml
[health]: https://github.com/vfile/.github
[health-coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md
[health-contributing]: https://github.com/vfile/.github/blob/main/contributing.md
[health-support]: https://github.com/vfile/.github/blob/main/support.md
[npmjs-install]: https://docs.npmjs.com/cli/install
[typescript]: https://www.typescriptlang.org
[wooorm]: https://wooorm.com

1
node_modules/.pnpm/vfile-matter@5.0.1/node_modules/yaml generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../yaml@2.8.3/node_modules/yaml