11 lines
363 B
TypeScript
11 lines
363 B
TypeScript
/**
|
|
* Extract the `version` field from YAML frontmatter.
|
|
* Returns 0 if no version is found.
|
|
*/
|
|
export function parseSeedVersion(content: string): number {
|
|
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
if (!match) return 0;
|
|
const versionMatch = match[1]!.match(/^version:\s*(\d+)/m);
|
|
return versionMatch ? parseInt(versionMatch[1]!, 10) : 0;
|
|
}
|