diff --git a/src/content/blog.ts b/src/content/blog.ts index 85991b3..339df8e 100644 --- a/src/content/blog.ts +++ b/src/content/blog.ts @@ -1,11 +1,11 @@ -import type { BlogPost } from '$lib/types/blog'; +import type { Post } from '$lib/types/post'; import type { MarkdownMetadata } from '$content/types'; import type { MdsvexImport } from './types'; import { parseReadContent } from '$content/utils'; import { error } from '@sveltejs/kit'; -export function listBlogPosts() { - const posts = import.meta.glob('./blog/*.md', { +export function listPosts() { + const posts = import.meta.glob('./blog/*.md', { eager: true, import: 'metadata' }); @@ -13,14 +13,14 @@ export function listBlogPosts() { return parseReadContent(posts); } -export async function getBlogPostMetadata(slug: string) { - const { post } = await getBlogPost(slug); +export async function getPostMetadata(slug: string) { + const { post } = await getPost(slug); return post; } -export async function getBlogPost(slug: string) { +export async function getPost(slug: string) { try { - const data: MdsvexImport = await import(`./blog/${slug}.md`); + const data: MdsvexImport = await import(`./blog/${slug}.md`); return { post: { ...data.metadata, slug }, diff --git a/src/content/projects.ts b/src/content/projects.ts index d1f0242..bd46ce9 100644 --- a/src/content/projects.ts +++ b/src/content/projects.ts @@ -1,4 +1,6 @@ -import type { MarkdownMetadata, MdsvexImport } from './types'; +import type { MdsvexImport } from '$content/types'; +import type { MarkdownMetadata } from '$content/types'; +import type { Project } from '$lib/types/projects'; import { parseReadContent } from './utils'; import { error } from '@sveltejs/kit'; @@ -13,10 +15,16 @@ export function listProjects() { return parseReadContent(projects); } +export async function getProjectMetadata(slug: string) { + const { post } = await getProject(slug); + return post; +} export async function getProject(slug: string) { try { - const data: MdsvexImport = await import(`./projects/${slug}.md`); + const data: MdsvexImport = await import( + `./projects/${slug}.md` + ); return { post: { ...data.metadata, slug },