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

View file

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

View file

@ -1,30 +1,49 @@
---
import BaseHead from "../components/BaseHead.astro";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import BaseHead from "../components/BaseHead.astro"
import Header from "../components/Header.astro"
import Footer from "../components/Footer.astro"
import { formatDate } from "../utils";
import { SITE_TITLE } from "../consts";
const { frontmatter } = Astro.props;
const type = frontmatter.tags[0];
const { pubDate, title, description, featured } = frontmatter;
const dateFormated = formatDate(pubDate);
import { formatDate } from "../utils"
import { SITE_TITLE } from "../consts"
const { frontmatter } = Astro.props
const type = frontmatter.tags?.[0] ?? "默认"
const { pubDate, title, description, featured } = frontmatter
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>
<BaseHead title={`${title} - ${SITE_TITLE}`} description={description} image={frontmatter.cover.square} />
<BaseHead
title={`${title} - ${SITE_TITLE}`}
description={description}
image={frontmatter.cover?.square}
/>
</head>
<body class:list={["page-article", { "theme-dark": frontmatter.theme === "dark" }]}>
<body
class:list={[
"page-article",
{ "theme-dark": frontmatter.theme === "dark" },
]}
>
<Header />
<main id="main" class="main">
<section>
<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="component-content">
<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>
</div>
</div>
@ -34,19 +53,24 @@ const dateFormated = formatDate(pubDate);
<h1 class="hero-headline">{title}</h1>
</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>
<div class:list={["tagssheet component"]}>
<div class="component-content">
{
frontmatter.tags.map((tag) => {
frontmatter.tags?.map((tag) => {
return (
<a href={`/tags/${tag}`} class="tag">
{tag}
</a>
);
)
})
}
</div>
@ -56,10 +80,15 @@ const dateFormated = formatDate(pubDate);
<div class="component">
<div class="component-content">
<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
>
<p class="content">作者: {frontmatter.author} 发表日期:{dateFormated}</p>
<p class="content">
作者: {frontmatter.author} 发表日期:{dateFormated}
</p>
</div>
</div>
</div>
@ -68,9 +97,9 @@ const dateFormated = formatDate(pubDate);
</main>
<Footer />
<script is:inline>
var script = document.createElement("script");
script.src = "/static/js/initPost.js";
document.head.appendChild(script);
var script = document.createElement("script")
script.src = "/static/js/initPost.js"
document.head.appendChild(script)
</script>
</body>
</html>

View file

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

View file

@ -1,14 +1,20 @@
---
import BaseLayout from "../layouts/BaseLayout.astro";
import ArchivePostList from "../layouts/ArchivePostList.astro";
const allPosts = await Astro.glob("./posts/*.md");
const tags = ["寝室"];
const posts = [];
import BaseLayout from "../layouts/BaseLayout.astro"
import ArchivePostList from "../layouts/ArchivePostList.astro"
const allPosts = await Astro.glob("./posts/*.md")
const Blogs = await Astro.glob("../pages/posts/blogs/**/*.md")
const tags = ["寝室", "技术", "学习", "其他"]
const posts = []
tags.forEach((tag) => {
let filteredPosts = allPosts.filter((post) => post.frontmatter.tags.includes(tag));
posts.push(filteredPosts);
});
let filteredPosts = allPosts.filter((post) =>
post.frontmatter.tags.includes(tag)
)
let filteredBlogs = Blogs.filter(
(post) => post.frontmatter.tags?.includes(tag) ?? tag === "其他"
)
posts.push([...filteredPosts, ...filteredBlogs])
})
---
<BaseLayout primaryTitle="归档">
@ -19,9 +25,15 @@ tags.forEach((tag) => {
return (
<div class="archive-tag">
<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>

View file

@ -86,7 +86,7 @@ allPosts.sort(
})
}
{
Blogs.slice(2, 6).map((post) => {
Blogs.slice(1, 7).map((post) => {
return (
<MoreTile
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
link: https://www.cnblogs.com/N3ptune
tags:
-
- 技术
- C语言
---
# 从汇编角度看 C 语言 - 1

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@ author:
name: N3ptune
link: https://www.cnblogs.com/N3ptune
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
---