diff --git a/astro.config.mjs b/astro.config.mjs index 371ea6c..7b9ca2c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,7 +5,7 @@ import { defineConfig } from "astro/config" // https://astro.build/config export default defineConfig({ - site: "https://localhost:4321/", + site: "https://astro-air.netlify.app", vite: { worker: { plugins: () => [], diff --git a/package.json b/package.json index 0d39ef3..9e4a755 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "astro": "^5.1.0", + "astro-og-canvas": "^0.5.5", + "canvaskit-wasm": "^0.39.1", "lucide-react": "^0.468.0", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e594ddc..db9ddd4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,12 @@ importers: astro: specifier: ^5.1.0 version: 5.1.0(@types/node@22.10.2)(jiti@2.4.2)(rollup@4.27.4)(typescript@5.7.2)(yaml@2.6.1) + astro-og-canvas: + specifier: ^0.5.5 + version: 0.5.5(astro@5.1.0(@types/node@22.10.2)(jiti@2.4.2)(rollup@4.27.4)(typescript@5.7.2)(yaml@2.6.1)) + canvaskit-wasm: + specifier: ^0.39.1 + version: 0.39.1 lucide-react: specifier: ^0.468.0 version: 0.468.0(react@18.3.1) @@ -1151,6 +1157,9 @@ packages: '@vscode/l10n@0.0.18': resolution: {integrity: sha512-KYSIHVmslkaCDyw013pphY+d7x1qV8IZupYfeIfzNA+nsaWHbn5uPuQRvdRFsa9zFzGeudPuoGoZ1Op4jrJXIQ==} + '@webgpu/types@0.1.21': + resolution: {integrity: sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==} + acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -1248,6 +1257,12 @@ packages: resolution: {integrity: sha512-F6NW1RJo5pp2kPnnM97M5Ohw8zAGjv83MpxHqfAochH68n/kiXN57+hYaNUCA7XkScoVNr6yzvly3hsY34TGfQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + astro-og-canvas@0.5.5: + resolution: {integrity: sha512-dbZ7voJAmvy8Zyv5zFsgENs9G4uhcCJ4nVuUPb7ymu8+Vp/jr/fdQDKPrLYUG2TSi/1HejYRnzkXcSv6ntlDTA==} + engines: {node: '>=18.14.1'} + peerDependencies: + astro: ^3.0.0 || ^4.0.0 || ^5.0.0 + astro@5.1.0: resolution: {integrity: sha512-g/cqwGK84Ozp5jyW45c3+2KQ4BeJtigbfwO8EA3lr7AC+XjE6/5dMvX4/bBaWf3gJVghd0L6cdqwlWikq+/Rrw==} engines: {node: ^18.17.1 || ^20.3.0 || >=22.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0'} @@ -1329,6 +1344,9 @@ packages: caniuse-lite@1.0.30001684: resolution: {integrity: sha512-G1LRwLIQjBQoyq0ZJGqGIJUXzJ8irpbjHLpVRXDvBEScFJ9b17sgK6vlx0GAJFE21okD7zXl08rRRUfq6HdoEQ==} + canvaskit-wasm@0.39.1: + resolution: {integrity: sha512-Gy3lCmhUdKq+8bvDrs9t8+qf7RvcjuQn+we7vTVVyqgOVO1UVfHpsnBxkTZw+R4ApEJ3D5fKySl9TU11hmjl/A==} + ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} @@ -4743,6 +4761,8 @@ snapshots: '@vscode/l10n@0.0.18': {} + '@webgpu/types@0.1.21': {} + acorn-jsx@5.3.2(acorn@8.14.0): dependencies: acorn: 8.14.0 @@ -4864,6 +4884,13 @@ snapshots: - supports-color - typescript + astro-og-canvas@0.5.5(astro@5.1.0(@types/node@22.10.2)(jiti@2.4.2)(rollup@4.27.4)(typescript@5.7.2)(yaml@2.6.1)): + dependencies: + astro: 5.1.0(@types/node@22.10.2)(jiti@2.4.2)(rollup@4.27.4)(typescript@5.7.2)(yaml@2.6.1) + canvaskit-wasm: 0.39.1 + deterministic-object-hash: 2.0.2 + entities: 4.5.0 + astro@5.1.0(@types/node@22.10.2)(jiti@2.4.2)(rollup@4.27.4)(typescript@5.7.2)(yaml@2.6.1): dependencies: '@astrojs/compiler': 2.10.3 @@ -5039,6 +5066,10 @@ snapshots: caniuse-lite@1.0.30001684: {} + canvaskit-wasm@0.39.1: + dependencies: + '@webgpu/types': 0.1.21 + ccount@2.0.1: {} chalk@4.1.2: diff --git a/public/avatar.png b/public/avatar.png new file mode 100755 index 0000000..b5641fc Binary files /dev/null and b/public/avatar.png differ diff --git a/public/favicon.svg b/public/favicon.svg deleted file mode 100644 index f157bd1..0000000 --- a/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/public/fonts/hwmc.otf b/public/fonts/hwmc.otf new file mode 100644 index 0000000..9bdd945 Binary files /dev/null and b/public/fonts/hwmc.otf differ diff --git a/src/assets/astro.svg b/src/assets/astro.svg deleted file mode 100644 index 14ea709..0000000 --- a/src/assets/astro.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/components/astro/head/root.astro b/src/components/astro/head/root.astro deleted file mode 100644 index e045c17..0000000 --- a/src/components/astro/head/root.astro +++ /dev/null @@ -1,14 +0,0 @@ ---- -import { en, zh } from "~/config" -import { getLangFromUrl } from "~/i18n/utils" - -const lang = getLangFromUrl(Astro.url) -const config = lang === "zh" ? zh.meta : en.meta ---- - - - - - -{config.title} - {config.slogan} - diff --git a/src/components/astro/tag.astro b/src/components/astro/tag.astro index db15202..b7e8256 100644 --- a/src/components/astro/tag.astro +++ b/src/components/astro/tag.astro @@ -1,6 +1,6 @@ --- import { getLangFromUrl, useTranslations } from "~/i18n/utils" -import HomeLayout from "~/layouts/home.astro" +import MainLayout from "~/layouts/main.astro" import { formatDate } from "~/utils" interface Props { @@ -16,7 +16,7 @@ const t = useTranslations(lang) const filteredPosts = posts.filter((post: any) => post.data.tags?.includes(tag)) --- - +
{tag}
@@ -43,4 +43,4 @@ const filteredPosts = posts.filter((post: any) => post.data.tags?.includes(tag))

