
Table of Contents
添加行号 Link to 添加行号
此方法仅在 Shiki
中可用, Prism
无法通过 CSS 直接生成行号。
在
v2.2.1
更新后默认添加行号。在 src\styles\global.scss
中添加以下内容:
SCSS
1234567891011121314
pre .line {
counter-increment: line;
padding-left: 2.5em;
}
pre :not(:last-child).line::before {
content: counter(line);
position: absolute;
left: 0;
width: 3em;
text-align: right;
margin-right: 10px;
color: #888;
}
改变主题 Link to 改变主题
Frosti 使用 Shiki
来渲染代码框, Shiki
已经提供了足够多的主题,不推荐使用 Prism
。
有关于 Shiki
的主题详见:https://shiki.style/themes
在 astro.config.mjs
中修改内容:
JS
12345678
markdown: {
shikiConfig: {
themes: {
light: 'github-light',
dark: 'github-dark',
},
},
},
Thanks for reading!
How to customize code box
© Tanguy Frageul | CC BY-SA 4.0