import fm from 'front-matter';

const modules = import.meta.glob('./BlogPosts/*.md', { query: '?raw', import: 'default' });

export async function loadPosts() {
    const posts = [];

    for (const path in modules) {
        const fileContent = await modules[path]();
        const { attributes } = fm(fileContent);

        posts.push({
            ...attributes,
            path,
        });
    }

    return posts;
}


/* // /data/blog-post-data.js
export const blogPosts = [
    {
        title: "#0 - Setting Up Camp",
        slug: "0-setting-up-camp",
        filename: "#0-setting-up-camp.md",
        date: "2025-08-24 05:00:00 UTC",
        canonical_url: "https://campfire.dlseitz.dev/0-setting-up-camp",
        tags: ["fullstack", "developerjourney", "BuildInPublic", "introduction", "Campfire-Logs"],
        header: {
            image: "./assets/kemal-berkay-dogan-TcUN5sDZPZ8-unsplash.jpg",
            attribution: 'Photo by <a href="https://unsplash.com/@kemaldgn?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Kemal Berkay Dogan</a> on <a href="https://unsplash.com/photos/a-campfire-with-a-cup-of-coffee-sitting-in-front-of-it-TcUN5sDZPZ8?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>'
        },
        published: true
    },
    {
        title: "#1 - The Great Gitea Migration",
        slug: "1-the-great-gitea-migration",
        filename: "#1-the-great-gitea-migration.md",
        date: "2025-08-27 20:19:51 UTC",
        canonical_url: "https://campfire.dlseitz.dev/1-the-great-gitea-migration",
        tags: ["Campfire-Logs", "SelfHosting", "Devops", "gitea"],
        header: {
            image: "./assets/leon-contreras-YndHL7gQIJE-unsplash.jpg",
            attribution: 'Photo by <a href="https://unsplash.com/@lc_photography?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Leon Contreras</a> on <a href="https://unsplash.com/photos/selective-focus-photography-of-marshmallows-on-fire-pit-YndHL7gQIJE?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>'
        },
        published: true
    },
    {
        title: "#2 - Retrofitting the Privacy Policy",
        slug: "2-retrofitting-the-privacy-policy",
        filename: "#2-retrofitting-the-privacy-policy.md",
        date: "2025-09-02 20:41:21 UTC",
        canonical_url: "https://campfire.dlseitz.dev/2-retrofitting-the-privacy-policy",
        tags: ["WebDevelopment", "FullStackDevelopment", "Nodejs", "DevLife", "Campfire-Logs"],
        header: {
            image: "./assets/2-privacy-policy-head-img.png",
            attribution: "Image generated with Sora. | © 2025 Derek L. Seitz"
        },
        published: true
    },
    {
        title: "#3 - Data Privacy: Things to Consider",
        slug: "3-data-privacy-things-to-consider",
        filename: "#3-data-privacy-things-to-consider.md",
        date: "2025-09-03 03:49:36 UTC",
        canonical_url: "https://campfire.dlseitz.dev/3-data-privacy-things-to-consider",
        tags: ["dataprivacy", "WebDevelopment", "Freelancing", "PrivacyPolicy", "Campfire-Logs"],
        header: {
            image: "./assets/toa-heftiba-x9I-6yoXrXE-unsplash.jpg",
        attribution: 'Photo by <a href="https://unsplash.com/@heftiba?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Toa Heftiba</a> on <a href="https://unsplash.com/photos/group-of-people-sitting-on-front-firepit-x9I-6yoXrXE?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>'
        },
        published: true
    },
    {
        title: "#4 - Refactoring a False Sense of Simplicity",
        slug: "4-refactoring-a-false-sense-of-simplicity",
        filename: "#4-refactoring-a-false-sense-of-simplicity.md",
        date: "2025-09-12 01:08:54 UTC",
        canonical_url: "https://campfire.dlseitz.dev/4-refactoring-a-false-sense-of-simplicity",
        tags: ["refactoring", "WebDevelopment", "FrontendDevelopment", "CSS", "Campfire-Logs"],
        header: {
            image: "./assets/20250911_2016_Coding by Campfire_simple_compose_01k4xqta8sfjyrws9ezcwjpg9x.png",
            attribution: "Image generated with Sora. | © 2025 Derek L. Seitz"
        },
        published: true
    },
    {
        title: "#5 - The Power of [Separation] Compels You!",
        slug: "5-the-power-of-separation-compels-you",
        filename: "#5-the-power-of-separation-compels-you.md",
        date: "2025-09-20 21:51:29 UTC",
        canonical_url: "https://campfire.dlseitz.dev/5-the-power-of-separation-compels-you",
        tags: ["WebDevelopment","refactoring","JavaScript","apiintegration", "Campfire-Logs"],
        header: {
            image: "./assets/5-separation.webp",
            attribution: "Image generated with Sora. | © 2025 Derek L. Seitz"
        },
        published: true
    },
    {
        title: "#6 - Learning React",
        slug: "6-learning-react",
        filename: "#6-learning-react.md",
        date: null,
        cononical_url: null,
        tags: null,
        published: false
    }
]; */
