Skip to content

Commit

Permalink
switch from yaml to gray-matter
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Jun 9, 2024
1 parent 637a3d0 commit b84f1cf
Show file tree
Hide file tree
Showing 3 changed files with 770 additions and 596 deletions.
6 changes: 3 additions & 3 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vitepress";
import { readdirSync, readFileSync, statSync } from "fs";
import { join, sep } from "path";
import { parse } from "yaml";
import matter from "gray-matter";
import { fileURLToPath } from "url";
import metaTags from "./meta";

Expand Down Expand Up @@ -31,7 +31,7 @@ function computeBars() {
const file = readFileSync(fileName, { encoding: "utf8" });
const name = fileName.replace(process.cwd(), "").replace(".md", "");
// parse yaml frontmatter into object
const frontmatter = parse(file.split(/---|___|\*\*\*/g)[1]);
const frontmatter = matter(file).data;
return {
frontmatter,
text: frontmatter.title,
Expand All @@ -45,7 +45,7 @@ function computeBars() {
const category = cur.frontmatter.type;

// delete because unused
delete cur.frontmatter;
delete (cur as any).frontmatter;

// because this isn't just an object with the names as keys we need to search
const found = acc.findIndex((v) => v.text === category);
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
"preview": "vitepress preview"
},
"dependencies": {
"gray-matter": "^4.0.3",
"vitepress": "^1.2.2",
"vue": "^3.4.27",
"yaml": "^2.4.2"
"vue": "^3.4.27"
},
"devDependencies": {
"@types/node": "^20.14.2"
}
}
Loading

0 comments on commit b84f1cf

Please sign in to comment.