fix archive page

This commit is contained in:
lyq 2024-05-16 23:19:25 +08:00
parent ba98790a83
commit 92b728f6d0
23 changed files with 217 additions and 224 deletions

View file

@ -5,100 +5,101 @@ import { SITE_URL } from "./src/consts"
import vue from "@astrojs/vue" import vue from "@astrojs/vue"
import tailwind from "@astrojs/tailwind" import tailwind from "@astrojs/tailwind"
import react from "@astrojs/react" import react from "@astrojs/react"
function pipeline() { function pipeline() {
return [ return [
() => (tree) => { // () => (tree) => {
visit(tree, "element", (node, index) => { // visit(tree, "element", (node, index) => {
if (node.tagName === "p" && node.children[0].tagName === "img") { // if (node.tagName === "p" && node.children[0].tagName === "img") {
node.tagName = "figure" // node.tagName = "figure"
let img = node.children[0] // let img = node.children[0]
let sign = md5(img.properties.src) // let sign = md5(img.properties.src)
let data = img.properties.alt.split("|") // let data = img.properties.alt.split("|")
let alt = data[0] // let alt = data[0]
let size = "big" // let size = "big"
if (data.length > 1) { // if (data.length > 1) {
size = data[1] // size = data[1]
} // }
let classes = [ // let classes = [
"image component image-fullbleed body-copy-wide nr-scroll-animation nr-scroll-animation--on", // "image component image-fullbleed body-copy-wide nr-scroll-animation nr-scroll-animation--on",
] // ]
classes.push(`image-${size}`) // classes.push(`image-${size}`)
node.properties.className = classes // node.properties.className = classes
node.children = [ // node.children = [
{ // {
type: "element", // type: "element",
tagName: "div", // tagName: "div",
properties: { // properties: {
className: ["component-content"], // className: ["component-content"],
}, // },
children: [ // children: [
{ // {
type: "element", // type: "element",
tagName: "div", // tagName: "div",
properties: { // properties: {
className: ["image-sharesheet"], // className: ["image-sharesheet"],
}, // },
children: [ // children: [
{ // {
type: "element", // type: "element",
tagName: "div", // tagName: "div",
properties: { // properties: {
className: [ // className: [
`image image-load image-asset image-${sign}`, // `image image-load image-asset image-${sign}`,
], // ],
id: `lht${sign}`, // id: `lht${sign}`,
}, // },
children: [ // children: [
{ // {
type: "element", // type: "element",
tagName: "picture", // tagName: "picture",
properties: { // properties: {
className: ["picture"], // className: ["picture"],
}, // },
children: [ // children: [
{ // {
type: "element", // type: "element",
tagName: "img", // tagName: "img",
properties: { // properties: {
"data-src": img.properties.src, // "data-src": img.properties.src,
alt: alt, // alt: alt,
className: ["picture-image"], // className: ["picture-image"],
}, // },
}, // },
], // ],
}, // },
], // ],
}, // },
], // ],
}, // },
{ // {
type: "element", // type: "element",
tagName: "div", // tagName: "div",
properties: { // properties: {
className: ["image-description"], // className: ["image-description"],
}, // },
children: [ // children: [
{ // {
type: "element", // type: "element",
tagName: "div", // tagName: "div",
properties: { // properties: {
className: ["image-caption"], // className: ["image-caption"],
}, // },
children: [ // children: [
{ // {
type: "text", // type: "text",
value: alt, // value: alt,
}, // },
], // ],
}, // },
], // ],
}, // },
], // ],
}, // },
] // ]
} // }
}) // })
}, // },
() => (tree) => { () => (tree) => {
tree.children.forEach((node) => { tree.children.forEach((node) => {
if (node.type === "raw") { if (node.type === "raw") {

View file

@ -1837,14 +1837,13 @@ packages:
dev: false dev: false
optional: true optional: true
/bare-fs@2.2.2: /bare-fs@2.3.0:
resolution: {integrity: sha512-X9IqgvyB0/VA5OZJyb5ZstoN62AzD7YxVGog13kkfYWYqJYcK0kcqLZ6TrmH5qr4/8//ejVcX4x/a0UvaogXmA==} resolution: {integrity: sha512-TNFqa1B4N99pds2a5NYHR15o0ZpdNKbAeKTE/+G6ED/UeOavv8RY3dr/Fu99HW3zU3pXpo2kDNO8Sjsm2esfOw==}
requiresBuild: true requiresBuild: true
dependencies: dependencies:
bare-events: 2.2.2 bare-events: 2.2.2
bare-os: 2.2.1 bare-path: 2.1.2
bare-path: 2.1.0 bare-stream: 1.0.0
streamx: 2.16.1
dev: false dev: false
optional: true optional: true
@ -1854,14 +1853,22 @@ packages:
dev: false dev: false
optional: true optional: true
/bare-path@2.1.0: /bare-path@2.1.2:
resolution: {integrity: sha512-DIIg7ts8bdRKwJRJrUMy/PICEaQZaPGZ26lsSx9MJSwIhSrcdHn7/C8W+XmnG/rKi6BaRcz+JO00CjZteybDtw==} resolution: {integrity: sha512-o7KSt4prEphWUHa3QUwCxUI00R86VdjiuxmJK0iNVDHYPGo+HsDaVCnqCmPbf/MiW1ok8F4p3m8RTHlWk8K2ig==}
requiresBuild: true requiresBuild: true
dependencies: dependencies:
bare-os: 2.2.1 bare-os: 2.2.1
dev: false dev: false
optional: true optional: true
/bare-stream@1.0.0:
resolution: {integrity: sha512-KhNUoDL40iP4gFaLSsoGE479t0jHijfYdIcxRn/XtezA2BaUD0NRf/JGRpsMq6dMNM+SrCrB0YSSo/5wBY4rOQ==}
requiresBuild: true
dependencies:
streamx: 2.16.1
dev: false
optional: true
/base-64@1.0.0: /base-64@1.0.0:
resolution: {integrity: sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==} resolution: {integrity: sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==}
dev: false dev: false
@ -4364,8 +4371,8 @@ packages:
pump: 3.0.0 pump: 3.0.0
tar-stream: 3.1.7 tar-stream: 3.1.7
optionalDependencies: optionalDependencies:
bare-fs: 2.2.2 bare-fs: 2.3.0
bare-path: 2.1.0 bare-path: 2.1.2
dev: false dev: false
optional: true optional: true

View file

@ -1,30 +1,49 @@
--- ---
import BaseHead from "../components/BaseHead.astro"; import BaseHead from "../components/BaseHead.astro"
import Header from "../components/Header.astro"; import Header from "../components/Header.astro"
import Footer from "../components/Footer.astro"; import Footer from "../components/Footer.astro"
import { formatDate } from "../utils"; import { formatDate } from "../utils"
import { SITE_TITLE } from "../consts"; import { SITE_TITLE } from "../consts"
const { frontmatter } = Astro.props; const { frontmatter } = Astro.props
const type = frontmatter.tags[0]; const type = frontmatter.tags?.[0] ?? "默认"
const { pubDate, title, description, featured } = frontmatter; const { pubDate, title, description, featured } = frontmatter
const dateFormated = formatDate(pubDate); const dateFormated = formatDate(pubDate)
--- ---
<html lang="zh-CN" dir="ltr" class="js no-touch progressive-image no-reduced-motion progressive"> <html
lang="zh-CN"
dir="ltr"
class="js no-touch progressive-image no-reduced-motion progressive"
>
<head> <head>
<BaseHead title={`${title} - ${SITE_TITLE}`} description={description} image={frontmatter.cover.square} /> <BaseHead
title={`${title} - ${SITE_TITLE}`}
description={description}
image={frontmatter.cover?.square}
/>
</head> </head>
<body class:list={["page-article", { "theme-dark": frontmatter.theme === "dark" }]}> <body
class:list={[
"page-article",
{ "theme-dark": frontmatter.theme === "dark" },
]}
>
<Header /> <Header />
<main id="main" class="main"> <main id="main" class="main">
<section> <section>
<article class="article"> <article class="article">
<div class:list={[{ "featured-header": featured, "article-header": !featured }]}> <div
class:list={[
{ "featured-header": featured, "article-header": !featured },
]}
>
<div class="category component"> <div class="category component">
<div class="component-content"> <div class="component-content">
<div class="category-eyebrow"> <div class="category-eyebrow">
<span class="category-eyebrow__category category_original">{type}</span> <span class="category-eyebrow__category category_original"
>{type}</span
>
<span class="category-eyebrow__date">{dateFormated}</span> <span class="category-eyebrow__date">{dateFormated}</span>
</div> </div>
</div> </div>
@ -34,19 +53,24 @@ const dateFormated = formatDate(pubDate);
<h1 class="hero-headline">{title}</h1> <h1 class="hero-headline">{title}</h1>
</div> </div>
</div> </div>
<div class:list={[{ "featured-subhead": featured, "article-subhead": !featured }, "component"]}> <div
class:list={[
{ "featured-subhead": featured, "article-subhead": !featured },
"component",
]}
>
<div class="component-content">{description}</div> <div class="component-content">{description}</div>
</div> </div>
<div class:list={["tagssheet component"]}> <div class:list={["tagssheet component"]}>
<div class="component-content"> <div class="component-content">
{ {
frontmatter.tags.map((tag) => { frontmatter.tags?.map((tag) => {
return ( return (
<a href={`/tags/${tag}`} class="tag"> <a href={`/tags/${tag}`} class="tag">
{tag} {tag}
</a> </a>
); )
}) })
} }
</div> </div>
@ -56,10 +80,15 @@ const dateFormated = formatDate(pubDate);
<div class="component"> <div class="component">
<div class="component-content"> <div class="component-content">
<div class="article-copyright"> <div class="article-copyright">
<a class="content" href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.zh" target="_blank" <a
class="content"
href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.zh"
target="_blank"
>版权声明:自由转载-非商用-非衍生-保持署名创意共享3.0许可证)</a >版权声明:自由转载-非商用-非衍生-保持署名创意共享3.0许可证)</a
> >
<p class="content">作者: {frontmatter.author} 发表日期:{dateFormated}</p> <p class="content">
作者: {frontmatter.author} 发表日期:{dateFormated}
</p>
</div> </div>
</div> </div>
</div> </div>
@ -68,9 +97,9 @@ const dateFormated = formatDate(pubDate);
</main> </main>
<Footer /> <Footer />
<script is:inline> <script is:inline>
var script = document.createElement("script"); var script = document.createElement("script")
script.src = "/static/js/initPost.js"; script.src = "/static/js/initPost.js"
document.head.appendChild(script); document.head.appendChild(script)
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,10 +1,13 @@
--- ---
import { formatDate } from "../utils"; import { formatDate } from "../utils"
const { title, href, cover, tags, date } = Astro.props; const { title, href, cover, tags, date } = Astro.props
const dateFormated = formatDate(date); const dateFormated = formatDate(date)
const type = tags[0]; const type = tags?.[0] ?? "默认"
const label = `${title} - ${type} - 发表时间 ${dateFormated}`;
const image = cover ? cover : "https://oss.nbtca.space/CA-logo.svg"
const label = `${title} - ${type} - 发表时间 ${dateFormated}`
--- ---
<li <li
@ -18,14 +21,16 @@ const label = `${title} - ${type} - 发表时间 ${dateFormated}`;
aria-label={label} aria-label={label}
> >
<div class="tile__media" aria-hidden="true"> <div class="tile__media" aria-hidden="true">
<img class="cover image" data-src={cover} alt="lt"/> <img class="cover image" data-src={image} alt="lt" />
</div> </div>
<div class="tile__description" aria-hidden="true"> <div class="tile__description" aria-hidden="true">
<div class="tile__head"> <div class="tile__head">
<div class="tile__category">{type}</div> <div class="tile__category">{type}</div>
<div class="tile__headline">{title}</div> <div class="tile__headline">{title}</div>
</div> </div>
<div class="tile__timestamp icon-hide icon icon-before icon-clock">{dateFormated}</div> <div class="tile__timestamp icon-hide icon icon-before icon-clock">
{dateFormated}
</div>
</div> </div>
</a> </a>
</li> </li>

View file

@ -1,14 +1,20 @@
--- ---
import BaseLayout from "../layouts/BaseLayout.astro"; import BaseLayout from "../layouts/BaseLayout.astro"
import ArchivePostList from "../layouts/ArchivePostList.astro"; import ArchivePostList from "../layouts/ArchivePostList.astro"
const allPosts = await Astro.glob("./posts/*.md"); const allPosts = await Astro.glob("./posts/*.md")
const tags = ["寝室"]; const Blogs = await Astro.glob("../pages/posts/blogs/**/*.md")
const posts = []; const tags = ["寝室", "技术", "学习", "其他"]
const posts = []
tags.forEach((tag) => { tags.forEach((tag) => {
let filteredPosts = allPosts.filter((post) => post.frontmatter.tags.includes(tag)); let filteredPosts = allPosts.filter((post) =>
posts.push(filteredPosts); post.frontmatter.tags.includes(tag)
}); )
let filteredBlogs = Blogs.filter(
(post) => post.frontmatter.tags?.includes(tag) ?? tag === "其他"
)
posts.push([...filteredPosts, ...filteredBlogs])
})
--- ---
<BaseLayout primaryTitle="归档"> <BaseLayout primaryTitle="归档">
@ -19,9 +25,15 @@ tags.forEach((tag) => {
return ( return (
<div class="archive-tag"> <div class="archive-tag">
<h2 class="tag-header">{tag}</h2> <h2 class="tag-header">{tag}</h2>
<div class="tag-post-list">{posts[index].length !== 0 ? <ArchivePostList posts={posts[index]} /> : <div class="no-posts">暂无文章</div>}</div> <div class="tag-post-list">
{posts[index].length !== 0 ? (
<ArchivePostList posts={posts[index]} />
) : (
<div class="no-posts">暂无文章</div>
)}
</div>
</div> </div>
); )
}) })
} }
</div> </div>

View file

@ -86,7 +86,7 @@ allPosts.sort(
}) })
} }
{ {
Blogs.slice(2, 6).map((post) => { Blogs.slice(1, 7).map((post) => {
return ( return (
<MoreTile <MoreTile
title={post.frontmatter.title} title={post.frontmatter.title}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View file

@ -1,35 +0,0 @@
---
layout: "../../../../layouts/MarkdownPost.astro"
title: 关于
pubDate: 2023-12-12 14:27:01
permalink: /about/
sidebar: false
article: false
author:
name: nbtca
link: https://github.com/nbtca
---
## 📚Blog
这是一个兼具博客文章、知识管理、文档查找的计算机协会网站。欢迎到[GitHub](https://github.com/xugaoyi/vuepress-theme-vdoing)点个 Star( •̀ ω •́ )✧
:::tip
文章内容仅是计协的一些小技术,如有误还请指正。
:::
[更新日志](https://github.com/nbtca/blogs/commits/main)
## 🎨Theme
本站主题是 [`Vdoing`](https://github.com/xugaoyi/vuepress-theme-vdoing),这是一款简洁高效的 VuePress 知识管理&博客 主题。旨在轻松打造一个`结构化`与`碎片化`并存的个人在线知识库&博客,让你的知识海洋像一本本书一样清晰易读。配合多维索引,让每一个知识点都可以快速定位! [Github 地址](https://github.com/xugaoyi/vuepress-theme-vdoing)
## 🐼Our
计算机协会成员
### 技能
- 熟悉 JavaScript、HTML、CSS、Vue、React 的拼写
- 了解 Linux、windows、macOS 的开关机方式
- 精通 Git 的 pull 和 push并注册了 GitHub 帐号刷了一些 star

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- C语言
--- ---
# 从汇编角度看 C 语言 - 1 # 从汇编角度看 C 语言 - 1

View file

@ -13,7 +13,8 @@ author:
name: chundot name: chundot
link: https://chundot.github.io link: https://chundot.github.io
tags: tags:
- - 技术
- C语言
--- ---
# 写 C 语言的种种工具 # 写 C 语言的种种工具

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- Go语言
--- ---
## Go 语言极限入门 ## Go 语言极限入门

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- Linux
--- ---
## **Linux 信号** ## **Linux 信号**

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- Linux
--- ---
## Linux 文件系统结构 ## Linux 文件系统结构

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- Linux
--- ---
## Linux 进程 ## Linux 进程

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- Python
--- ---
## Python 爬虫实战 - 爬取 TIOBE TOP20 语言排行榜 ## Python 爬虫实战 - 爬取 TIOBE TOP20 语言排行榜

View file

@ -13,7 +13,8 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 技术
- Python
--- ---
## Python 爬虫实战-获取王者荣耀英雄大全 ## Python 爬虫实战-获取王者荣耀英雄大全

View file

@ -1,5 +1,5 @@
--- ---
layout: "../../../../layouts/MarkdownPost.astro" layout: "../../../../../layouts/MarkdownPost.astro"
title: 友情链接 title: 友情链接
pubDate: 2019-12-25 14:27:01 pubDate: 2019-12-25 14:27:01
permalink: /friends permalink: /friends
@ -8,6 +8,8 @@ sidebar: false
author: author:
name: nbtca name: nbtca
link: https://github.com/nbtca link: https://github.com/nbtca
tags:
- 其他
--- ---
<!-- <!--

View file

@ -13,7 +13,7 @@ author:
name: chundot name: chundot
link: https://chundot.github.io link: https://chundot.github.io
tags: tags:
- - 学习
--- ---
# Visual Studio Code 入门指北 # Visual Studio Code 入门指北

View file

@ -13,7 +13,7 @@ author:
name: jollari name: jollari
link: https://github.com/Jolanyu link: https://github.com/Jolanyu
tags: tags:
- - 学习
--- ---
# 寝室软路由记录 # 寝室软路由记录

View file

@ -13,7 +13,7 @@ author:
name: N3ptune name: N3ptune
link: https://www.cnblogs.com/N3ptune link: https://www.cnblogs.com/N3ptune
tags: tags:
- - 学习
--- ---
# 逆向工程实战 # 逆向工程实战

View file

@ -1,18 +0,0 @@
---
pageComponent:
name: Catalogue
data:
path: 01.技术
imgUrl: /img/technology.png
description: 技术文档、教程、技巧、总结等文章
title: 技术
date: 2023-11-27
permalink: /technology/
sidebar: false
article: false
comment: false
editLink: false
author:
name: nbtca
link: https://github.com/nbtca
---

View file

@ -1,18 +0,0 @@
---
pageComponent:
name: Catalogue
data:
path: 02.更多
imgUrl: /img/more_1.png
description: 学习、面试、在线工具等更多文章和页面
title: 更多
date: 2023-11-27
permalink: /more/
sidebar: false
article: false
comment: false
editLink: false
author:
name: nbtca
link: https://github.com/nbtca
---