This commit is contained in:
Han
2025-02-12 10:09:30 +08:00
parent 8deb0fe01e
commit d116e8fcd1
912 changed files with 5761 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
---
import { getCollection } from "astro:content";
import type { GetStaticPathsOptions } from "astro";
import setSearchJson from "../utils/vhSearch";
export async function getStaticPaths(options: GetStaticPathsOptions) {
const { paginate } = options;
const posts = (await getCollection("blog")).sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
// 生成 Search JSON 文件 ======
await setSearchJson(posts);
// 生成 Search JSON 文件 ======
return paginate(posts, { pageSize: 15 });
}
const { page } = Astro.props;
const { data, ...page_data } = page;
// 页面 Info
import SITE_CONFIG from "../config";
const { Description } = SITE_CONFIG;
// 博客列表组件
import ArticleCard from "../components/ArticleCard.astro";
// 公共 Layout
import Layout from "../layouts/Layout.astro";
// Aside组件
import Aside from "../components/Aside.astro";
// 分页组件
import Pagination from "../components/Pagination.astro";
---
<Layout title="" description={Description}>
<section class="vh-container">
<section class="vh-animation article-list">
<!-- 文章列表 -->
{data.map((post, index) => <ArticleCard post={post} index={index} />)}
<!-- 分页 -->
<Pagination data={page_data.url} />
</section>
<Aside />
</section>
</Layout>
+49
View File
@@ -0,0 +1,49 @@
---
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// Aside组件
import Aside from "../../components/Aside.astro";
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// 评论组件
import Comment from "../../components/Comment.astro";
// 动态说说样式
import "../../styles/About.less";
---
<Layout title="关于" description={Description} activeNav="about">
<section class="vh-container">
<section class="vh-about">
<header class="vh-page-header">
<h1>关于我</h1>
<p>Hi there, I’m Han 👋</p>
</header>
<main>
<p>我是一名热爱前端开发并拥有丰富经验的工程师,喜欢探索新技术并应用于实际项目中。 我始终保持对新技术的热情,并将我的知识与经验分享在我的博客中。我期待在这里与你分享我的见解、经验和最新的技术动态。</p>
<h3>🌟 Languages and Tools</h3>
<div class="language-tool">
<a href="https://www.w3.org/html/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white" alt="HTML5" /></a>
<a href="https://nodejs.org" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js" /></a>
<a href="https://www.php.net/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/php-3776AB?style=for-the-badge&logo=php&logoColor=white" alt="PHP" /></a>
<a href="https://www.python.org" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white" alt="Python" /></a>
<a href="https://git-scm.com/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Git-F05032?style=for-the-badge&logo=git&logoColor=white" alt="Git" /> </a>
<a href="https://www.linux.org/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black" alt="Linux" /></a>
<a href="https://www.nginx.com" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Nginx-009639?style=for-the-badge&logo=nginx&logoColor=white" alt="Nginx" /></a>
<a href="https://www.docker.com/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white" alt="Docker" /></a>
<a href="https://vuejs.org/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Vue.js-4FC08D?style=for-the-badge&logo=vue.js&logoColor=white" alt="Vue.js" /></a>
<a href="https://vitejs.dev/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Vite-646CFF?style=for-the-badge&logo=vite&logoColor=white" alt="Vite" /></a>
<a href="https://webpack.js.org" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Webpack-8DD6F9?style=for-the-badge&logo=webpack&logoColor=black" alt="Webpack" /></a>
<a href="https://www.electronjs.org" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Electron-47848F?style=for-the-badge&logo=electron&logoColor=white" alt="Electron" /></a>
<a href="https://expressjs.com" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Express-000000?style=for-the-badge&logo=express&logoColor=white" alt="Express" /></a>
<a href="https://tailwindcss.com/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white" alt="Tailwind CSS" /></a>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black" alt="JavaScript" /></a>
<a href="https://www.sqlite.org/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/SQLite-003B57?style=for-the-badge&logo=sqlite&logoColor=white" alt="SQLite" /></a>
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener nofollow"><img data-vh-lz-src="https://img.shields.io/badge/VS_Code-007ACC?style=for-the-badge&logo=visual-studio-code&logoColor=white" alt="VS Code" /></a>
</div>
</main>
<Comment />
</section>
<Aside />
</section>
</Layout>
+21
View File
@@ -0,0 +1,21 @@
---
import { getArchiveList } from "../../utils/getArchive";
// 获取归档列表
const articleList = await getArchiveList();
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// Aside组件
import Aside from "../../components/Aside.astro";
// 文章列表组件
import Archive from "../../components/Archive.astro";
---
<Layout title="归档" description={Description} activeNav="archives">
<section class="vh-container">
<Archive articleList={articleList} />
<Aside />
</section>
</Layout>
+82
View File
@@ -0,0 +1,82 @@
---
import { getDescription, fmtTime } from "../../utils/index";
import { type CollectionEntry, getCollection } from "astro:content";
import { render } from "astro:content";
export async function getStaticPaths() {
const posts = await getCollection("blog");
return posts.map((post: any) => ({ params: { article: post.data.id }, props: post }));
}
// 处理文章内容
type Props = CollectionEntry<"blog">;
const post: any = Astro.props;
// 页面 Info
import SITE_CONFIG from "../../config";
// 处理文章内容
const description = getDescription(post);
const { Content } = await render(post);
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// Aside组件
import Aside from "../../components/Aside.astro";
// Footer 组件
import Copyright from "../../components/Copyright.astro";
// 评论组件
import Comment from "../../components/Comment.astro";
// 文章页面样式
import "../../styles/Article.less";
---
<Layout title={post.data.title} keywords={post.data.tags} description={description}>
<section class="vh-container">
<article class="vh-animation vh-article-main">
<header>
<h1>{post.data.title}</h1>
<div class="article-meta">
<span class="article-meta-item">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"> <path d="M152 24c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40L64 64C28.7 64 0 92.7 0 128l0 16 0 48L0 448c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-256 0-48 0-16c0-35.3-28.7-64-64-64l-40 0 0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40L152 64l0-40zM48 192l80 0 0 56-80 0 0-56zm0 104l80 0 0 64-80 0 0-64zm128 0l96 0 0 64-96 0 0-64zm144 0l80 0 0 64-80 0 0-64zm80-48l-80 0 0-56 80 0 0 56zm0 160l0 40c0 8.8-7.2 16-16 16l-64 0 0-56 80 0zm-128 0l0 56-96 0 0-56 96 0zm-144 0l0 56-64 0c-8.8 0-16-7.2-16-16l0-40 80 0zM272 248l-96 0 0-56 96 0 0 56z"></path></svg>
<time>{fmtTime(post.data.date, "YYYY-MM-DD")}</time>
</span>
<span class="article-meta-item">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path d="M75 75L41 41C25.9 25.9 0 36.6 0 57.9L0 168c0 13.3 10.7 24 24 24l110.1 0c21.4 0 32.1-25.9 17-41l-30.8-30.8C155 85.5 203 64 256 64c106 0 192 86 192 192s-86 192-192 192c-40.8 0-78.6-12.7-109.7-34.4c-14.5-10.1-34.4-6.6-44.6 7.9s-6.6 34.4 7.9 44.6C151.2 495 201.7 512 256 512c141.4 0 256-114.6 256-256S397.4 0 256 0C185.3 0 121.3 28.7 75 75zm181 53c-13.3 0-24 10.7-24 24l0 104c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65 0-94.1c0-13.3-10.7-24-24-24z"></path></svg>
<time>{fmtTime(post.data.updated, "YYYY-MM-DD")}</time>
</span>
<a class="article-meta-item" href={`/categories/${post.data.categories}`}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"></path></svg>
<span>{post.data.categories}</span>
</a>
</div>
</header>
<Content />
<Copyright site={SITE_CONFIG.Site} id={post.data.id} title={post.data.title} sitename={SITE_CONFIG.Title} time={fmtTime(post.data.date, "YYYY-MM-DD")} auther={SITE_CONFIG.Author} />
<Comment />
</article>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
// 初始化文章功能脚本
import ArticleInit from "../../scripts/Article";
// 初始化视频播放器
import videoInit from "../../scripts/Video";
// 初始化音乐播放器
import musicInit from "../../scripts/Music";
// 进入页面时初始化
const videoList: any[] = [];
const MusicList: any[] = [];
updateRouter("afterMount", () => {
ArticleInit();
videoInit(videoList);
musicInit(MusicList);
});
// 页面离开卸载播放器
updateRouter("beforeCreate", () => {
// 销毁播放器
videoList.forEach((i: any) => i.destroy());
videoList.length = 0;
// 销毁音乐
MusicList.forEach((i: any) => i.destroy());
MusicList.length = 0;
});
</script>
</Layout>
@@ -0,0 +1,27 @@
---
import { getCategoriesList } from "../../utils/getArchive";
import { getCollection } from "astro:content";
export async function getStaticPaths(): Promise<any> {
const posts = await getCollection("blog");
return posts.map((post: any) => ({ params: { categories: post.data.categories }, props: post }));
}
// 获取分类列表
const { categories } = Astro.params;
const articleList = await getCategoriesList(categories);
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// Aside组件
import Aside from "../../components/Aside.astro";
// 文章列表组件
import Archive from "../../components/Archive.astro";
---
<Layout title={`分类 ${categories}`} description={Description}>
<section class="vh-container">
<Archive articleList={articleList} />
<Aside />
</section>
</Layout>
+34
View File
@@ -0,0 +1,34 @@
---
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// Aside组件
import Aside from "../../components/Aside.astro";
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// 评论组件
import Comment from "../../components/Comment.astro";
// 动态说说样式
import "../../styles/Links.less";
---
<Layout title="友情链接" description={Description} activeNav="links">
<section class="vh-container">
<section class="vh-links">
<header class="vh-page-header">
<h1>朋友圈 👭</h1>
<p>天下快意之事莫若友。</p>
</header>
<main></main>
<Comment />
</section>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
import LinksInit from "../../scripts/Links";
// 进入页面时初始化
updateRouter("afterMount", LinksInit);
</script>
</Layout>
+31
View File
@@ -0,0 +1,31 @@
---
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// Aside组件
import Aside from "../../components/Aside.astro";
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// 评论组件
import Comment from "../../components/Comment.astro";
---
<Layout title="留言" description={Description} activeNav="message">
<section class="vh-container">
<section class="vh-message" style="gap:1.25rem;">
<header class="vh-page-header">
<h1>留言板 🌸</h1>
<p>快友之事莫若谈。</p>
</header>
<Comment />
</section>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
import LinksInit from "../../scripts/Links";
// 进入页面时初始化
updateRouter("afterMount", LinksInit);
</script>
</Layout>
+13
View File
@@ -0,0 +1,13 @@
import type { APIRoute } from 'astro';
const getRobotsTxt = (sitemapURL: URL) => `User-agent: *
Disallow: /MineWeb/
Disallow: /assets/
Disallow: /*?*
Sitemap: ${sitemapURL.href}`;
export const GET: APIRoute = ({ site }) => {
const sitemapURL = new URL('sitemap-index.xml', site);
return new Response(getRobotsTxt(sitemapURL));
};
+21
View File
@@ -0,0 +1,21 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { getDescription } from '../utils/index'
import SITE_CONFIG from '../config';
const { Title, Description } = SITE_CONFIG;
export async function GET(context: any) {
const posts = await getCollection('blog');
return rss({
title: Title,
description: Description,
site: context.site,
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.updated || post.data.date,
description: getDescription(post),
link: `/article/${post.data.id}`
})),
});
}
+29
View File
@@ -0,0 +1,29 @@
---
import { getTagsList } from "../../utils/getArchive";
import { getCollection } from "astro:content";
export async function getStaticPaths(): Promise<any> {
const posts = await getCollection("blog");
let tagList: any = [];
posts.forEach(post => (tagList = [...tagList, ...post.data.tags]));
return [...new Set(tagList)].map(tags => ({ params: { tags } }));
}
// 获取分类列表
const { tags } = Astro.params;
const articleList = await getTagsList(tags);
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// Aside组件
import Aside from "../../components/Aside.astro";
// 文章列表组件
import Archive from "../../components/Archive.astro";
---
<Layout title={`标签 ${tags}`} description={Description}>
<section class="vh-container">
<Archive articleList={articleList} />
<Aside />
</section>
</Layout>
+34
View File
@@ -0,0 +1,34 @@
---
// 页面 Info
import SITE_CONFIG from "../../config";
const { Description } = SITE_CONFIG;
// Aside组件
import Aside from "../../components/Aside.astro";
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// 评论组件
import Comment from "../../components/Comment.astro";
// 动态说说样式
import "../../styles/Talking.less";
---
<Layout title="动态" description={Description} activeNav="talking">
<section class="vh-container">
<section class="vh-talking">
<header class="vh-page-header">
<h1>动态 🥫</h1>
<p>记录美好生活.</p>
</header>
<main></main>
<Comment />
</section>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
import TalkingInit from "../../scripts/Talking";
// 进入页面时初始化
updateRouter("afterMount", TalkingInit);
</script>
</Layout>