Skip to content

Commit

Permalink
Removed gray-matter as a dep
Browse files Browse the repository at this point in the history
  • Loading branch information
RealA10N committed Dec 19, 2023
1 parent 03dd88a commit b0a24a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 106 deletions.
99 changes: 0 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"d3": "^7.8.4",
"d3-force": "^3.0.0",
"edmonds-blossom-fixed": "^1.0.1",
"gray-matter": "^4.0.3",
"moment": "^2.29.4",
"structurae": "^4.0.2"
}
Expand Down
11 changes: 5 additions & 6 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import matter from 'gray-matter';
import moment from 'moment';
import type { PageServerLoad } from './$types';
import type { Post } from '$lib/interfaces/post';
Expand All @@ -11,18 +10,18 @@ function globToUrl(glob: string) {
}

export const load = (async () => {
const globs = import.meta.glob('./posts/*/+page.md', { as: 'raw' });
const globs = import.meta.glob('./posts/*/+page.md');

const contents = await Promise.all(
Object.entries(globs).map(async ([glob, fn]) => [globToUrl(glob), await fn()])
);

const posts = contents.map(([url, content]) => {
const data = matter(content).data;
const posts = contents.map(([url, { metadata }]) => {
metadata as Post;
return {
...data,
...metadata,
url: url,
published: moment(data.published).unix() * 1000
published: moment(metadata.published).unix() * 1000
} as Post;
});

Expand Down

0 comments on commit b0a24a6

Please sign in to comment.