Skip to content

Commit

Permalink
Don't use lib import in +page.server.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
matekdev committed Nov 11, 2023
1 parent 3ac3862 commit 4736c51
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/routes/blog/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import type { EntryGenerator } from './$types';
import { SlugFromPath } from '$lib/slugFromPath';

function slugFromPath(path: string) {
return path.match(/([\w-]+)\.(svelte\.md|md|svx)/i)?.[1] ?? null;
}

export const entries: EntryGenerator = async () => {
const modules = import.meta.glob(`/src/blogs/*.{md,svx,svelte.md}`);
const postPromises = Object.entries(modules).map(([path, resolver]) =>
resolver().then(
(post) =>
({
slug: SlugFromPath(path),
slug: slugFromPath(path),
...(post as unknown as App.MdsvexFile).metadata
}) as App.BlogPost
)
Expand Down

0 comments on commit 4736c51

Please sign in to comment.