feat: seo优化

This commit is contained in:
2026-07-08 22:54:08 +08:00
parent bbacb11bce
commit df4bb9212b
8 changed files with 65 additions and 49 deletions

View File

@@ -2,6 +2,7 @@
import {defineConfig} from 'astro/config';
import solidJs from '@astrojs/solid-js';
import node from '@astrojs/node';
import sitemap from "@astrojs/sitemap";
// https://astro.build/config
export default defineConfig({
@@ -10,7 +11,7 @@ export default defineConfig({
server: {
host: "0.0.0.0",
},
integrations: [solidJs()],
integrations: [solidJs(), sitemap()],
adapter: node({
mode: 'standalone'
}),

View File

@@ -11,6 +11,7 @@
},
"dependencies": {
"@astrojs/node": "11.0.2",
"@astrojs/sitemap": "^3.7.3",
"@astrojs/solid-js": "^5.1.3",
"astro": "^7.0.6",
"dayjs": "^1.11.21",

53
pnpm-lock.yaml generated
View File

@@ -11,6 +11,9 @@ importers:
'@astrojs/node':
specifier: 11.0.2
version: 11.0.2(astro@7.0.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.2)(@types/node@26.1.0)(rollup@4.62.2))
'@astrojs/sitemap':
specifier: ^3.7.3
version: 3.7.3
'@astrojs/solid-js':
specifier: ^5.1.3
version: 5.1.3(@types/node@26.1.0)(lightningcss@1.32.0)(solid-js@1.9.14)
@@ -140,6 +143,9 @@ packages:
resolution: {integrity: sha512-KTivpmnz6lDsC6o9H4+DNm2SrE/GHzw8cNAvEJwAvUT+eoaEnn/4NtbDNfRRaxaJHdp15gf+tfHAWiXR4wB3BA==}
engines: {node: '>=22.12.0'}
'@astrojs/sitemap@3.7.3':
resolution: {integrity: sha512-f8euLVsyeAmAkSm/1M2Kb8sL8byQmfgbvBNaHFItCheTj/IpiJYSEWVcqDHZ/yEHxiS7+w87mQkzwZaPHmk5GA==}
'@astrojs/solid-js@5.1.3':
resolution: {integrity: sha512-KxfYt4y1d7BuSw6EsN1EaPoGYsIES7bEI6AtTbncuabRUUMZs+mOWOeOdmgnwVLj+jbNbhBjUZsqr77eUviZdw==}
engines: {node: 18.20.8 || ^20.3.0 || >=22.0.0}
@@ -1168,9 +1174,15 @@ packages:
'@types/nlcst@2.0.3':
resolution: {integrity: sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==}
'@types/node@24.13.2':
resolution: {integrity: sha512-fRa09kZTgu8o71KFcDjUFuc7F+dEbZYZmkI0mg5YBTRs0yMKjYHsq/c0urDKeDb+D5qVgXOdFcuu+DZPKOITwA==}
'@types/node@26.1.0':
resolution: {integrity: sha512-O0A1G3xPGy4w7AgQdAQYUlQ+BKk2Oovw8eRpofyp5KdBZULnbe+WqaOVNrm705SHphCiG4XHsACrSmPu1f+Kgw==}
'@types/sax@1.2.7':
resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==}
'@types/tough-cookie@4.0.5':
resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}
@@ -1188,6 +1200,9 @@ packages:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
arg@5.0.2:
resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==}
argparse@2.0.1:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
@@ -1915,6 +1930,11 @@ packages:
sisteransi@1.0.5:
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
sitemap@9.0.1:
resolution: {integrity: sha512-S6hzjGJSG3d6if0YoF5kTyeRJvia6FSTBroE5fQ0bu1QNxyJqhhinfUsXi9fH3MgtXODWvwo2BDyQSnhPQ88uQ==}
engines: {node: '>=20.19.5', npm: '>=10.8.2'}
hasBin: true
smol-toml@1.7.0:
resolution: {integrity: sha512-aqVvWoyO21L23mb+drl4RmMXbf6N7FdHjAhTRA9ZBL7apWBgfWC16KjrASI+1p9GAroljyMHj6fK67i0UiTNvQ==}
engines: {node: '>= 18'}
@@ -1938,6 +1958,9 @@ packages:
resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
engines: {node: '>= 0.8'}
stream-replace-string@2.0.0:
resolution: {integrity: sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==}
stringify-entities@4.0.4:
resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==}
@@ -2001,6 +2024,9 @@ packages:
uncrypto@0.1.3:
resolution: {integrity: sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==}
undici-types@7.18.2:
resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}
undici-types@7.28.0:
resolution: {integrity: sha512-LJAfY+2w6HGeT8d8J1wNQsUGUEGio6NWWpwdwurQe4f6oojzCFuGLizl1KSve4irsTxyLly1QhEeE6iapdaIvQ==}
@@ -2361,6 +2387,12 @@ snapshots:
dependencies:
prismjs: 1.30.0
'@astrojs/sitemap@3.7.3':
dependencies:
sitemap: 9.0.1
stream-replace-string: 2.0.0
zod: 4.4.3
'@astrojs/solid-js@5.1.3(@types/node@26.1.0)(lightningcss@1.32.0)(solid-js@1.9.14)':
dependencies:
solid-js: 1.9.14
@@ -3123,10 +3155,18 @@ snapshots:
dependencies:
'@types/unist': 3.0.3
'@types/node@24.13.2':
dependencies:
undici-types: 7.18.2
'@types/node@26.1.0':
dependencies:
undici-types: 8.3.0
'@types/sax@1.2.7':
dependencies:
'@types/node': 26.1.0
'@types/tough-cookie@4.0.5': {}
'@types/unist@3.0.3': {}
@@ -3142,6 +3182,8 @@ snapshots:
normalize-path: 3.0.0
picomatch: 2.3.2
arg@5.0.2: {}
argparse@2.0.1: {}
aria-query@5.3.2: {}
@@ -3999,6 +4041,13 @@ snapshots:
sisteransi@1.0.5: {}
sitemap@9.0.1:
dependencies:
'@types/node': 24.13.2
'@types/sax': 1.2.7
arg: 5.0.2
sax: 1.6.0
smol-toml@1.7.0: {}
solid-js@1.9.14:
@@ -4022,6 +4071,8 @@ snapshots:
statuses@2.0.2: {}
stream-replace-string@2.0.0: {}
stringify-entities@4.0.4:
dependencies:
character-entities-html4: 2.1.0
@@ -4079,6 +4130,8 @@ snapshots:
uncrypto@0.1.3: {}
undici-types@7.18.2: {}
undici-types@7.28.0: {}
undici-types@8.3.0: {}