{t("tag.no_posts")}

) } -
+ diff --git a/src/config/index.ts b/src/config/index.ts index 5c08987..cba72ac 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -6,7 +6,7 @@ export const latestPosts = 8 const common = { meta: { - favicon: "/favicon.svg", + favicon: "/avatar.png", url: "https://blog.sunguoqi.com", }, social: [ diff --git a/src/content.config.ts b/src/content.config.ts index 2196278..b7223f4 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -7,6 +7,7 @@ const postSchema = z.object({ pubDate: z.coerce.date(), updatedDate: z.coerce.date().optional(), heroImage: z.string().optional(), + ogImage: z.string().optional(), tags: z.array(z.string()).optional(), }) diff --git a/src/content/posts/en/post-1.md b/src/content/posts/en/post-1.md index ff93c11..beb1473 100644 --- a/src/content/posts/en/post-1.md +++ b/src/content/posts/en/post-1.md @@ -2,6 +2,7 @@ title: "My First Blog Post" pubDate: 2020-07-01 description: "This is the first post of my new Astro blog." +ogImage: "https://sunguoqi.com/me.png" author: "Astro Learner" image: url: "https://docs.astro.build/assets/rose.webp" diff --git a/src/layouts/base.astro b/src/layouts/base.astro index 48650d2..d743dee 100644 --- a/src/layouts/base.astro +++ b/src/layouts/base.astro @@ -3,15 +3,51 @@ import "~/styles/globals.css" import { NoiseBackground } from "~/components/react/noise-background" import { ClientRouter } from "astro:transitions" import { getLangFromUrl } from "~/i18n/utils" -import Head from "~/components/astro/head/root.astro" +import { en, zh } from "~/config" const lang = getLangFromUrl(Astro.url) + +const { title, description, ogImage } = Astro.props + +const ogImageURL = new URL(ogImage, Astro.site).href +const permalink = new URL(Astro.url.pathname, Astro.site).href + +const config = lang === "zh" ? zh.meta : en.meta --- - + + + + + { + !title + ? `${config.title} - ${config.slogan}` + : `${config.title} - ${title}` + } + + + + + + + + + + + + + + + + + +