Skip to content

Commit 5b3ccc0

Browse files
committed
refactor(ui): unify date format and improve accessibility
1 parent 1889d99 commit 5b3ccc0

File tree

9 files changed

+23
-25
lines changed

9 files changed

+23
-25
lines changed

assets/js/code-block.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ document.addEventListener('DOMContentLoaded', () => {
1010
preElement.parentNode.insertBefore(codeContainer, preElement);
1111
codeContainer.appendChild(preElement);
1212

13-
const copyButton = document.createElement('button');
14-
copyButton.className = 'copy-code-btn';
15-
copyButton.innerHTML = '<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';
13+
const copyButton = document.createElement('button');
14+
copyButton.className = 'copy-code-btn';
15+
copyButton.setAttribute('aria-label', 'Copy code to clipboard');
16+
copyButton.setAttribute('title', 'Copy code');
17+
copyButton.innerHTML = '<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';
1618
codeContainer.appendChild(copyButton);
1719

1820
copyButton.addEventListener('click', () => {

assets/js/toc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ document.addEventListener('DOMContentLoaded', () => {
5454
});
5555
ticking = true;
5656
}
57-
});
57+
}, { passive: true });
5858

5959
onScroll(); // Initial check
6060
});

content/learn/heap-memory.smd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ defer allocator.free(say);
248248

249249
另一种形式是将 `Allocator` 传递给 `init` ,然后由对象**内部使用**。这种方法不那么明确,因为你已经给了对象一个分配器来使用,但你不知道哪些方法调用将实际分配。对于长寿命对象来说,这种方法更实用。
250250

251-
注入分配器的优势不仅在于显式,还在于灵活性。`std.mem.Allocator` 是一个接口,提供了 `alloc`、`free`、`create` 和 `destroy` 函数以及其他一些函数。到目前为止,我们只看到了 `std.heap.GeneralPurposeAllocator`,但标准库或第三方库中还有其他实现.
251+
注入分配器的优势不仅在于显式,还在于灵活性。`std.mem.Allocator` 是一个接口,提供了 `alloc`、`free`、`create` 和 `destroy` 函数以及其他一些函数。到目前为止,我们只看到了 `std.heap.GeneralPurposeAllocator`,但标准库或第三方库中还有其他实现
252252

253253
> Zig 没有用于创建接口的语法糖。一种类似于接口的模式是带标签的联合(tagged unions),不过与真正的接口相比,这种模式相对受限。整个标准库中也探索了一些其他模式,例如 `std.mem.Allocator`。本指南不探讨这些接口模式。
254254

