mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
chore: add toc theme config option and update theme guides
This commit is contained in:
parent
94f9998f45
commit
eb82a7d2f2
14 changed files with 121 additions and 15 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)';
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
1
src/types/index.d.ts
vendored
1
src/types/index.d.ts
vendored
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue