Skip to content

Commit 7c4b5d6

Browse files
committed
chore: delete useless code
1 parent 311b5a7 commit 7c4b5d6

File tree

10 files changed

+83
-154
lines changed

10 files changed

+83
-154
lines changed

index.html

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="zh-CN">
33

4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
7-
<meta name="theme-color" content="rgb(46, 44, 79)">
8-
<meta name="author" content="<!-- author -->">
9-
<meta property="og:site_name" content="<!-- author --> 的博客">
10-
<meta property="og:locale" content="zh_CN">
11-
<meta property="og:title" content="<!-- author --> 的博客">
12-
<meta property="og:type" content="website">
13-
<meta property="og:url" content="<!-- website -->">
14-
<meta name="twitter:card" content="summary">
15-
<meta name="twitter:title" content="<!-- author --> 的博客">
16-
<meta name=application-name content="<!-- author --> 的博客">
17-
<meta name=apple-mobile-web-app-title content="<!-- author --> 的博客">
18-
<title> <!-- author --> 的博客</title>
19-
<link rel="shortcut icon" href="/public/favicon.ico" type="image/x-icon">
20-
<link rel="stylesheet" href="<!-- base.css -->">
21-
<link rel="stylesheet" href="<!-- index.css -->">
22-
<link rel="stylesheet" href="<!-- markdown.css -->">
23-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
24-
<script src="<!-- index.js -->"></script>
25-
</head>
4+
<!-- Head -->
265

276
<body>
287
<!-- Header -->

main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ async function createConfig() {
1919
version: Math.floor(Math.random() * 1000000),
2020
}
2121

22+
const head = await Deno.readTextFile(
23+
new URL('./util/head.html', baseConfig.src),
24+
)
25+
2226
const header = await Deno.readTextFile(
2327
new URL('./util/header.html', baseConfig.src),
2428
)
2529
const footer = await Deno.readTextFile(
2630
new URL('./util/footer.html', baseConfig.src),
2731
)
2832

29-
return { ...baseConfig, header, footer }
33+
return { ...baseConfig, header, footer, head }
3034
}
3135

3236
const config = await createConfig()

src/about/about.html renamed to src/about/index.html

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="zh-CN">
33

4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
7-
<meta name="description" content="fwqaaq 的介绍,在这里认识我">
8-
<meta name="keywords" content="HTML, CSS, JavaScript, TypeScript, Vue, Git...">
9-
<meta name="theme-color" content="rgb(26, 26, 26)">
10-
<title> fwqaaq Blog </title>
11-
<link rel="shortcut icon" href="/public/favicon.ico" type="image/x-icon">
12-
<link rel="stylesheet" href="<!-- base.css -->">
13-
<link rel="stylesheet" href="<!-- index.css -->">
14-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
15-
<script src="<!-- index.js -->"></script>
16-
</head>
4+
<!-- Head -->
175

186
<body>
19-
<header class="blog-header">
20-
<i id="switch-icon" class="fa-solid fa-bars"></i>
21-
<a href="https://github.com/fwqaaq" target="_blank">
22-
<img src="https://avatars.githubusercontent.com/u/82551626?v=4" loading="lazy" alt="me" srcset="">
23-
</a>
24-
<nav class="header-nav">
25-
<a class="decoration-line" href="/"><i class="fa-solid fa-house-chimney fa-xs"></i>
26-
<span class="disappear">首页</span>
27-
</a>
28-
<a class="decoration-line" href="/./about/index.html"><i class="fa-solid fa-address-card fa-xs"></i>
29-
<span class="disappear">关于</span></a>
30-
<a class="decoration-line" href="/./archive/index.html"><i class="fa-solid fa-box-archive fa-xs"></i> <span
31-
class="disappear">归档</span></a>
32-
<a class="decoration-line" href="/./tags/index.html"><i class="fa-solid fa-tag fa-xs"></i> <span
33-
class="disappear">标签</span></a>
34-
<div class="toy"><i class="fa-solid fa-gamepad fa-xs"></i> <span class="disappear">玩具</span>
35-
<nav class="toy-nav disappear">
36-
<a class="decoration-line" href="/public/resume/">我的简历</a>
37-
<a class="decoration-line" href="/public/write-css/index.html">学习 UI</a>
38-
</nav>
39-
</div>
40-
<a class="decoration-line" href="/feed.xml"><i class="fa-solid fa-rss fa-xs"></i> <span
41-
class="disappear">订阅</span></a>
42-
<a class="decoration-line model" href="#" class="model"><i class="fa-solid fa-sun fa-xs"></i></a>
43-
</nav>
44-
</header>
7+
<!-- Header -->
458
<main class="about-main">
469
<div class="about-container">
4710
<h2>关于我</h2>
@@ -53,9 +16,9 @@ <h2>欢迎来到 fwqaaq 的博客</h2>
5316
<h3>感谢你的参观</h3>
5417
</section>
5518
<section class="box about-card-4 about-section-color-one">
56-
<h3>人生格言</h3>
57-
<h2>像我这样的下水道的老鼠一辈子都见不到光</h2>
58-
<h3>--from fwqaaq</h3>
19+
<h3>最爱 makima</h3>
20+
<h2>所以你会选择乡下的老鼠还是城里的老鼠呢</h2>
21+
<h3>--from Reze</h3>
5922
</section>
6023
</div>
6124
<div class="about-row">
@@ -134,29 +97,7 @@ <h3>Feel me</h3>
13497
</div>
13598
</div>
13699
</main>
137-
<footer class="blog-footer">
138-
<div class="footer-container">
139-
<p class="text-center"><a class="decoration-line"
140-
href="https://creativecommons.org/licenses/by-sa/3.0/deed.zh-hans">© CC BY-SA</a> 2021 -
141-
2024 <a class="decoration-line" href="https://github.com/fwqaaq">fwqaaq</a>.
142-
Powered by <a class="decoration-line" href="https://deno.com">Deno</a>
143-
</p>
144-
</div>
145-
<div class="footer-icons-container">
146-
<a class="icon" href="https://github.com/fwqaaq">
147-
<img src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" width="32px" alt="GitHub">
148-
</a>
149-
<a class="icon" href="mailto:fwqaaq@gmail">
150-
<img src="https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico" width="32px" alt="Gmail">
151-
</a>
152-
<a class="icon" href="https://www.fwqaaq.com">
153-
<img src="https://www.fwqaaq.com/public/favicon.ico" width="32px" alt="Blog" />
154-
</a>
155-
<a class="icon" href="https://t.me/fwqaaq">
156-
<img src="https://telegram.org/img/website_icon.svg?4" width="32px" alt="Telegram">
157-
</a>
158-
</div>
159-
</footer>
100+
<!-- Footer -->
160101
</body>
161102