View File

@@ -1,46 +1 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" role="img" aria-label="placeholder favicon">
<defs>
<!-- 轻微渐变底色 -->
<linearGradient id="g" x1="0" x2="0" y1="0" y2="1">
<stop offset="0" stop-color="#f7f8fb"/>
<stop offset="1" stop-color="#e6e9f2"/>
</linearGradient>
<!-- 圆角外形的蒙版(用来制造中间空缺) -->
<mask id="holeMask">
<!-- 全白表示顯示 -->
<rect x="0" y="0" width="64" height="64" fill="white"/>
<!-- 中间用黑色(掏空) -->
<!-- 这里用一个较大的圆角方块作为"空缺" -->
<rect x="14" y="14" width="36" height="36" rx="8" ry="8" fill="black"/>
</mask>
<!-- 描边样式(虚线) -->
<pattern id="dash" width="6" height="6" patternUnits="userSpaceOnUse">
<rect width="6" height="6" fill="none"/>
</pattern>
</defs>
<!-- 圆角底板 -->
<rect x="2" y="2" width="60" height="60" rx="12" ry="12" fill="url(#g)" stroke="#d9dce8" stroke-width="1"/>
<!-- 在底板上绘制一个较暗的阴影区域,让边缘有质感 -->
<rect x="2" y="34" width="60" height="28" rx="12" ry="12" fill-opacity="0.03" fill="#000"/>
<!-- 使用mask把中间挖空透明 -->
<g mask="url(#holeMask)">
<!-- 这层是底色的延伸,挖空后中间变透明 -->
<rect x="2" y="2" width="60" height="60" rx="12" ry="12" fill="url(#g)" />
</g>
<!-- 在被挖空的边缘画一圈圆角虚线作为占位提示 -->
<rect x="14" y="14" width="36" height="36" rx="8" ry="8"
fill="none" stroke="#9aa0b6" stroke-width="1.5" stroke-dasharray="3 3" />
<!-- 中心放置一个小图形(可选): 一个微小的“文件”轮廓来提示占位 -->
<g transform="translate(28,20)">
<path d="M0 0 L8 0 L8 12 L0 12 Z" fill="none" stroke="#9aa0b6" stroke-width="1" stroke-linejoin="round"/>
<path d="M5 0 L5 3" stroke="#9aa0b6" stroke-width="1" stroke-linecap="round"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="628" height="628" viewBox="0 0 628 628"><path d="M444.443 164.59c-19.447 4.194-41.182 12.774-57.96 22.688-18.304 10.868-48.047 35.463-66.35 54.72l-13.537 14.299-18.303-20.4c-42.899-48.238-81.793-69.401-132.128-71.88C82.952 160.395 22.703 204.82 3.637 276.888-1.51 296.145-1.129 337.9 4.4 358.11c11.058 40.61 39.276 75.883 75.12 93.614 18.875 9.343 32.984 12.965 56.817 14.3 24.595 1.334 45.377-2.288 67.303-11.821 29.361-12.774 51.669-30.887 85.797-69.972 12.583-14.49 23.45-26.311 24.023-26.311.572 0 8.77 10.295 17.922 22.688 25.548 34.7 45.377 51.669 78.17 66.922 39.277 18.113 86.179 21.163 125.836 8.198 46.33-15.443 80.459-57.77 89.992-112.108 8.77-51.097-4.767-102.194-36.607-136.512-20.02-21.545-45.377-36.416-72.45-42.518-17.16-3.813-53.767-3.813-71.88 0m80.078 12.964c35.462 11.25 67.303 41.183 81.793 77.218 8.389 20.59 11.058 38.132 9.914 65.968-.763 17.922-2.097 28.408-5.148 38.132-21.735 69.019-78.552 103.147-153.481 92.47-37.941-5.53-81.412-30.124-102.766-57.96l-5.148-6.864 5.339 2.097c16.778 6.292 56.626 10.868 68.065 7.817 6.292-1.716 9.533-1.335 21.926 2.86 28.98 9.724 57.961 7.817 78.743-5.339 27.264-17.35 42.136-47.474 41.754-84.653-.19-29.552-8.198-50.715-26.12-68.828-14.109-13.918-27.264-20.02-47.093-21.163-41.373-2.67-83.7 16.587-120.497 54.72l-13.156 13.917-11.82-3.813c-13.156-4.385-31.269-15.443-31.269-19.256s38.704-41.374 55.482-54.148c26.311-19.829 56.817-33.175 85.607-37.56 20.59-3.05 50.143-1.144 67.875 4.385m-340.52.382c30.697 7.626 63.11 28.599 89.992 58.532 43.28 47.856 51.288 53.576 84.463 60.63 34.7 7.436 46.33 16.588 62.917 49.762 11.44 22.689 12.584 29.934 6.483 36.035-3.813 3.813-5.53 4.004-25.358 3.05-38.323-1.715-61.774-11.058-77.598-30.696-4.958-5.91-12.965-13.536-17.923-16.587-12.774-8.008-27.836-23.833-46.711-48.428-8.961-11.63-22.88-27.645-31.078-35.653-44.424-43.852-104.481-47.284-143.185-8.39-38.132 38.324-39.848 98.763-3.814 136.513 12.775 13.347 25.167 20.21 43.09 24.024 32.221 6.863 61.773-4.386 93.614-35.273 11.44-11.058 43.28-46.14 48.427-53.384.382-.572 4.385 2.86 8.77 7.626 6.292 6.673 21.545 19.829 27.837 24.023 1.335.954-44.043 52.05-54.72 61.774-33.937 30.315-66.73 44.043-106.197 44.233-34.7.19-63.49-11.058-88.657-34.319-64.062-59.295-57.96-171.022 12.202-220.593 35.463-25.167 75.692-32.984 117.447-22.88m-10.486 54.528c12.012 3.05 31.84 14.11 43.471 24.595 5.91 5.339 18.303 19.066 27.264 30.506 14.3 18.303 16.016 21.354 13.919 24.214-10.296 13.346-37.18 42.898-50.525 55.482-11.25 10.677-20.401 17.35-30.697 22.498-14.108 7.054-15.252 7.245-34.7 7.245-18.303 0-21.163-.572-31.077-5.339-27.455-13.536-43.852-41.754-43.661-75.31 0-19.448 5.529-36.798 16.396-51.67 21.354-28.98 54.338-40.991 89.61-32.22m341.663 3.432c46.521 22.88 54.529 100.287 14.49 139.754-19.828 19.638-45.377 24.404-78.742 14.68-10.868-3.05-11.821-4.384-9.533-10.485 2.86-7.436.953-13.919-10.105-36.989-12.965-26.31-24.214-38.513-43.852-47.855l-14.871-7.055 14.49-13.727c28.217-26.693 51.669-38.513 88.657-44.805 11.249-1.907 27.836.762 39.466 6.482"/><path d="M378.856 344.572c-3.432 1.526-4.004 2.86-3.05 7.055 2.478 10.486 6.1 14.109 13.537 13.537 3.813-.382 7.626-1.907 8.77-3.623 3.05-4.766 0-12.774-6.292-16.015s-6.864-3.241-12.965-.954"/></svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

2
public/robots.txt Normal file
View File

@@ -0,0 +1,2 @@
User-agent: *
Allow: /

BIN
src/assets/icon/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -6,6 +6,9 @@ import BaseFooter from "@/components/BaseFooter.astro";
import { metadata } from "@/consts.ts";
const { siteTitle } = metadata;
const {title,description} = Astro.props;
const pageTitle = title ? `${title} - ${siteTitle}` : siteTitle;
---
<!doctype html>
@@ -18,7 +21,8 @@ const { siteTitle } = metadata;
/>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>{siteTitle}</title>
<title>{pageTitle}</title>
<meta name="description" content={description}>
</head>
<body>
<BaseHeader />

View File

@@ -25,7 +25,7 @@ const content = await highlightHtmlWithJsdom(data.content)
data.published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日')
---
<Layout>
<Layout title={data.title} description={data.summary}>
<h1 class="post-title">{data.title}</h1>
<div class="published-at">