Skip to content

Commit 60d07e9

Browse files
committed
format some code
1 parent 13aab4e commit 60d07e9

File tree

6 files changed

+88
-42
lines changed

6 files changed

+88
-42
lines changed

src/plugins/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class Core {
1212
}
1313
}
1414

15-
use(/**@type {Plugin}*/ plugin) {
15+
use(/**@type {import("../util/type.js").Plugin}*/ plugin) {
1616
if (this.plugins.has(plugin.name)) {
1717
throw new Error(`Plugin ${plugin.name} already exists`)
1818
}

src/posts/css_animation.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,39 @@ document.startViewTransition(
9898
['--end-radius', `${endRadius}px`]
9999
].forEach(([v, c]) => document.documentElement.style.setProperty(v, c))
100100
```
101+
102+
### 过渡动画
103+
104+
在过渡动画中,经常可以看到在 AJAX 请求中,有一个圆圈过渡的动画,这个实现也是非常简单。
105+
106+
1. 圆圈动画的实现,实际上就是少了一个 border 的圆圈在不停的旋转:
107+
108+
```css
109+
.loading::after {
110+
content: "";
111+
display: block;
112+
position: absolute;
113+
top: 50vh;
114+
left: 50%;
115+
width: 60px;
116+
height: 60px;
117+
margin: -30px 0 0 -30px;
118+
border-radius: 50%;
119+
border-style: solid;
120+
border-color: var(--theme-color) var(--theme-color) var(--theme-color) transparent;
121+
animation: spin 1s ease-in-out infinite;
122+
z-index: 1;
123+
}
124+
125+
@keyframes spin {
126+
0% {
127+
transform: rotate(0deg);
128+
}
129+
130+
100% {
131+
transform: rotate(360deg)
132+
}
133+
}
134+
```
135+
136+
2. 在 AJAX 请求中,要选择对时机,在请求开始的时候添加 `.loading` 类,请求结束的时候移除 `.loading` 类。参见:<https://github.com/fwqaaq/fwqaaq.github.io/blob/13aab4ed811fa89898321e470382479ab053e5d8/public/JavaScript/index.js#L196-L204>

src/posts/gitLFS.md renamed to src/posts/git_lfs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ summary: 使用 GIT LFS 进行大文件的版本控制
99

1010
[TOC]
1111

12-
## [GIT LEF](https://git-lfs.com)
12+
## [GIT LFS](https://git-lfs.com)
1313

1414
> Git LFS 是对例如音频、视频、图形等大文件的一种扩展,它可以将大文件存储在 Git 仓库之外,从而加快 Git 的速度,同时也可以避免 Git 仓库过大。
1515

src/util/remark/remark-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { visit } from 'unist-util-visit'
22

33
/** @type {import('unified/index.d.ts').Plugin<[], import('type-mdast').Root>}*/
44
const remarkList = () => {
5-
return (/**@type {import('type-mdast').Root}*/tree) => {
5+
return (/**@type {import('type-mdast').Root}*/ tree) => {
66
visit(
77
tree,
88
'list',

src/util/remark/remark-toc.js

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,52 @@ const remarkToc = (options = {}) => {
1212
return (tree) => {
1313
/** @type {{type: string, depth: number, children: []}[]}*/
1414
const headings = []
15-
visit(tree, "heading", (/**@type {import("type-mdast").Node} */ node, _index) => {
16-
/**@type {string} */
17-
let title = node.children[0].value
18-
// Using others type when heading is not a text node
19-
if (node.children[0].type !== "text" && node.children[0].children[0]) {
20-
title = node.children[0].children[0].value
21-
}
22-
/**@type {number} */
23-
const depth = node.depth
24-
const children = [{ type: "text", value: title }]
25-
headings.push({ type: "heading", depth, children })
26-
})
15+
visit(
16+
tree,
17+
'heading',
18+
(/**@type {import("type-mdast").Node} */ node, _index) => {
19+
/**@type {string} */
20+
let title = node.children[0].value
21+
// Using others type when heading is not a text node
22+
if (node.children[0].type !== 'text' && node.children[0].children[0]) {
23+
title = node.children[0].children[0].value
24+
}
25+
/**@type {number} */
26+
const depth = node.depth
27+
const children = [{ type: 'text', value: title }]
28+
headings.push({ type: 'heading', depth, children })
29+
},
30+
)
2731

28-
visit(tree, "paragraph", (/**@type {import("type-mdast").Node} */ node, _index) => {
29-
if (node.children?.[0]?.value !== flag) return
30-
const table = toc({ type: "root", children: headings })
31-
// update toc node
32-
table.map.data = {
33-
hProperties: {
34-
class: "remark-toc",
35-
},
36-
}
37-
node.data = {
38-
hName: "details",
39-
hProperties: {
40-
class: "remark-toc-details",
41-
},
42-
}
43-
node.children = [
44-
{
45-
type: "html",
46-
value: "<summary class='remark-toc-summary'>目录</summary>",
47-
},
48-
table.map
49-
]
50-
})
32+
visit(
33+
tree,
34+
'paragraph',
35+
(/**@type {import("type-mdast").Node} */ node, _index) => {
36+
if (node.children?.[0]?.value !== flag) return
37+
const table = toc({ type: 'root', children: headings })
38+
// update toc node
39+
table.map.data = {
40+
hProperties: {
41+
class: 'remark-toc',
42+
},
43+
}
44+
node.data = {
45+
hName: 'details',
46+
hProperties: {
47+
class: 'remark-toc-details',
48+
},
49+
}
50+
node.children = [
51+
{
52+
type: 'html',
53+
value: "<summary class='remark-toc-summary'>目录</summary>",
54+
},
55+
table.map,
56+
]
57+
},
58+
)
5159
return tree
5260
}
5361
}
5462

55-
export default remarkToc
63+
export default remarkToc

src/util/utils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ export async function generatePage(
114114
(acc, { date, summary }) => {
115115
const place = `/./posts/${handleUTC(date)}/index.html`
116116
return acc +
117-
`<p class="archive-p-line"><a class="archive-time-line" href=${place} target="_blank"> <span>${summary}</span> <span>${convertToUSA(date)
117+
`<p class="archive-p-line"><a class="archive-time-line" href=${place} target="_blank"> <span>${summary}</span> <span>${
118+
convertToUSA(date)
118119
}</span></a></p>`
119120
},
120121
'',
121122
)
122-
const itemBody = `${itemHead}${header}${templateArticle({ title: key, content: p })
123-
}${footer}`
123+
const itemBody = `${itemHead}${header}${
124+
templateArticle({ title: key, content: p })
125+
}${footer}`
124126
await Deno.writeTextFile(itemUrl, itemBody)
125127
}
126128
}

0 commit comments

Comments
 (0)