From d616a73c939218b2caed5759fa879f63284844b7 Mon Sep 17 00:00:00 2001 From: satnaing Date: Tue, 31 Jan 2023 00:20:53 +0630 Subject: [PATCH] docs: add AstroPaper v2 release blog post --- src/content/blog/astro-paper-2.md | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/content/blog/astro-paper-2.md diff --git a/src/content/blog/astro-paper-2.md b/src/content/blog/astro-paper-2.md new file mode 100644 index 0000000..a987a64 --- /dev/null +++ b/src/content/blog/astro-paper-2.md @@ -0,0 +1,72 @@ +--- +author: Sat Naing +pubDatetime: 2023-01-30T15:57:52.737Z +title: AstroPaper 2.0 +postSlug: astro-paper-2 +ogImage: "" +tags: + - release +description: AstroPaper with the enhancements of Astro v2. Type-safe markdown contents, bug fixes and better dev experience etc. +--- + +Astro 2.0 has been released with some cool features, breaking changes, DX improvements, better error overlay and so on. AstroPaper takes advantage of those cool features, especially Content Collections API. + +## Table of contents + +## Features & Changes + +### Type-safe Frontmatters and Redefined Blog Schema + +Frontmatter of AstroPaper 2.0 markdown contents are now type-safe thanks to Astro’s Content Collections. Blog schema is defined inside the `src/content/_schemas.ts` file. + +### New Home for Blog contents + +All the blog posts were moved from `src/contents` to `src/content/blog` directory. + +### New Fetch API + +Contents are now fetched with `getCollection` function. No relative path to the content needs to be specified anymore. + +```ts +// old content fetching method +- const postImportResult = import.meta.glob>( + "../contents/**/**/*.md",); + +// new content fetching method ++ const postImportResult = await getCollection("blog"); +``` + +### Renamed Frontmatter Properties + +The following frontmatter properties are renamed. + +| Old Names | New Names | +| --------- | ----------- | +| datetime | pubDatetime | +| slug | postSlug | + +### Default Tag for blog post + +If a blog post doesn't have any tag (in other words, frontmatter property `tags` is not specified), the default tag `others` will be used for that blog post. But you can set the default tag in the `/src/content/_schemas.ts` file. + +```ts +// src/contents/_schemas.ts +export const blogSchema = z.object({ + // --- + // replace "others" with whatever you want + tags: z.array(z.string()).default(["others"]), + ogImage: z.string().optional(), + description: z.string(), +}); +``` + +### Updated Docs & README + +All the [#docs](https://astro-paper.pages.dev/tags/docs/) blog posts and [README](https://github.com/satnaing/astro-paper#readme) are updated for this AstroPaper v2. + +## Bug Fixes + +- fix broken tags in the Blog Post page +- in a tag page, the last part of the breadcrumb is now updated to lower-case for consistency +- exclude draft posts in a tag page +- fix 'onChange value not updating issue' after a page reload