Skip to content

Commit

Permalink
feat: update CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
EveSunMaple committed Dec 4, 2024
1 parent 508d790 commit bd47d4d
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 115 deletions.
31 changes: 30 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,33 @@

### Fix

- 修复了若干问题
- 修复了若干问题

## [2.8.1] - 2024-12-5

### Features

- 新增 `sitmap.xml` 代替自动生成的 `sitmap-0.xml`
- 重写 `rss.xml.ts` 完善了格式并在 RSS 中添加了全文内容
- 新增可重用组件 `GithubInfo` 路径:src\widget\GithubInfo.astro
- 新增卡片布局 包括 `Aside` / `Horizontal` / `Vertical`
- 为博客文章内容添加了渐入效果
- 添加了手动开关评论系统的功能

### Refactored

- 组件布局统一并修改
- 重写了博客底部 License 组件的样式
- 清理了全局的 ClassName 以简化代码
- 将 `tag` 路由更名为 `tags`

### Fix

- 可访问性修复:为必要的组件添加了 `aria-label` 以及由 `sr-only` 包裹的文本
- 为代码框中的复制按钮添加了随机的专属的 `id` 与表单链接
- 修复了分页按钮在仅有一页时出现的样式错误
- 修复了在标签与分类页面下不显示字数与阅读时长的问题

### Chore

- 使用 `iconify` 代替了本地存储 svg 的方式
223 changes: 109 additions & 114 deletions src/config/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,128 +11,123 @@ export const transformers = [
}
},
pre(node) {
const generateUniqueId = () => {
return `copy-checkbox-${Math.random().toString(36).slice(2, 9)}`;
};

const uniqueId = crypto.randomUUID();
// 复制按钮 HTML
const copyButtonHTML = (index) => {
const uniqueId = `${generateUniqueId()}-${index}`; // 使用 index 来生成唯一的 id
return {
type: "element",
tagName: "div",
properties: { className: ["code-container"] },
children: [
{
type: "element",
tagName: "label",
properties: {
className: [
"swap",
"swap-flip",
"btn",
"btn-ghost",
"btn-sm",
"copy-btn",
const copyButtonHTML = {
type: "element",
tagName: "div",
properties: { className: ["code-container"] },
children: [
{
type: "element",
tagName: "label",
properties: {
className: [
"swap",
"swap-flip",
"btn",
"btn-ghost",
"btn-sm",
"copy-btn",
],
for: uniqueId, // 关联控件
"aria-label": "Copy to clipboard",
},
children: [
{
type: "element",
tagName: "span",
properties: { className: ["sr-only"], },
children: [
{
type: "text",
value: "Copy to clipboard",
},
],
for: uniqueId, // 关联控件
"aria-label": "Copy to clipboard",
},
children: [
{
type: "element",
tagName: "span",
properties: { className: ["sr-only"], },
children: [
{
type: "text",
value: "Copy to clipboard",
},
],
},
{
type: "element",
tagName: "input",
properties: {
className: ["copy-checkbox"],
type: "checkbox",
id: uniqueId, // 使用唯一的 id
},
{
type: "element",
tagName: "input",
properties: {
className: ["copy-checkbox"],
type: "checkbox",
id: uniqueId, // 使用唯一的 id
},
{
type: "element",
tagName: "div",
properties: { className: ["swap-on"] },
children: [
{
type: "element",
tagName: "svg",
properties: {
viewBox: "0 -0.5 25 25",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
className: "stroke-current shrink-0 h-6 w-6",
},
children: [
{
type: "element",
tagName: "path",
properties: {
d: "M5.5 12.5L10.167 17L19.5 8",
strokeWidth: "1.5",
strokeLinecap: "round",
strokeLinejoin: "round",
},
},
],
},
{
type: "element",
tagName: "div",
properties: { className: ["swap-on"] },
children: [
{
type: "element",
tagName: "svg",
properties: {
viewBox: "0 -0.5 25 25",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
className: "stroke-current shrink-0 h-6 w-6",
},
],
},
{
type: "element",
tagName: "div",
properties: { className: ["swap-off"] },
children: [
{
type: "element",
tagName: "svg",
properties: {
viewBox: "0 -0.5 25 25",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
className: "stroke-current shrink-0 h-6 w-6",
children: [
{
type: "element",
tagName: "path",
properties: {
d: "M5.5 12.5L10.167 17L19.5 8",
strokeWidth: "1.5",
strokeLinecap: "round",
strokeLinejoin: "round",
},
},
children: [
{
type: "element",
tagName: "path",
properties: {
fillRule: "evenodd",
clipRule: "evenodd",
d: "M17.676 14.248C17.676 15.8651 16.3651 17.176 14.748 17.176H7.428C5.81091 17.176 4.5 15.8651 4.5 14.248V6.928C4.5 5.31091 5.81091 4 7.428 4H14.748C16.3651 4 17.676 5.31091 17.676 6.928V14.248Z",
strokeWidth: "1.5",
strokeLinecap: "round",
strokeLinejoin: "round",
},
],
},
],
},
{
type: "element",
tagName: "div",
properties: { className: ["swap-off"] },
children: [
{
type: "element",
tagName: "svg",
properties: {
viewBox: "0 -0.5 25 25",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
className: "stroke-current shrink-0 h-6 w-6",
},
children: [
{
type: "element",
tagName: "path",
properties: {
fillRule: "evenodd",
clipRule: "evenodd",
d: "M17.676 14.248C17.676 15.8651 16.3651 17.176 14.748 17.176H7.428C5.81091 17.176 4.5 15.8651 4.5 14.248V6.928C4.5 5.31091 5.81091 4 7.428 4H14.748C16.3651 4 17.676 5.31091 17.676 6.928V14.248Z",
strokeWidth: "1.5",
strokeLinecap: "round",
strokeLinejoin: "round",
},
{
type: "element",
tagName: "path",
properties: {
d: "M10.252 20H17.572C19.1891 20 20.5 18.689 20.5 17.072V9.75195",
strokeWidth: "1.5",
strokeLinecap: "round",
strokeLinejoin: "round",
},
},
{
type: "element",
tagName: "path",
properties: {
d: "M10.252 20H17.572C19.1891 20 20.5 18.689 20.5 17.072V9.75195",
strokeWidth: "1.5",
strokeLinecap: "round",
strokeLinejoin: "round",
},
],
},
],
},
],
},
],
};
},
],
},
],
},
],
},
],
};

// 生成工具栏(包含代码语言标签)
Expand Down Expand Up @@ -188,7 +183,7 @@ export const transformers = [
});

codeContentPre.children.push(lineNode);
toolsDiv.children.push(copyButtonHTML(index)); // 为每个代码框生成唯一的复制按钮
toolsDiv.children.push(copyButtonHTML); // 为每个代码框生成唯一的复制按钮
});

// 生成最终的代码块结构
Expand Down

0 comments on commit bd47d4d

Please sign in to comment.