chore: add toc theme config option and update theme guides

This commit is contained in:
radishzzz 2025-05-18 17:23:32 +01:00
parent 94f9998f45
commit eb82a7d2f2
14 changed files with 121 additions and 15 deletions

View file

@ -0,0 +1,91 @@
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View file

@ -60,6 +60,8 @@ export const themeConfig: ThemeConfig = {
dateFormat: 'YYYY-MM-DD', // YYYY-MM-DD, MM-DD-YYYY, DD-MM-YYYY, MONTH DAY YYYY, DAY MONTH YYYY
// enable KaTeX for mathematical formulas rendering
katex: true, // true, false
// enable table of contents for all posts by default
toc: true, // true, false
},
// GLOBAL SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END

View file

@ -1,6 +1,6 @@
import { glob } from 'astro/loaders'
import { defineCollection, z } from 'astro:content'
import { allLocales } from '@/config'
import { allLocales, themeConfig } from '@/config'
const posts = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/posts' }),
@ -15,7 +15,7 @@ const posts = defineCollection({
// Advanced
draft: z.boolean().optional().default(false),
pin: z.number().int().min(0).max(99).optional().default(0),
toc: z.boolean().optional().default(true),
toc: z.boolean().optional().default(themeConfig.global.toc),
lang: z.enum(['', ...allLocales]).optional().default(''),
abbrlink: z.string().optional().default('').refine(
abbrlink => !abbrlink || /^[a-z0-9\-]*$/.test(abbrlink),

View file

@ -86,6 +86,8 @@ global: {
dateFormat: 'YYYY-MM-DD'
// enable KaTeX for mathematical formulas rendering
katex: true // true, false
// enable table of contents for all posts by default
toc: true // true, false
}
```
@ -315,7 +317,7 @@ Pins the article to the top. The higher the number, the higher the priority of t
#### toc
Generate table of contents. Shows h2 to h4 headings. Default is true.
Generate table of contents. Shows h2 to h4 headings. Uses the global `global.toc` configuration by default, but can be overridden individually in each article.
#### lang

View file

@ -86,6 +86,8 @@ global: {
dateFormat: 'YYYY-MM-DD'
// habilitar KaTeX para renderizar fórmulas matemáticas
katex: true // true, false
// habilitar tabla de contenidos para todos los artículos por defecto
toc: true // true, false
}
```
@ -315,7 +317,7 @@ Fija el artículo en la parte superior. Cuanto mayor sea el número, mayor será
#### toc
Genera tabla de contenidos. Muestra encabezados h2 a h4. El valor predeterminado es true.
Genera tabla de contenidos. Muestra encabezados de h2 a h4. Utiliza la configuración global `global.toc` por defecto, pero puede ser modificada individualmente en cada artículo.
#### lang

View file

@ -86,6 +86,8 @@ global: {
dateFormat: 'YYYY-MM-DD'
// 数式表示のためのKaTeXを有効化
katex: true // true, false
// デフォルトですべての記事に目次を表示
toc: true // true, false
}
```
@ -315,7 +317,7 @@ abbrlink: theme-guide
#### toc
目次を自動生成するかどうか。h2からh4までの見出しを表示します。デフォルトは true
目次を生成するかどうか。h2からh4までの見出しを表示します。デフォルトではグローバル設定 `global.toc` を使用しますが、記事ごとに個別に設定することも可能です
#### lang

View file

@ -86,6 +86,8 @@ global: {
dateFormat: 'YYYY-MM-DD'
// включить KaTeX для отображения математических формул
katex: true // true, false
// включить оглавление для всех статей по умолчанию
toc: true // true, false
}
```
@ -315,7 +317,7 @@ abbrlink: theme-guide
#### toc
Генерировать оглавление. Показывает заголовки от h2 до h4. По умолчанию — true.
Генерировать оглавление. Показывает заголовки от h2 до h4. По умолчанию использует глобальный параметр `global.toc`, но может быть изменен индивидуально в каждой статье.
#### lang

View file

@ -86,6 +86,8 @@ global: {
dateFormat: 'YYYY-MM-DD'
// 啟用 KaTeX 數學公式渲染
katex: true // true, false
// 預設為所有文章開啟目錄
toc: true // true, false
}
```
@ -315,7 +317,7 @@ abbrlink: theme-guide
#### toc
是否生成目錄。顯示 h2 至 h4 標題。預設為 true
是否生成目錄。顯示 h2 至 h4 標題。預設為全域配置 `global.toc` 的選項,可在文章中單獨設定以覆蓋全域配置
#### lang

View file

@ -86,6 +86,8 @@ global: {
dateFormat: 'YYYY-MM-DD'
// 启用 KaTeX 数学公式渲染
katex: true // true, false
// 默认为所有文章开启目录
toc: true // true, false
}
```
@ -315,7 +317,7 @@ abbrlink: theme-guide
#### toc
是否生成目录。显示 h2 至 h4 标题。默认为 true
是否生成目录。显示 h2 至 h4 标题。默认为全局配置 `global.toc` 的选项,可在文章中单独设置以覆盖全局配置
#### lang

View file

@ -1,4 +1,4 @@
/* GitHub Card >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
/* GitHub Card */
.gc-container {
--at-apply: 'block mb-4 px-5 py-4 overflow-x-auto uno-round-border bg-secondary/5';
--at-apply: 'transition-colors duration-300 ease-out lg:(px-6 py-5) hover:(bg-secondary/10 c-primary)';

View file

@ -16,7 +16,7 @@ body {
-webkit-backface-visibility: hidden;
}
body::selection {
--at-apply: 'bg-mark';
--at-apply: 'bg-highlight';
}
/* Fix KaTeX Overflow Issue */
@ -54,7 +54,7 @@ h4:hover .heading-anchor-link svg:hover {
}
.highlight-static::after,
.highlight-hover::after {
--at-apply: 'content-[""] absolute left-0 z--1 h-0.5em w-full bg-mark';
--at-apply: 'content-[""] absolute left-0 z--1 h-0.5em w-full bg-highlight';
}
.highlight-static::after,
.highlight-hover:hover::after {

View file

@ -211,7 +211,7 @@ html.dark .heti :where(u) {
/* Highlighted Text */
.heti :where(mark) {
--at-apply: 'bg-mark py-0.65 text-inherit';
--at-apply: 'bg-highlight py-0.65 text-inherit';
}
/* Footnotes */
@ -221,7 +221,7 @@ html.dark .heti :where(u) {
}
.heti sup:target,
.heti sup a:target {
--at-apply: 'bg-mark';
--at-apply: 'bg-highlight';
}
.heti .data-footnote-backref {
--at-apply: 'font-serif no-underline';

View file

@ -34,6 +34,7 @@ export interface ThemeConfig {
fontStyle: 'sans' | 'serif'
dateFormat: 'YYYY-MM-DD' | 'MM-DD-YYYY' | 'DD-MM-YYYY' | 'MONTH DAY YYYY' | 'DAY MONTH YYYY'
katex: boolean
toc: boolean
}
comment: {

View file

@ -20,7 +20,7 @@ export default defineConfig({
dark: {
colors: {
...dark,
mark: 'oklch(0.93 0.195089 103.2532 / 0.2)', // rgba(255,235,0,0.5)
highlight: 'oklch(0.93 0.195089 103.2532 / 0.2)', // rgba(255,235,0,0.5)
note: 'oklch(70.7% 0.165 254.624 / 0.8)', // blue-400
tip: 'oklch(76.5% 0.177 163.223 / 0.8)', // emerald-400
important: 'oklch(71.4% 0.203 305.504 / 0.8)', // purple-400
@ -34,7 +34,7 @@ export default defineConfig({
theme: {
colors: {
...light,
mark: 'oklch(0.93 0.195089 103.2532 / 0.5)', // rgba(255,235,0,0.5)
highlight: 'oklch(0.93 0.195089 103.2532 / 0.5)', // rgba(255,235,0,0.5)
note: 'oklch(48.8% 0.243 264.376 / 0.8)', // blue-700
tip: 'oklch(50.8% 0.118 165.612 / 0.8)', // emerald-700
important: 'oklch(49.6% 0.265 301.924 / 0.8)', // purple-700