content/post/2024-06-11-zig-hashmap-2.smd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ if (gop.found_existing) {
365365
}
366366
```
367367

368-
当然,只要不对哈希表进行修改,`value_ptr` 就应被视为有效. 顺便提一句,这同样适用于我们通过 `iterator()`、`valueIterator` 和 `keyIterator` 获取的迭代键和值,原因相同。
368+
当然,只要不对哈希表进行修改,`value_ptr` 就应被视为有效顺便提一句,这同样适用于我们通过 `iterator()`、`valueIterator` 和 `keyIterator` 获取的迭代键和值,原因相同。
369369

370370
## [结论]($heading.id('conclusion'))
371371

layouts/learn.shtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<h1 :text="$page.title" data-pagefind-meta="title" data-pagefind-ignore></h1>
1313
<div data-pagefind-sort="date" :text="$page.date.format('2006-01-02')" style="display:none"></div>
1414
<div class="toc-fallback" :if="$page.isSection().not().and($page.custom.getOr('toc', true))" data-pagefind-ignore>
15-
<h3>Table Of Content</h3>
15+
<h3>Table of Contents</h3>
1616
<div :html="$page.toc()"></div>
1717
</div>
1818
<div :html="$page.content()"></div>

layouts/monthly.shtml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
<a href="$loop.it.link()" class="monthly-item">
2323
<span class="monthly-item-title" :text="$loop.it.title"></span>
2424
<div class="monthly-item-meta">
25-
<span class="monthly-date-part" :text="$loop.it.date.format('01')"></span>
26-
<span class="monthly-sep">/</span>
27-
<span class="monthly-date-part" :text="$loop.it.date.format('2006')"></span>
25+
<span class="monthly-date-part" :text="$loop.it.date.format('2006-01-02')"></span>
2826
</div>
2927
</a>
3028
</div>
@@ -34,7 +32,7 @@
3432
<!-- Article Page: Content + Prev/Next -->
3533
<div :if="$page.isSection().not()">
3634
<div class="toc-fallback" :if="$page.custom.getOr('toc', true)" data-pagefind-ignore>
37-
<h3>Table Of Content</h3>
35+
<h3>Table of Contents</h3>
3836
<div :html="$page.toc()"></div>
3937
</div>
4038
<div :html="$page.content()" class="monthly-content"></div>

layouts/post.shtml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@
4747
<a href="$loop.it.link()" class="monthly-item">
4848
<span class="monthly-item-title" :text="$loop.it.title"></span>
4949
<div class="monthly-item-meta">
50-
<span class="monthly-date-part" :text="$loop.it.date.format('02')"></span>
51-
<span class="monthly-sep">/</span>
52-
<span class="monthly-date-part" :text="$loop.it.date.format('01')"></span>
53-
<span class="monthly-sep">/</span>
54-
<span class="monthly-date-part" :text="$loop.it.date.format('2006')"></span>
50+
<span class="monthly-date-part" :text="$loop.it.date.format('2006-01-02')"></span>
5551
</div>
5652
</a>
5753
</div>
@@ -64,11 +60,11 @@
6460
<p>
6561
<span id="author" :text="$page.author"></span>
6662
|
67-
<span :text="$page.date.format('January 02, 2006')"></span>
63+
<span :text="$page.date.format('2006-01-02')"></span>
6864
</p>
6965
</div>
7066
<div class="toc-fallback" :if="$page.custom.getOr('toc', true)" data-pagefind-ignore>
71-
<h3>Table Of Content</h3>
67+
<h3>Table of Contents</h3>
7268
<div :html="$page.toc()"></div>
7369
</div>
7470
<div :html="$page.content()"></div>

layouts/templates/base.shtml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
fetch('https://en.liujiacai.net/pv/write?' + new URLSearchParams(payload),
2626
{mode: 'no-cors'}).catch(console.log);
2727
</script>
28-
<script src="$site.asset('js/toc.js').link()"></script>
29-
<script src="$site.asset('js/code-block.js').link()"></script>
28+
<script defer src="$site.asset('js/toc.js').link()"></script>
29+
<script defer src="$site.asset('js/code-block.js').link()"></script>
3030

3131
<super>
3232
</head>
@@ -41,7 +41,7 @@
4141
<a href="$site.page('contributing').link()">贡献</a>
4242
<a href="$site.page('search').link()">搜索</a>
4343
</nav>
44-
<button class="mobile-menu-toggle" id="menu-toggle" aria-label="Toggle navigation menu" aria-expanded="false">
44+
<button class="mobile-menu-toggle" id="menu-toggle" aria-label="Toggle navigation menu" aria-expanded="false" aria-controls="nav-menu">
4545
<span class="mobile-menu-line"></span>
4646
<span class="mobile-menu-line"></span>
4747
<span class="mobile-menu-line"></span>
@@ -50,8 +50,10 @@
5050
</div>
5151
<script>
5252
document.getElementById('menu-toggle').addEventListener('click', function() {
53-
document.getElementById('nav-menu').classList.toggle('active');
53+
const nav = document.getElementById('nav-menu');
54+
const active = nav.classList.toggle('active');
5455
this.classList.toggle('active');
56+
this.setAttribute('aria-expanded', active);
5557
});
5658
</script>
5759
<super>

layouts/templates/content.shtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
<h1 :text="$page.title" data-pagefind-meta="title" data-pagefind-ignore></h1>
1414
<div data-pagefind-sort="date" :text="$page.date.format('2006-01-02')" style="display:none"></div>
1515
<div id="meta" :if="$page.isSection().not()" data-pagefind-ignore>
16-
<p :text="$page.date.format('2006-01-03')"></p>
16+
<p :text="$page.date.format('2006-01-02')"></p>
1717
<p :text="$page.author" id="author"></p>
1818
</div>
1919
<div class="toc-fallback" :if="$page.custom.getOr('toc', true).and($page.isSection().not())" data-pagefind-ignore>
20-
<h3>Table Of Content</h3>
20+
<h3>Table of Contents</h3>
2121
<div :html="$page.toc()"></div>
2222
</div>
2323
<ul class="article-list" :loop="$page.subpages()" data-pagefind-ignore>
2424
<li>
2525
<a href="$loop.it.link()" class="article-item">
2626
<span class="article-title" :text="$loop.it.title"></span>
2727
<span class="article-date" :if="$page.custom.getOr('showTocDate', true)">
28-
<time datetime="$loop.it.date.format('2006-01-03')" :text="$loop.it.date.format('2006-01-03')"></time>
28+
<time datetime="$loop.it.date.format('2006-01-02')" :text="$loop.it.date.format('2006-01-02')"></time>
2929
</span>
3030
</a>
3131
</li>

0 commit comments

Comments
 (0)