Skip to content

Commit b0a8941

Browse files
docs: 添加 vercel 部署, obsidian 链接设置, giscus 评论功能的说明 (#48)
Co-authored-by: Neko Ayaka <neko@ayaka.moe>
1 parent f0c47f4 commit b0a8941

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,107 @@ Nólëbase 知识库使用 VitePress 静态生成器来驱动和生成静态页
316316
317317
请参照 VitePress 官方文档的[部署 VitePress 站点](https://vitepress.dev/zh/guide/deploy)页面文档所介绍的内容,通过主流的静态网站托管服务来部署自己的 Nólëbase 知识库。
318318

319+
##### Vercel 部署
320+
Vercel 部署很简单, 在 Vercel 中选择项目后, 修改构建的「Output directory」为 `.vitepress/dist` 就行了(默认是 `./dist`
321+
322+
如果你选择了用 Vercel 部署,可以关闭 Netlify 自带的 CI/CD builder workflow.
323+
324+
在 GitHub 仓库页面 -> Actions -> Netlify 对应的 workflow -> 右上角 3 个点 -> Disable workflow
325+
326+
## Obsidian 的设置
327+
### 关于图片链接问题
328+
如果你的 Markdown 中的图片链接没有在当前文件所在目录下,会解析出错,无法在 Vitepress 中正确渲染。如果没有这个问题,你可以跳过下面的内容
329+
330+
解决方法: 推荐的 Obsidian Setting => Files and links 设置如下
331+
- New link format => Relative path to file
332+
- Use `[[Wikilinks]]` => False
333+
- Default location for new attachments => In subfolder under current folder
334+
- Subfolder name => assets
335+
336+
这么做有几个好处
337+
- 保持兼容性的 Markdown : 可以让文档也能在 Github 中被正确渲染( Github 无法解析`[[双链]]`
338+
- 方便迁移文件和图片,你只需要把图片文件夹和 Markdown 文件一起复制就行(如果是全部汇总在某个文件夹下,以后复制比较麻烦)
339+
340+
> [!TIP]
341+
> 对于已有的笔记和图片链接,你可以考虑使用 Obsidian 插件[obsidian-link-converter](https://github.com/ozntel/obsidian-link-converter) 来帮你做自动的转换 `[[wikilink]]` 为 relative_path 的 Markdown link
342+
343+
## 开启 Giscus 评论功能
344+
Giscus 利用了 [GitHub Discussions](https://docs.github.com/en/discussions) 实现的评论系统,让访客借助 GitHub 在你的网站上留下评论!(你的github仓库必须是公开的才能使用 giscus)。
345+
346+
具体配置方法
347+
- 第一步,访问 Giscus 网站: https://giscus.app/zh-CN, 参考网站上的说明,一步步操作,最终你会得到 Giscus 的配置信息
348+
- 第二步,在 Nólëbase 仓库下执行,
349+
350+
```sh
351+
pnpm add -D vitepress-plugin-comment-with-giscus
352+
```
353+
354+
- 第三步,在 `./vitepress/theme/index.ts` 中添加 Giscus 插件代码(注意更改部分内容为你第一步得到的配置信息哦),演示如下,具体请参考[插件文档](https://github.com/T-miracle/vitepress-plugin-comment-with-giscus)
355+
356+
```ts
357+
import type { Theme } from 'vitepress'
358+
import DefaultTheme from 'vitepress/theme'
359+
import giscusTalk from 'vitepress-plugin-comment-with-giscus';
360+
import { useData, useRoute } from 'vitepress';
361+
import { toRefs } from "vue";
362+
import { h } from 'vue'
363+
// 略过.......
364+
365+
const ExtendedTheme: Theme = {
366+
// 略过.......
367+
enhanceApp({ app }) {
368+
// 略过.......
369+
},
370+
// 开始!添加下面的内容
371+
setup() {
372+
// Get frontmatter and route
373+
const { frontmatter } = toRefs(useData());
374+
const route = useRoute();
375+
376+
// Obtain configuration from: https://giscus.app/
377+
giscusTalk({
378+
repo: 'your github repositor',
379+
repoId: 'your repo Id',
380+
category: 'your category', // default: `General`
381+
categoryId: 'your category id',
382+
mapping: 'pathname', // default: `pathname`
383+
inputPosition: 'top', // default: `top`
384+
lang: 'zh-CN', // default: `zh-CN`
385+
// i18n setting (Note: This configuration will override the default language set by lang)
386+
// Configured as an object with key-value pairs inside:
387+
// [your i18n configuration name]: [corresponds to the language pack name in Giscus]
388+
locales: {
389+
'zh-Hans': 'zh-CN',
390+
'en-US': 'en'
391+
},
392+
homePageShowComment: false, // Whether to display the comment area on the homepage, the default is false
393+
lightTheme: 'light', // default: `light`
394+
darkTheme: 'transparent_dark', // default: `transparent_dark`
395+
// ...
396+
}, {
397+
frontmatter, route
398+
},
399+
// Whether to activate the comment area on all pages.
400+
// The default is true, which means enabled, this parameter can be ignored;
401+
// If it is false, it means it is not enabled.
402+
// You can use `comment: true` preface to enable it separately on the page.
403+
true
404+
);
405+
}
406+
// 结束!好了,上面的内容就是你需要修改的部分,其他维持原样就好啦
407+
}
408+
409+
export default ExtendedTheme
410+
```
411+
412+
413+
在 Markdown 文件上添加下面的属性,可以决定是否在当前文章中开启评论
414+
```
415+
---
416+
comment: true
417+
---
418+
```
419+
319420
## 知识库编写须知
320421

321422
由于很多时候需要重复编排和调整文档的结构和注解以适应和满足使用者的阅读习惯或是文档叙述的内容需求,以及说明使用的 API 的版本号和破坏性更新说明,可能会导致在以上或是更多外部因素的影响下导致文档结构混乱不一,查询造成困难,或是索引和快速查阅文档的时候需要花费大量的时间和精力去了解文章结构和内容,以下提出了一个较为完善(任需商议)的知识库结构、使用规范的提案。

笔记/index.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,104 @@ Nólëbase 知识库使用 VitePress 静态生成器来驱动和生成静态页
296296
> 让我们把精力放在写作上吧!❤️
297297
298298
请参照 VitePress 官方文档的[部署 VitePress 站点](https://vitepress.dev/zh/guide/deploy)页面文档所介绍的内容,通过主流的静态网站托管服务来部署自己的 Nólëbase 知识库。
299+
300+
##### Vercel 部署
301+
Vercel 部署很简单, 在 Vercel 中选择项目后, 修改构建的「Output directory」为 `.vitepress/dist` 就行了(默认是 `./dist`
302+
303+
如果你选择了用 Vercel 部署,可以关闭 Netlify 自带的 CI/CD builder workflow.
304+
305+
在 GitHub 仓库页面 -> Actions -> Netlify 对应的 workflow -> 右上角 3 个点 -> Disable workflow
306+
307+
## Obsidian 的设置
308+
### 关于图片链接问题
309+
如果你的 Markdown 中的图片链接没有在当前文件所在目录下,会解析出错,无法在 Vitepress 中正确渲染。如果没有这个问题,你可以跳过下面的内容
310+
311+
解决方法: 推荐的 Obsidian Setting => Files and links 设置如下
312+
- New link format => Relative path to file
313+
- Use `[[Wikilinks]]` => False
314+
- Default location for new attachments => In subfolder under current folder
315+
- Subfolder name => assets
316+
317+
这么做有几个好处
318+
- 保持兼容性的 Markdown : 可以让文档也能在 Github 中被正确渲染( Github 无法解析`[[双链]]`
319+
- 方便迁移文件和图片,你只需要把图片文件夹和 Markdown 文件一起复制就行(如果是全部汇总在某个文件夹下,以后复制比较麻烦)
320+
321+
> [!TIP]
322+
> 对于已有的笔记和图片链接,你可以考虑使用 Obsidian 插件[obsidian-link-converter](https://github.com/ozntel/obsidian-link-converter) 来帮你做自动的转换 `[[wikilink]]` 为 relative_path 的 Markdown link
323+
324+
## 开启 Giscus 评论功能
325+
Giscus 利用了 [GitHub Discussions](https://docs.github.com/en/discussions) 实现的评论系统,让访客借助 GitHub 在你的网站上留下评论!(你的github仓库必须是公开的才能使用 giscus)。
326+
327+
具体配置方法
328+
- 第一步,访问 Giscus 网站: https://giscus.app/zh-CN, 参考网站上的说明,一步步操作,最终你会得到 Giscus 的配置信息
329+
- 第二步,在 Nólëbase 仓库下执行,
330+
331+
```sh
332+
pnpm add -D vitepress-plugin-comment-with-giscus
333+
```
334+
335+
- 第三步,在 `./vitepress/theme/index.ts` 中添加 Giscus 插件代码(注意更改部分内容为你第一步得到的配置信息哦),演示如下,具体请参考[插件文档](https://github.com/T-miracle/vitepress-plugin-comment-with-giscus)
336+
337+
```ts
338+
import type { Theme } from 'vitepress'
339+
import DefaultTheme from 'vitepress/theme'
340+
import giscusTalk from 'vitepress-plugin-comment-with-giscus';
341+
import { useData, useRoute } from 'vitepress';
342+
import { toRefs } from "vue";
343+
import { h } from 'vue'
344+
// 略过.......
345+
346+
const ExtendedTheme: Theme = {
347+
// 略过.......
348+
enhanceApp({ app }) {
349+
// 略过.......
350+
},
351+
// 开始!添加下面的内容
352+
setup() {
353+
// Get frontmatter and route
354+
const { frontmatter } = toRefs(useData());
355+
const route = useRoute();
356+
357+
// Obtain configuration from: https://giscus.app/
358+
giscusTalk({
359+
repo: 'your github repositor',
360+
repoId: 'your repo Id',
361+
category: 'your category', // default: `General`
362+
categoryId: 'your category id',
363+
mapping: 'pathname', // default: `pathname`
364+
inputPosition: 'top', // default: `top`
365+
lang: 'zh-CN', // default: `zh-CN`
366+
// i18n setting (Note: This configuration will override the default language set by lang)
367+
// Configured as an object with key-value pairs inside:
368+
// [your i18n configuration name]: [corresponds to the language pack name in Giscus]
369+
locales: {
370+
'zh-Hans': 'zh-CN',
371+
'en-US': 'en'
372+
},
373+
homePageShowComment: false, // Whether to display the comment area on the homepage, the default is false
374+
lightTheme: 'light', // default: `light`
375+
darkTheme: 'transparent_dark', // default: `transparent_dark`
376+
// ...
377+
}, {
378+
frontmatter, route
379+
},
380+
// Whether to activate the comment area on all pages.
381+
// The default is true, which means enabled, this parameter can be ignored;
382+
// If it is false, it means it is not enabled.
383+
// You can use `comment: true` preface to enable it separately on the page.
384+
true
385+
);
386+
}
387+
// 结束!好了,上面的内容就是你需要修改的部分,其他维持原样就好啦
388+
}
389+
390+
export default ExtendedTheme
391+
```
392+
393+
394+
在 Markdown 文件上添加下面的属性,可以决定是否在当前文章中开启评论
395+
```
396+
---
397+
comment: true
398+
---
399+
```

0 commit comments

Comments
 (0)