正式版1.0✅

This commit is contained in:
Han
2025-03-02 18:38:46 +08:00
parent 60f5296dcb
commit e7117f0903
52 changed files with 794 additions and 513 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import "../styles/Article.less";
<Layout title="404 Not Found" keywords={[404]} description="404 Not Found">
<section class="vh-container">
<article class="vh-animation vh-article-main">
<article class="vh-article-main vh-animation vh-animation-init">
<header>
<h1 class="error-title">404 Not Found</h1>
</header>
+7 -3
View File
@@ -8,7 +8,11 @@ export async function getStaticPaths(options: GetStaticPathsOptions) {
// 生成 Search JSON 文件 ======
await setSearchJson(posts);
// 生成 Search JSON 文件 ======
return paginate(posts, { pageSize: 15 });
// 隐藏的文章不显示
return paginate(
posts.filter(i => !i.data.hide),
{ pageSize: 15 }
);
}
const { page } = Astro.props;
@@ -27,9 +31,9 @@ import Pagination from "../components/Pagination.astro";
const currentPage = page_data.url.current.replace("/", "");
---
<Layout title={currentPage ? `第${currentPage}页` : ""} description={Description}>
<Layout title={currentPage ? `第${currentPage}页文章` : ""} description={Description}>
<section class="vh-container">
<section class="vh-animation article-list">
<section class="article-list vh-animation vh-animation-init">
<!-- 文章列表 -->
{data.map((post, index) => <ArticleCard post={post} index={index} />)}
<!-- 分页 -->
+2 -2
View File
@@ -14,9 +14,9 @@ import Comment from "../../components/Comment.astro";
import "../../styles/About.less";
---
<Layout title="关于" description={Description} activeNav="about">
<Layout title="关于" description={Description}>
<section class="vh-container">
<section class="vh-about">
<section class="vh-about vh-animation vh-animation-init">
<header class="vh-page-header">
<h1>关于我</h1>
<p>Hi there, I’m Han 👋</p>
+1 -1
View File
@@ -13,7 +13,7 @@ import Aside from "../../components/Aside.astro";
import Archive from "../../components/Archive.astro";
---
<Layout title="归档" description={Description} activeNav="archives">
<Layout title="归档" description={Description}>
<section class="vh-container">
<Archive articleList={articleList} />
<Aside />
+12 -31
View File
@@ -14,10 +14,12 @@ import getCover from "../../utils/getCover";
const ARTICLE_COVER: string = await getCover(post.data.cover);
// 页面 Info
import SITE_CONFIG from "../../config";
const { Site, Title, Author, Twikoo } = SITE_CONFIG;
const { Site, Title, Author, Twikoo, GoogleAds } = SITE_CONFIG;
// 处理文章内容
const description = getDescription(post);
const { Content } = await render(post);
const { Content, remarkPluginFrontmatter } = await render(post);
// 文章字数和阅读时间
const { reading_time, article_word_count } = remarkPluginFrontmatter;
// 公共 Layout
import Layout from "../../layouts/Layout.astro";
// Aside组件
@@ -26,19 +28,23 @@ import Aside from "../../components/Aside.astro";
import Copyright from "../../components/Copyright.astro";
// 评论组件
import Comment from "../../components/Comment.astro";
// Google 广告组件
import GoogleAd from "../../components/GoogleAd.astro";
// 文章页面样式
import "../../styles/Article.less";
---
<Layout title={post.data.title} keywords={post.data.tags} description={description} pagecover={ARTICLE_COVER}>
<section class="vh-container">
<article class="vh-animation vh-article-main">
<article class="vh-article-main vh-animation vh-animation-init">
<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 A")}</time>
<span class="count"><strong>{article_word_count}</strong>字</span>
<span class="time"><strong>{parseFloat((Number(reading_time) || 0).toFixed(1).replace(/\.0+$/, ""))}</strong>分钟</span>
</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>
@@ -49,41 +55,16 @@ import "../../styles/Article.less";
<main>
<Content />
<nav class="tag-list">
{post.data.tags.map((i: any) => <a href={`/tags/${i}`}>{i}</a>)}
{post.data.tags.map((i: any) => <a href={`/tag/${i}`}>{i}</a>)}
</nav>
</main>
<footer>
<!-- 底部谷歌广告 -->
{GoogleAds.ad_Client && GoogleAds.articleAD_Slot && <GoogleAd className="vh-article-ad" slotID={GoogleAds.articleAD_Slot} />}
<Copyright site={Site} id={post.data.id} title={post.data.title} sitename={Title} time={fmtTime(post.data.date, "YYYY-MM-DD A")} auther={Author} />
</footer>
{Twikoo.envId && <Comment envId={Twikoo.envId} />}
</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>
+1 -1
View File
@@ -19,7 +19,7 @@ import Aside from "../../components/Aside.astro";
import Archive from "../../components/Archive.astro";
---
<Layout title={`分类 ${categories}`} description={Description}>
<Layout title={`分类 ${categories} 下的文章`} description={Description}>
<section class="vh-container">
<Archive articleList={articleList} />
<Aside />
+3 -13
View File
@@ -12,26 +12,16 @@ import Comment from "../../components/Comment.astro";
import "../../styles/Links.less";
---
<Layout title="友情链接" description={Description} activeNav="links">
<Layout title="友情链接" description={Description}>
<section class="vh-container">
<section class="vh-links">
<section class="vh-links vh-animation vh-animation-init">
<header class="vh-page-header">
<h1>朋友圈 👭</h1>
<p>天下快意之事莫若友。</p>
</header>
<main></main>
<main><section class="vh-space-loading"><span></span><span></span><span></span></section></main>
{Twikoo.envId && <Comment envId={Twikoo.envId} />}
</section>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
import LinksInit from "../../scripts/Links";
// 进入页面时初始化
// 数据源
import LINKS_DATA from "../../page_data/Link";
const { api, data } = LINKS_DATA;
updateRouter("afterMount", () => LinksInit(api || data));
</script>
</Layout>
+2 -9
View File
@@ -10,9 +10,9 @@ import Layout from "../../layouts/Layout.astro";
import Comment from "../../components/Comment.astro";
---
<Layout title="留言" description={Description} activeNav="message">
<Layout title="留言" description={Description}>
<section class="vh-container">
<section class="vh-message" style="gap:1.25rem;">
<section class="vh-message vh-animation vh-animation-init" style="gap:1.25rem;">
<header class="vh-page-header">
<h1>留言板 🌸</h1>
<p>快友之事莫若谈。</p>
@@ -21,11 +21,4 @@ import Comment from "../../components/Comment.astro";
</section>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
import LinksInit from "../../scripts/Links";
// 进入页面时初始化
updateRouter("afterMount", LinksInit);
</script>
</Layout>
+1 -1
View File
@@ -11,7 +11,7 @@ export async function GET(context: any) {
title: Title,
description: Description,
site: context.site,
items: posts.map((post) => ({
items: posts.filter(i => !i.data.hide).map((post) => ({
title: post.data.title,
pubDate: post.data.updated || post.data.date,
description: getDescription(post),
@@ -21,7 +21,7 @@ import Aside from "../../components/Aside.astro";
import Archive from "../../components/Archive.astro";
---
<Layout title={`标签 ${tags}`} description={Description}>
<Layout title={`标签 ${tags} 下的文章`} description={Description}>
<section class="vh-container">
<Archive articleList={articleList} />
<Aside />
+3 -13
View File
@@ -12,26 +12,16 @@ import Comment from "../../components/Comment.astro";
import "../../styles/Talking.less";
---
<Layout title="动态" description={Description} activeNav="talking">
<Layout title="动态" description={Description}>
<section class="vh-container">
<section class="vh-talking">
<section class="vh-talking vh-animation vh-animation-init">
<header class="vh-page-header">
<h1>动态 🥫</h1>
<p>记录美好生活.</p>
</header>
<main></main>
<main><section class="vh-space-loading white"><span></span><span></span><span></span></section></main>
{Twikoo.envId && <Comment envId={Twikoo.envId} />}
</section>
<Aside />
</section>
<script>
import updateRouter from "../../utils/updateRouter";
import TalkingInit from "../../scripts/Talking";
// 进入页面时初始化
// 数据源
import TALKING_DATA from "../../page_data/Talking";
const { api, data } = TALKING_DATA;
updateRouter("afterMount", () => TalkingInit(api || data));
</script>
</Layout>