@kawapress/plugin-shiki 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +34 -130
  2. package/README.zh-CN.md +35 -131
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -1,156 +1,60 @@
1
- <p align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo-dark.png">
4
- <img src="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo.png" alt="KawaPress" width="180">
5
- </picture>
6
- </p>
1
+ # @kawapress/plugin-shiki
7
2
 
8
- <h1 align="center">KawaPress</h1>
3
+ Code highlighting for KawaPress, with light and dark themes and optional Twoslash type hints.
9
4
 
10
- <p align="center">
11
- <strong>A Vue-first static site generator for documentation and content-focused websites.</strong>
12
- </p>
5
+ [![npm version](https://img.shields.io/npm/v/@kawapress/plugin-shiki?label=npm&color=42b883)](https://www.npmjs.com/package/@kawapress/plugin-shiki) · [简体中文](https://github.com/kawapress/kawapress/blob/main/packages/plugin-shiki/README.zh-CN.md)
13
6
 
14
- <p align="center">
15
- Write in Markdown. Develop with real SSR. Extend everything through public APIs.
16
- </p>
7
+ `@kawapress/plugin-shiki` is part of [KawaPress](https://github.com/kawapress/kawapress), a Vue-first static site generator.
17
8
 
18
- <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm version"></a>
20
- <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="documentation build"></a>
21
- <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT license"></a>
22
- <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 or newer">
23
- </p>
9
+ ## Features
24
10
 
25
- <p align="center">
26
- <a href="https://shenqingchuan.github.io/kawapress/en/">Documentation</a>
27
- ·
28
- <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.zh-CN.md">简体中文</a>
29
- </p>
11
+ - Highlights code at build time with [Shiki](https://shiki.style), so readers download no highlighter.
12
+ - Light and dark themes switch together with the site appearance.
13
+ - Line notations in comments: `[!code highlight]`, `[!code focus]`, `[!code ++]`, `[!code --]`, `[!code warning]` and `[!code error]`.
14
+ - Optional [Twoslash](https://twoslash.netlify.app): mark a block with `ts twoslash` and hover to see types.
30
15
 
31
- If you run into any problems while using KawaPress, please [open an issue](https://github.com/ShenQingchuan/kawapress/issues). Your feedback helps shape the project during its early development.
16
+ ## Install
32
17
 
33
- ## Why KawaPress?
18
+ This package is already included in `kawapress`. A site that uses `kawapress/nagi` has it, so there is nothing to install.
34
19
 
35
- KawaPress turns Markdown into pre-rendered Vue websites. It keeps the familiar simplicity of a documentation generator while giving themes and plugins the same public extension points used by the official experience.
36
-
37
- - **Real SSR during development** — every initial request is server-rendered, so SSR-only problems appear before build or deployment.
38
- - **A complete default experience** — the built-in nagi (凪) preset includes responsive documentation layouts, dark mode, local search, syntax highlighting, Twoslash, code groups, multilingual navigation, and more.
39
- - **Vue from end to end** — Markdown becomes Vue components, Vue Router handles navigation, and regular Vue SFCs fit naturally into content.
40
- - **AI-ready output** — nagi generates page-level Markdown, locale-aware `llms.txt` and `llms-full.txt`, plus built-in copy actions.
41
- - **One extension model** — Generator Plugins, Runtime Plugins, and Presets cover build-time behavior, the Vue runtime, themes, and reusable product setups without private theme hooks.
42
-
43
- KawaPress is an independent project. It is not a VitePress fork or a drop-in replacement, and it intentionally does not use VitePress configuration.
44
-
45
- ## Quick Start
46
-
47
- You need [Node.js](https://nodejs.org/) 22.12 or newer.
48
-
49
- Create a new site with the scaffolder:
20
+ Install it yourself only when you build a site without the nagi preset.
50
21
 
51
22
  ```sh
52
- npm create kawapress@latest my-kawapress-site
53
- cd my-kawapress-site
54
- npm run dev
23
+ npm install --save-dev @kawapress/plugin-shiki
55
24
  ```
56
25
 
57
- `pnpm create kawapress my-kawapress-site` and `yarn create kawapress my-kawapress-site` do the same thing. The scaffolder asks for a site title and a default language, and can install dependencies for you.
58
-
59
- If you would rather see every file from the start, set the site up by hand:
60
-
61
- ```sh
62
- mkdir my-kawapress-site
63
- cd my-kawapress-site
64
- pnpm init
65
- pnpm add --save-dev kawapress
66
- ```
26
+ `pnpm add --save-dev @kawapress/plugin-shiki` and `yarn add --dev @kawapress/plugin-shiki` work too.
67
27
 
68
- Create `kawapress.config.ts`:
28
+ ## Usage
69
29
 
70
30
  ```ts
71
- import { nagi } from 'kawapress/nagi'
72
-
73
- export default nagi({
74
- title: 'My Docs',
31
+ import shikiPlugin from '@kawapress/plugin-shiki'
32
+ import { defineConfig } from 'kawapress'
33
+
34
+ export default defineConfig({
35
+ plugins: [
36
+ shikiPlugin({
37
+ themes: { light: 'github-light', dark: 'github-dark' },
38
+ twoslash: true,
39
+ }),
40
+ ],
75
41
  })
76
42
  ```
77
43
 
78
- Create `index.md`:
79
-
80
- ```md
81
- ---
82
- layout: home
83
- title: My Docs
84
- ---
85
-
86
- # My Docs
87
-
88
- Welcome to my KawaPress site.
89
- ```
90
-
91
- Start the development server:
92
-
93
- ```sh
94
- pnpm exec kawapress dev
95
- ```
96
-
97
- Build static files into `dist`:
98
-
99
- ```sh
100
- pnpm exec kawapress build
101
- ```
102
-
103
- The deployed output is static and does not require a Node.js server. npm and Yarn commands are available in the [Getting Started guide](https://shenqingchuan.github.io/kawapress/en/guide/getting-started).
44
+ ## Options
104
45
 
105
- > If your site directly imports Vue APIs or Vue components, also install `vue` as a development dependency.
106
-
107
- ## What You Get
108
-
109
- | Area | Included capability |
46
+ | Option | Description |
110
47
  | --- | --- |
111
- | Authoring | Markdown, frontmatter, Vue in Markdown, file-based routing, data loaders |
112
- | Rendering | Shared development/build SSR semantics, hydration, Vue Router navigation |
113
- | Documentation UI | nagi layouts, responsive sidebar, page outline, dark mode, i18n |
114
- | Content | Shiki, Twoslash, code groups, code copy, containers, GitHub alerts |
115
- | Discovery | Lazy local search and locale-aware navigation |
116
- | AI consumption | Page `.md`, `llms.txt`, `llms-full.txt`, copy actions |
117
- | Styling | UnoCSS integration with sensible nagi defaults |
118
-
119
- The `kawapress` package includes nagi and its official plugins. A basic site only needs this one package; advanced users can compose the individual `@kawapress/*` packages directly.
120
-
121
- ## Extension Model
122
-
123
- KawaPress keeps extension boundaries explicit:
124
-
125
- - a **Generator Plugin** extends configuration, Markdown, page data, Vite, and build artifacts;
126
- - a **Runtime Plugin** extends the real Vue App and Vue Router in both SSR and the browser;
127
- - a **Preset** combines configuration and plugins into a ready-to-use experience such as nagi.
128
-
129
- A logical plugin is installed once and can provide both generator and runtime behavior. Learn more in the [Plugin System guide](https://shenqingchuan.github.io/kawapress/en/guide/plugin-system).
48
+ | `theme` | One Shiki theme for both appearances. Default `github-light`. |
49
+ | `themes` | A `{ light, dark }` pair. Use it instead of `theme`. |
50
+ | `langs` | Languages to load. A common set is loaded by default. |
51
+ | `transformers` | Extra Shiki transformers. |
52
+ | `twoslash` | `true`, or Twoslash options, to turn on type hints for `ts twoslash` blocks. |
130
53
 
131
54
  ## Documentation
132
55
 
133
- - [Getting Started](https://shenqingchuan.github.io/kawapress/en/guide/getting-started)
134
- - [What is KawaPress?](https://shenqingchuan.github.io/kawapress/en/guide/what-is-kawapress)
135
- - [Markdown Extensions](https://shenqingchuan.github.io/kawapress/en/guide/markdown-extensions)
136
- - [Internationalization](https://shenqingchuan.github.io/kawapress/en/guide/internationalization)
137
- - [Plugin System](https://shenqingchuan.github.io/kawapress/en/guide/plugin-system)
138
- - [Theme Customization](https://shenqingchuan.github.io/kawapress/en/guide/theme-customization)
139
-
140
- ## Contributing
141
-
142
- Issues and pull requests are welcome. For a large feature, please open an issue first so the direction can be agreed on before implementation.
143
-
144
- ```sh
145
- pnpm install
146
- pnpm lint
147
- pnpm typecheck
148
- pnpm test
149
- pnpm build
150
- ```
151
-
152
- KawaPress uses Node.js 22.12 or newer and pnpm 11.22.0 for repository development.
56
+ [Documentation](https://kawapress.dev/en/guide/markdown-extensions) · [Report a problem](https://github.com/kawapress/kawapress/issues)
153
57
 
154
58
  ## License
155
59
 
156
- [MIT](https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE) © KawaPress contributors
60
+ [MIT](https://github.com/kawapress/kawapress/blob/main/LICENSE) © KawaPress contributors
package/README.zh-CN.md CHANGED
@@ -1,156 +1,60 @@
1
- <p align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo-dark.png">
4
- <img src="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo.png" alt="KawaPress" width="180">
5
- </picture>
6
- </p>
1
+ # @kawapress/plugin-shiki
7
2
 
8
- <h1 align="center">KawaPress</h1>
3
+ KawaPress 的代码高亮,支持浅色和深色主题,以及可选的 Twoslash 类型提示。
9
4
 
10
- <p align="center">
11
- <strong>以 Vue 为核心,面向文档与内容型网站的静态站点生成器。</strong>
12
- </p>
5
+ [![npm version](https://img.shields.io/npm/v/@kawapress/plugin-shiki?label=npm&color=42b883)](https://www.npmjs.com/package/@kawapress/plugin-shiki) · [English](https://github.com/kawapress/kawapress/blob/main/packages/plugin-shiki/README.md)
13
6
 
14
- <p align="center">
15
- 用 Markdown 安心写作,在真实 SSR 中开发,通过公开能力自由扩展。
16
- </p>
7
+ `@kawapress/plugin-shiki` 是 [KawaPress](https://github.com/kawapress/kawapress) 的一部分。KawaPress 是一个以 Vue 为核心的静态站点生成器。
17
8
 
18
- <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm 版本"></a>
20
- <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="文档构建状态"></a>
21
- <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT 许可"></a>
22
- <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 或更高版本">
23
- </p>
9
+ ## 特性
24
10
 
25
- <p align="center">
26
- <a href="https://shenqingchuan.github.io/kawapress/">中文文档</a>
27
- ·
28
- <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.md">English</a>
29
- </p>
11
+ - 构建时用 [Shiki](https://shiki.style) 完成高亮,读者不需要下载高亮器。
12
+ - 浅色和深色主题随站点外观一起切换。
13
+ - 用注释标记行:`[!code highlight]`、`[!code focus]`、`[!code ++]`、`[!code --]`、`[!code warning]` 和 `[!code error]`。
14
+ - 可选的 [Twoslash](https://twoslash.netlify.app):在代码块上写 `ts twoslash`,把鼠标移上去就能看到类型。
30
15
 
31
- 使用 KawaPress 时遇到任何问题,欢迎到 [提交 Issue](https://github.com/ShenQingchuan/kawapress/issues) 反馈,一起参与本项目的早期建设。
16
+ ## 安装
32
17
 
33
- ## 为什么选择 KawaPress?
18
+ 这个包已经包含在 `kawapress` 里。使用 `kawapress/nagi` 的站点自带它,不需要再安装。
34
19
 
35
- KawaPress 会把 Markdown 编译成预渲染的 Vue 网站。它保留了文档生成器简单、轻快的写作方式,同时让官方主题和第三方扩展使用完全相同的公开能力。
36
-
37
- - **开发时也执行真实 SSR**:每次首次请求都会在服务端渲染。只在 SSR 中出现的问题,不必等到构建或上线后才发现。
38
- - **默认体验完整**:内置 nagi(凪)预设,包含响应式文档布局、深浅色模式、本地搜索、代码高亮、Twoslash、代码组和多语言导航等常用能力。
39
- - **从头到尾使用 Vue**:Markdown 会变成 Vue 组件,页面跳转交给 Vue Router;需要交互时,也可以自然地使用普通 Vue SFC。
40
- - **面向 AI 的文档产物**:nagi 默认生成每页 `.md`、各语言的 `llms.txt` 与 `llms-full.txt`,并提供复制正文和链接的操作。
41
- - **统一的扩展模型**:Generator Plugin、Runtime Plugin 与 Preset 分别覆盖生成阶段、Vue 运行时和能力组合,不依赖主题私有入口。
42
-
43
- KawaPress 是一个独立项目,不是 VitePress 的分支或配置兼容层,也不能直接使用 VitePress 配置。
44
-
45
- ## 快速开始
46
-
47
- 请先准备 [Node.js](https://nodejs.org/) 22.12 或更高版本。
48
-
49
- 用脚手架创建新站点:
20
+ 只有不使用 nagi 预设搭建站点时,才需要单独安装它。
50
21
 
51
22
  ```sh
52
- npm create kawapress@latest my-kawapress-site
53
- cd my-kawapress-site
54
- npm run dev
23
+ npm install --save-dev @kawapress/plugin-shiki
55
24
  ```
56
25
 
57
- `pnpm create kawapress my-kawapress-site` 和 `yarn create kawapress my-kawapress-site` 的作用完全一样。脚手架会询问站点标题和默认语言,也可以顺便帮你安装依赖。
58
-
59
- 如果你更想从零看清每个文件,可以手动创建:
60
-
61
- ```sh
62
- mkdir my-kawapress-site
63
- cd my-kawapress-site
64
- pnpm init
65
- pnpm add --save-dev kawapress
66
- ```
26
+ 也可以用 `pnpm add --save-dev @kawapress/plugin-shiki` 或 `yarn add --dev @kawapress/plugin-shiki`。
67
27
 
68
- 创建 `kawapress.config.ts`:
28
+ ## 使用
69
29
 
70
30
  ```ts
71
- import { nagi } from 'kawapress/nagi'
72
-
73
- export default nagi({
74
- title: 'My Docs',
31
+ import shikiPlugin from '@kawapress/plugin-shiki'
32
+ import { defineConfig } from 'kawapress'
33
+
34
+ export default defineConfig({
35
+ plugins: [
36
+ shikiPlugin({
37
+ themes: { light: 'github-light', dark: 'github-dark' },
38
+ twoslash: true,
39
+ }),
40
+ ],
75
41
  })
76
42
  ```
77
43
 
78
- 创建 `index.md`:
79
-
80
- ```md
81
- ---
82
- layout: home
83
- title: My Docs
84
- ---
85
-
86
- # My Docs
87
-
88
- 欢迎来到我的 KawaPress 站点。
89
- ```
90
-
91
- 启动开发服务器:
92
-
93
- ```sh
94
- pnpm exec kawapress dev
95
- ```
96
-
97
- 构建静态文件到 `dist`:
98
-
99
- ```sh
100
- pnpm exec kawapress build
101
- ```
102
-
103
- 部署产物是普通静态文件,不需要在服务器上继续运行 Node.js。npm 和 Yarn 的完整命令可以查看[快速开始](https://shenqingchuan.github.io/kawapress/guide/getting-started)。
44
+ ## 配置项
104
45
 
105
- > 如果站点会直接导入 Vue API 或 Vue 组件,还需要把 `vue` 安装为开发依赖。
106
-
107
- ## 默认包含什么?
108
-
109
- | 范围 | 内置能力 |
46
+ | 选项 | 说明 |
110
47
  | --- | --- |
111
- | 内容编写 | Markdown、Frontmatter、在 Markdown 中使用 Vue、文件路由、Data Loader |
112
- | 渲染 | 开发与构建共享 SSR 语义、Hydration、Vue Router 站内导航 |
113
- | 文档界面 | nagi 布局、响应式 Sidebar、本页目录、深浅色模式、多语言 |
114
- | 内容增强 | Shiki、Twoslash、代码组、代码复制、提示容器、GitHub Alerts |
115
- | 内容发现 | 按需加载的本地搜索与多语言导航 |
116
- | AI 读取 | 页面 `.md`、`llms.txt`、`llms-full.txt`、页面复制操作 |
117
- | 样式 | UnoCSS 集成与 nagi 默认配置 |
118
-
119
- `kawapress` 已经包含 nagi 和它使用的官方插件。普通文档站只需要安装这一个包;需要自行组合能力时,也可以直接使用独立的 `@kawapress/*` 包。
120
-
121
- ## 扩展模型
122
-
123
- KawaPress 把扩展边界分得很清楚:
124
-
125
- - **Generator Plugin** 负责配置、Markdown、页面数据、Vite 与构建产物;
126
- - **Runtime Plugin** 在 SSR 和浏览器中扩展真实的 Vue App 与 Vue Router;
127
- - **Preset** 把配置和一组插件组合成可以直接使用的产品体验,例如 nagi。
128
-
129
- 一个逻辑插件只需要安装一次,同时可以提供生成侧和运行侧能力。更多内容请查看[插件体系](https://shenqingchuan.github.io/kawapress/guide/plugin-system)。
48
+ | `theme` | 浅色和深色共用的一个 Shiki 主题,默认 `github-light`。 |
49
+ | `themes` | `{ light, dark }` 一对主题,用它就不要再写 `theme`。 |
50
+ | `langs` | 要加载的语言,默认加载一组常用语言。 |
51
+ | `transformers` | 额外的 Shiki 转换器。 |
52
+ | `twoslash` | `true` 或 Twoslash 选项,打开 `ts twoslash` 代码块的类型提示。 |
130
53
 
131
54
  ## 文档
132
55
 
133
- - [快速开始](https://shenqingchuan.github.io/kawapress/guide/getting-started)
134
- - [KawaPress 是什么?](https://shenqingchuan.github.io/kawapress/guide/what-is-kawapress)
135
- - [Markdown 语法扩展](https://shenqingchuan.github.io/kawapress/guide/markdown-extensions)
136
- - [国际化](https://shenqingchuan.github.io/kawapress/guide/internationalization)
137
- - [插件体系](https://shenqingchuan.github.io/kawapress/guide/plugin-system)
138
- - [主题定制](https://shenqingchuan.github.io/kawapress/guide/theme-customization)
139
-
140
- ## 参与贡献
141
-
142
- 欢迎提交 Issue 和 Pull Request。如果准备增加较大的功能,请先创建 Issue,把目标和方案聊清楚后再开始实现。
143
-
144
- ```sh
145
- pnpm install
146
- pnpm lint
147
- pnpm typecheck
148
- pnpm test
149
- pnpm build
150
- ```
151
-
152
- KawaPress 仓库使用 Node.js 22.12 或更高版本,以及 pnpm 11.22.0 进行开发。
56
+ [文档](https://kawapress.dev/guide/markdown-extensions) · [反馈问题](https://github.com/kawapress/kawapress/issues)
153
57
 
154
- ## 开源许可
58
+ ## 许可证
155
59
 
156
- [MIT](https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE) © KawaPress 贡献者
60
+ [MIT](https://github.com/kawapress/kawapress/blob/main/LICENSE) © KawaPress contributors
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@kawapress/plugin-shiki",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.1",
5
5
  "description": "Shiki and Twoslash plugin for KawaPress",
6
6
  "license": "MIT",
7
- "homepage": "https://shenqingchuan.github.io/kawapress/",
7
+ "homepage": "https://kawapress.dev/",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/ShenQingchuan/kawapress.git",
10
+ "url": "git+https://github.com/kawapress/kawapress.git",
11
11
  "directory": "packages/plugin-shiki"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/ShenQingchuan/kawapress/issues"
14
+ "url": "https://github.com/kawapress/kawapress/issues"
15
15
  },
16
16
  "exports": {
17
17
  ".": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vue": "^3.5.41",
46
- "kawapress": "0.1.0"
46
+ "kawapress": "^0.2.1"
47
47
  },
48
48
  "dependencies": {
49
49
  "@shikijs/transformers": "^4.4.3",