diff --git a/astro.config.mjs b/astro.config.mjs index af4988b..7b5a8e9 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -12,4 +12,5 @@ export default defineConfig({ }, }, }, + site: "https://blog.cloverta.top" }) diff --git a/package-lock.json b/package-lock.json index 640056e..716a31e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "sanyecao-blog", "version": "0.0.1", "dependencies": { + "@astrojs/rss": "^4.0.17", "astro": "^6.0.8", "url": "^0.11.4" }, @@ -73,6 +74,17 @@ "node": ">=22.12.0" } }, + "node_modules/@astrojs/rss": { + "version": "4.0.17", + "resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-4.0.17.tgz", + "integrity": "sha512-eV+wdMbeVKC9+sPaV0LN8JL1LGo9YAh3GKl4Ou4nzMNLmXM/aswYpSGxVEAuHilgBZ6/++/Pv08ICmuOqX107w==", + "license": "MIT", + "dependencies": { + "fast-xml-parser": "5.4.1", + "piccolore": "^0.1.3", + "zod": "^4.3.6" + } + }, "node_modules/@astrojs/telemetry": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.3.0.tgz", @@ -2371,6 +2383,40 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "license": "MIT" }, + "node_modules/fast-xml-builder": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", + "integrity": "sha512-f2jhpN4Eccy0/Uz9csxh3Nu6q4ErKxf0XIsasomfOihuSUa3/xw6w8dnOtCDgEItQFJG8KyXPzQXzcODDrrbOg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "dependencies": { + "path-expression-matcher": "^1.1.3" + } + }, + "node_modules/fast-xml-parser": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.4.1.tgz", + "integrity": "sha512-BQ30U1mKkvXQXXkAGcuyUA/GA26oEB7NzOtsxCDtyu62sjGw5QraKFhx2Em3WQNjPw9PG6MQ9yuIIgkSDfGu5A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "dependencies": { + "fast-xml-builder": "^1.0.0", + "strnum": "^2.1.2" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -3892,6 +3938,21 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/path-expression-matcher": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.2.0.tgz", + "integrity": "sha512-DwmPWeFn+tq7TiyJ2CxezCAirXjFxvaiD03npak3cRjlP9+OjTmSy1EpIrEbh+l6JgUundniloMLDQ/6VTdhLQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/piccolore": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/piccolore/-/piccolore-0.1.3.tgz", @@ -4482,6 +4543,18 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/strnum": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.2.tgz", + "integrity": "sha512-DnR90I+jtXNSTXWdwrEy9FakW7UX+qUZg28gj5fk2vxxl7uS/3bpI4fjFYVmdK9etptYBPNkpahuQnEwhwECqA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" + }, "node_modules/svgo": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/svgo/-/svgo-4.0.1.tgz", diff --git a/package.json b/package.json index f87d44f..c85ab4c 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "astro": "astro" }, "dependencies": { + "@astrojs/rss": "^4.0.17", "astro": "^6.0.8", "url": "^0.11.4" }, diff --git a/src/pages/posts/post-1.md b/src/blog/post-1.md similarity index 95% rename from src/pages/posts/post-1.md rename to src/blog/post-1.md index 3fb7150..8f2e7b7 100644 --- a/src/pages/posts/post-1.md +++ b/src/blog/post-1.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/MarkdownPostLayout.astro title: 'My First Blog Post' pubDate: 2022-07-01 description: 'This is the first post of my new Astro blog.' diff --git a/src/components/Header.astro b/src/components/Header.astro index e69de29..4a13a56 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -0,0 +1,20 @@ +--- +import Navigation from "./Navigation.astro"; +import ThemeIcon from "./ThemeIcon.astro"; +--- + +
+ +
+ + diff --git a/src/components/Posts/PostList.astro b/src/components/Posts/PostList.astro index db45052..81f7961 100644 --- a/src/components/Posts/PostList.astro +++ b/src/components/Posts/PostList.astro @@ -1,18 +1,24 @@ --- +import { getCollection } from "astro:content"; import PostItem from "./PostItem.astro"; -const allPosts = Object.values(import.meta.glob('@/pages/posts/*.md', { eager: true })); +const allPosts = await getCollection("blog"); --- - diff --git a/src/components/ThemeIcon.astro b/src/components/ThemeIcon.astro new file mode 100644 index 0000000..f7b7ed6 --- /dev/null +++ b/src/components/ThemeIcon.astro @@ -0,0 +1,77 @@ +--- + +--- + + + + + + diff --git a/src/content.config.ts b/src/content.config.ts new file mode 100644 index 0000000..ecea83b --- /dev/null +++ b/src/content.config.ts @@ -0,0 +1,23 @@ +// Import the glob loader +import { glob } from "astro/loaders"; +// Import utilities from `astro:content` +import { defineCollection } from "astro:content"; +// Import Zod +import { z } from "astro/zod"; +// Define a `loader` and `schema` for each collection +const blog = defineCollection({ + loader: glob({ pattern: '**/[^_]*.md', base: "./src/blog" }), + schema: z.object({ + title: z.string(), + pubDate: z.date(), + description: z.string(), + author: z.string(), + image: z.object({ + url: z.string(), + alt: z.string() + }), + tags: z.array(z.string()) + }) +}); +// Export a single `collections` object to register your collection(s) +export const collections = { blog }; \ No newline at end of file diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index b4bc5f6..51ecd43 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,5 +1,6 @@ --- -import Footer from "../components/Footer.astro" +import Footer from "../components/Footer.astro"; +import Header from "@/components/Header.astro"; const { pageTitle } = Astro.props; --- @@ -14,6 +15,7 @@ const { pageTitle } = Astro.props; {pageTitle} +