自定义分类页

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
title: 分类
date: 2023-07-04 19:16:57
type: "category" # anzhiyu渲染模板是`categories`
top_img: false
---

<style>
#libCategories .card-wrap:hover .card-info:after {
width: 300%;
}
html.windows div#libCategories div.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;
}
html.windows div#libCategories div.container .card {
width: 100%;
height: auto;
aspect-ratio: 1 / 1;
}
html.windows div#libCategories div.container .card .card-info h1 {
font-size: 30px;
}
</style>
<link
rel="stylesheet"
type="text/css"
href="https://npm.elemecdn.com/js-heo@1.0.11/3dCard/no3d.css"
/>

<div id="libCategories">
<div
id="lib-cards"
class="container"
></div>
</div>

<script type="text/javascript">
(function () {
// 配置分类数据
const categoryList = [
{
url: "/categories/programming-language/", // 分类的url
title: "编程语言", // 分类的名字
content: "一些常用的编程语言", // 分类的描述
img: "https://bu.dusays.com/2023/09/04/64f5decb81c5e.jpg" // 分类的图片
},
{
url: "/categories/literature/",
title: "文学作品",
content: "经典文学作品的赏析",
img: "https://bu.dusays.com/2023/09/04/64f5decb35784.jpg"
}
];
const categoryListDom = document.querySelector("#libCategories #lib-cards");
categoryListDom.innerHTML = categoryList
.map(
item =>
`<a href='javascript:void(0);' onClick='pjax.loadUrl("${item.url}")'>
<card data-image=${item.img}>
<h1 slot="header">${item.title}</h1>
<p slot="content">${item.content}</p>
</card>
</a>`
)
.join("");
})();
</script>

<script
src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"
data-pjax
></script>
<script
type="text/javascript"
src="https://npm.elemecdn.com/anzhiyu-theme-static@1.0.7/no3d/no3d.js"
data-pjax
></script>