[Not so] new website with Astro


This is the third version of this site. Only two rewrites (one from scratch, this one not so much) in 10 years is not too many, right? I’ve heard of Astro in an episode of syntax.fm and it got my attention. It is a very flexible tool for site generation, and it doesn’t get into the corporate approach by Gatsby.

The first step was to test if it was feasible to keep the old urls from the current site with this new tool. And with minimal editions at the frontmatter1, not only it was possible, but easy. See the code below, how intuitive it was to adapt the current existing blog content collection to the legacy content from Jekyll:

const legacyPost = defineCollection({
    loader: glob({base: './src/content/legacy-posts', pattern: '**/*.{md,mdx}'}),
    schema: z.object({
        title: z.string(),
        date: z.string(),
        updatedDate: z.string().optional(),
        description: z.string().optional(),
        image: z.string().optional(),
        altimg: z.string().optional(),
        // this param will probably be deleted,
        // since it's not being used anymore.
        img_full: z.coerce.boolean().optional(),
    })
});
File content.config.ts in the root of an Astro project.

I’ve decided into calling this legacy because I wanted to change the frontmatter structure, removing workarounds and what some might call technical debt from years that I’ve used on Jekyll. But, also giving space to learn new ways to do things in a new tool. Besides, the captioned code element above is way easier to do on Astro mdx files than the plain markdown files from Jekyll.

Footnotes

  1. Frontmatter: metadata area in a markdown file, in this case, a solution used both by Astro and Jekyll