162103
</html>

src/plugins/asserts.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { copy, ensureDir, ensureFile, exists, walk } from 'fs'
2-
import { replaceHead } from '../util/utils.js'
1+
import { copy, ensureDir, walk } from 'fs'
32
import { createProcessor } from '../util/utils.js'
43

54
export const assertPlugin = {
@@ -54,17 +53,6 @@ export const assertPlugin = {
5453

5554
await copy(entry.path, __dist_p, {})
5655
}
57-
58-
// about me
59-
const __dist_about = new URL('./about/index.html', dist)
60-
if (!await exists(__dist_about)) await ensureFile(__dist_about)
61-
const __src_about = new URL('./about/about.html', src)
62-
63-
const about = await replaceHead(
64-
{ version },
65-
await Deno.readTextFile(__src_about),
66-
)
67-
Deno.writeTextFile(__dist_about, about)
6856
},
6957
)
7058
},

src/plugins/pages.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
generateTags,
66
handleUTC,
77
replaceBody,
8+
replaceHead,
89
} from '../util/utils.js'
910
import { templateBox, templateProcess } from '../util/template.js'
1011

@@ -17,34 +18,52 @@ export const pagesPlugin = {
1718
core.addhook(
1819
'afterBuild',
1920
async (/**@type {import("../util/type.js").Config} */ config) => {
20-
const { dist, version, header, footer, src, author, website } = config
21+
const { dist, version, header, footer, src, author, website, head } =
22+
config
23+
const newHead = replaceHead({
24+
keywords: 'fwqaaq, blog, about, fwqaaq blog',
25+
description: 'fwqaaq 的个人博客',
26+
title: 'fwqaaq 的博客',
27+
version,
28+
url: website,
29+
author,
30+
}, head)
31+
32+
// handle the about page
33+
const aboutURL = new URL('./about/index.html', src)
34+
const aboutPage = replaceBody(newHead, header, footer, aboutURL)
35+
await ensureDir(new URL('./about/', dist))
36+
await Deno.writeTextFile(new URL('./about/index.html', dist), aboutPage)
2137

2238
// Handle the archive
2339
const groupArchive = Object.groupBy(
24-
meta,
40+
meta.map((item) => ({ author, ...item })),
2541
(item) => new Date(item.date).getFullYear(),
2642
)
2743

2844
// Handle the tags
2945
const groupTags = Object.groupBy(
30-
meta.flatMap((item) => item.tags.map((tag) => ({ tag, ...item }))),
46+
meta.flatMap((item) =>
47+
item.tags.map((tag) => ({ tag, author, ...item }))
48+
),
3149
(item) => item.tag,
3250
)
3351

3452
Promise.all([
35-
generatePage({ group: groupArchive, basePath: 'archive', ...config }),
36-
generatePage({ group: groupTags, basePath: 'tags', ...config }),
53+
generatePage({
54+
group: groupArchive,
55+
basePath: 'archive',
56+
head,
57+
...config,
58+
}),
59+
generatePage({ group: groupTags, basePath: 'tags', head, ...config }),
3760
])
3861

62+
// index home temeplate url
63+
const homeURL = new URL('../index.html', src)
64+
3965
// handle the 404
40-
const indexPage = replaceBody(
41-
header,
42-
footer,
43-
version,
44-
src,
45-
author,
46-
website,
47-
)
66+
const indexPage = replaceBody(newHead, header, footer, homeURL)
4867
const notFound = indexPage.replace(
4968
'<!-- Template -->',
5069
`<section class="not-found">

src/plugins/posts.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const postPlugin = {
2020
core.addhook(
2121
'beforeBuild',
2222
async (/**@type {import("../util/type.js").Config} */ config) => {
23-
const { dist, src, version, header, footer, website, author } = config
23+
const { dist, src, version, header, footer, website, author, head } =
24+
config
2425

2526
const posts = new URL('./posts/', src)
2627
const iter = Deno.readDir(posts)[Symbol.asyncIterator]()
@@ -62,8 +63,12 @@ export const postPlugin = {
6263

6364
const matches = postContent.match(updateRegex)
6465
const updateAt = matches ? matches[2].trim() : null
66+
const oneDay = 24 * 60 * 60 * 1000
6567

66-
if (!updateAt || new Date(updateAt) < new Date(updated)) {
68+
if (
69+
!updateAt ||
70+
+new Date(updateAt) + oneDay < +new Date(updated)
71+
) {
6772
postContent = postContent.replace(
6873
updateRegex,
6974
`updateAt: ${updated}`,
@@ -88,14 +93,14 @@ export const postPlugin = {
8893

8994
const keywords = tags.join(', ')
9095
const url = `${website}/posts/${handleUTC(date)}/`
91-
const head = await replaceHead({
96+
const newHead = replaceHead({
9297
keywords,
9398
description,
9499
title,
95100
version,
96101
url,
97102
author,
98-
})
103+
}, head)
99104
const postMeta = `<div class="post-meta post-meta-flex-around">
100105
<div class="post-author" href="/./about/"><i class="fa-solid fa-user"></i> ${author}</div>
101106
<div class="post-time"><i class="fa-solid fa-clock"></i> ${
@@ -111,7 +116,7 @@ export const postPlugin = {
111116
giscus,
112117
postMeta,
113118
})
114-
const post = `${head}${header}${content}${footer}`
119+
const post = `${newHead}${header}${content}${footer}`
115120

116121
await Deno.writeTextFile(postDist, post)
117122

src/util/footer.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
</div>
99
<div class="footer-icons-container">
1010
<a class="icon" href="https://github.com/fwqaaq">
11-
<img src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" width="32px" alt="GitHub">
11+
<i class="fa-brands fa-github" style="font-size:1.6rem;color: var(--theme-color);"></i>
1212
</a>
1313
<a class="icon" href="mailto:fwqaaq@gmail">
14-
<img src="https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico" width="32px" alt="Gmail">
14+
<i class="fa-solid fa-envelope" style="font-size:1.6rem;color: var(--theme-color);"></i>
1515
</a>
16-
<a class="icon" href="https://www.fwqaaq.com">
17-
<img src="https://www.fwqaaq.com/public/favicon.ico" width="32px" alt="Blog" />
16+
<a class="icon" href="https://www.fwqaaq.com/feed.xml">
17+
<i class="fa-solid fa-rss" style="font-size:1.6rem;color: var(--theme-color);"></i>
1818
</a>
1919
<a class="icon" href="https://t.me/fwqaaq">
20-
<img src="https://telegram.org/img/website_icon.svg?4" width="32px" alt="Telegram">
20+
<i class="fa-brands fa-telegram" style="font-size:1.6rem;color: var(--theme-color);"></i>
2121
</a>
2222
</div>
2323
</footer>

src/util/header.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
<a class="decoration-line" href="/public/pdf-utils/">pdf 水印工具</a>
2020
</nav>
2121
</div>
22-
<a class="decoration-line" href="/feed.xml"><i class="fa-solid fa-rss fa-xs"></i> <span
23-
class="disappear">订阅</span></a>
2422
<a class="decoration-line model" href="#" class="model"><i class="fa-solid fa-sun fa-xs"></i></a>
2523
</nav>
2624
</header>

src/util/type.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @property {number} version
3030
* @property {string} header
3131
* @property {string} footer
32+
* @property {string} head
3233
*/
3334

3435
/**
@@ -45,8 +46,9 @@
4546
* @property {Record<string, import("../plugins/core.js").MetaData>} group
4647
* @property {"archive" | "tags"} basePath
4748
* @property {string} dist
48-
* @property {string} header
49-
* @property {string} footer
5049
* @property {string} version
5150
* @property {string} author
51+
* @property {string} head
52+
* @property {string} header
53+
* @property {string} footer
5254
*/

0 commit comments

Comments
 (0)