Files
zeekay ca2c2f21a1 Merge upstream fumadocs dev (27 commits)
- Synced with upstream fumadocs changes
- Accepted upstream changes for all conflicts
- Deleted files that no longer exist upstream
- Maintains @hanzo package namespace
2025-12-30 17:54:34 -08:00

30 lines
691 B
TypeScript

import type { Pluggable } from 'unified';
import matter from 'gray-matter';
export type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
export function pluginOption(
def: (v: Pluggable[]) => (Pluggable | false | null)[],
options: ResolvePlugins = [],
): Pluggable[] {
const list = def(Array.isArray(options) ? options : []).filter(Boolean) as Pluggable[];
if (typeof options === 'function') {
return options(list);
}
return list;
}
/**
* Parse frontmatter, currently powered by `gray-matter`
*/
export function parseFrontmatter(content: string) {
const out = matter(content);
return {
frontmatter: out.data,
content: out.content,
};
}