Update formats of a blog page
This commit is contained in:
parent
c23ff1633c
commit
fc2a5be2e7
4 changed files with 16 additions and 9 deletions
|
|
@ -1,10 +1,8 @@
|
|||
// Import the glob loader
|
||||
import { glob } from "astro/loaders";
|
||||
// Import utilities from `astro:content`
|
||||
import { z, defineCollection } from "astro:content";
|
||||
// Define a `loader` and `schema` for each collection
|
||||
|
||||
const blog = defineCollection({
|
||||
loader: glob({ pattern: '**/[^_]*.md', base: "./src/blog" }),
|
||||
loader: glob({ pattern: '**/post-*.md', base: "./src/blog" }),
|
||||
schema: z.object({
|
||||
title: z.string(),
|
||||
pubDate: z.date(),
|
||||
|
|
@ -12,5 +10,5 @@ const blog = defineCollection({
|
|||
tags: z.array(z.string())
|
||||
})
|
||||
});
|
||||
// Export a single `collections` object to register your collection(s)
|
||||
|
||||
export const collections = { blog };
|
||||
|
|
@ -1,13 +1,20 @@
|
|||
---
|
||||
import BaseLayout from "./BaseLayout.astro";
|
||||
const { frontmatter } = Astro.props;
|
||||
|
||||
const optionsForDate = {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
timeZone: "UTC",
|
||||
timeZoneName:"short"
|
||||
};
|
||||
---
|
||||
|
||||
<BaseLayout pageTitle={frontmatter.title}>
|
||||
<p>{frontmatter.pubDate.toLocaleDateString()}</p>
|
||||
<p><em>{frontmatter.description}</em></p>
|
||||
<p>Created on: {frontmatter.pubDate.toLocaleDateString("ja-JP", optionsForDate)}</p>
|
||||
<p>Written by: {frontmatter.author}</p>
|
||||
<img src={frontmatter.image.url} width="300" alt={frontmatter.image.alt} />
|
||||
<p><em>{frontmatter.description}</em></p>
|
||||
<div class="tags">
|
||||
{
|
||||
frontmatter.tags.map((tag: string) => (
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
],
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
"jsxImportSource": "preact",
|
||||
"strictNullChecks": true,
|
||||
"allowJs": true
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue