Skip to content

Commit

Permalink
🎉 copy button and layout -> 2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EveSunMaple committed Nov 9, 2024
1 parent 62642b9 commit 7b2712d
Show file tree
Hide file tree
Showing 10 changed files with 2,711 additions and 2,467 deletions.
79 changes: 3 additions & 76 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";
import rehypeExternalLinks from 'rehype-external-links';
import playformCompress from "@playform/compress";
import partytown from "@astrojs/partytown";

import swup from "@swup/astro";
import astroI18next from "astro-i18next";

import { transformers } from './src/config/transformers.js';

import { remarkAddAnchor } from './src/plugins/remark-add-anchor.mjs';
import { remarkReadingTime } from './src/plugins/remark-reading-time.mjs';

Expand Down Expand Up @@ -51,81 +52,7 @@ export default defineConfig({
light: CODE_THEME.light,
dark: CODE_THEME.dark,
},
transformers: [
{
preprocess(code, { lang }) {
this.lang = lang;
return code;
},
root(node) {
if (node.tagName === "pre") {
node.tagName = "figure";
node.properties.className = ["highlight", this.lang];
}
},
pre(node) {
const toolsDiv = {
type: "element",
tagName: "div",
properties: { className: ["highlight-tools"] },
children: [
{
type: "element",
tagName: "div",
properties: { className: ["code-lang"] },
children: [{ type: "text", value: this.lang.toUpperCase() }],
},
],
};
const lineNumberCode = {
type: "element",
tagName: "code",
children: [],
};
const lineNumberPre = {
type: "element",
tagName: "pre",
properties: { className: ["frosti-code", "gutter"] },
children: [lineNumberCode],
};
const codeContentPre = {
type: "element",
tagName: "pre",
properties: { className: ["frosti-code", "code"] },
children: [],
};
node.children.forEach((lineNode, index, count) => {
count = 0;
lineNode.children.forEach(() => {
if (count & (1 === 1)) {
lineNumberCode.children.push({
type: "element",
tagName: "div",
properties: { className: ["line"] },
children: [{ type: "text", value: String(index + 1) }],
});
index++;
}
count++;
});

codeContentPre.children.push(lineNode);
});
const table = {
type: "element",
tagName: "div",
properties: { className: ["highlight-code"] },
children: [lineNumberPre, codeContentPre],
};
return {
type: "element",
tagName: "figure",
properties: { className: ["highlight", this.lang] },
children: [toolsDiv, table],
};
},
},
],
transformers: transformers
},
remarkPlugins: [remarkMath, remarkAddAnchor, remarkReadingTime],
rehypePlugins: [rehypeKatex,
Expand Down
19 changes: 17 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
- 修复了滚动问题
- 修复了在站内跳转时目录中 `active` 保留的问题

## [2.8.0] - 2024-11-3
## [2.8.0-rc] - 2024-11-3

### Features

Expand All @@ -549,4 +549,19 @@
### Fix

- 修复了控制台报错
- 补上了 `ProjectCard` 缺失的颜色过渡
- 补上了 `ProjectCard` 缺失的颜色过渡

## [2.8.0] - 2024-11-9

### Features

- 为 Navbar 添加了操作:下滑页面收起,上滑放下
- 重做了代码复制按钮,减少客户端代码,具体样式详见演示

### Refactored

- 整体页面调整(之前一直觉得 “贴屏幕贴得太近了” 这种感觉,现在好很多)包括宽度与字号

### Fix

- 修复了若干问题
Loading

0 comments on commit 7b2712d

Please sign in to comment.