More fixes

This commit is contained in:
Luke Vella 2024-10-13 10:59:27 +01:00
parent 1a5b2f206d
commit c9f6b67cbf
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C

View file

@ -1,6 +1,6 @@
import fs from "node:fs";
import matter from "gray-matter";
import { join } from "node:path";
import matter from "gray-matter";
const postsDirectory = join(process.cwd(), "src", "posts");
@ -21,7 +21,7 @@ export function getPostBySlug(slug: string, fields: string[] = []) {
const items: Items = {};
// Ensure only the minimal needed data is exposed
fields.forEach((field) => {
for (const field of fields) {
if (field === "slug") {
items[field] = realSlug;
}
@ -32,7 +32,7 @@ export function getPostBySlug(slug: string, fields: string[] = []) {
if (typeof data[field] !== "undefined") {
items[field] = data[field];
}
});
}
return items;
}