Skip to content

Commit

Permalink
docs: refine documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed May 30, 2024
1 parent 2dfee53 commit 4868cd9
Show file tree
Hide file tree
Showing 35 changed files with 491 additions and 518 deletions.
25 changes: 9 additions & 16 deletions docs/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ export default defineConfig({
{ text: '图片上传', link: '/guide/backend/img-upload.md' },
{ text: '账户与多站点', link: '/guide/backend/multi-site.md' },
{ text: '解析相对路径', link: '/guide/backend/relative-path.md' },
{ text: '如何配置界面', link: '/guide/backend/fe-control.md' },
{ text: 'English (i18n)', link: '/guide/frontend/i18n.md' },
],
},
{
Expand All @@ -116,24 +114,21 @@ export default defineConfig({
items: [
{ text: '表情包', link: '/guide/frontend/emoticons.md' },
{ text: '浏览量统计', link: '/guide/frontend/pv.md' },
{ text: 'Latex', link: '/guide/frontend/latex.md' },
{ text: 'LaTeX', link: '/guide/frontend/latex.md' },
{ text: '图片灯箱', link: '/guide/frontend/lightbox.md' },
{ text: '图片懒加载', link: '/guide/frontend/img-lazy-load.md' },
{ text: 'IP 属地', link: '/guide/frontend/ip-region.md' },
{ text: '精简版本', link: '/guide/frontend/artalk-lite.md' },
{ text: '置入博客', link: '/guide/frontend/import-blog.md' },
{ text: '置入框架', link: '/guide/frontend/import-framework.md' },
{ text: '前端 API', link: '/develop/fe-api.md' },
{ text: '多语言', link: '/guide/frontend/i18n.md' },
{ text: '开发文档', link: '/develop/index.md' },
],
},
{
text: '配置文档',
collapsed: true,
collapsed: false,
items: [
{ text: '环境变量', link: '/guide/env.md' },
{ text: '后端配置', link: '/guide/backend/config.md' },
{ text: '前端配置', link: '/guide/frontend/config.md' },
{ text: '配置文件', link: '/guide/backend/config.md' },
{ text: '界面配置', link: '/guide/frontend/config.md' },
],
},
{
Expand Down Expand Up @@ -163,21 +158,19 @@ export default defineConfig({
text: '开发文档',
items: [
{ text: '开发说明', link: '/develop/index.md' },
{ text: '置入博客', link: '/develop/import-blog.md' },
{ text: '置入框架', link: '/develop/import-framework.md' },
{ text: '前端 API', link: '/develop/fe-api.md' },
{ text: '前端 Event', link: '/develop/event.md' },
{ text: '插件开发', link: '/develop/plugs.md' },
{
text: '🔬 HTTP API',
text: 'HTTP API',
link: 'https://artalk.js.org/http-api.html',
},
{
text: '📖 Contributing Guide',
text: '贡献指南',
link: 'https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md',
},
{
text: '🔖 Code of Conduct',
link: 'https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md',
},
],
},
],
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/develop/event.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Event
# Frontend Event

## 基本事件

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/develop/fe-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const artalk = Artalk.init({

评论列表加载完毕后会触发 `list-loaded` 事件。

注:前端界面配置可能会被覆盖,详情见:[在后端控制前端](../guide/backend/fe-control.md)
> 注:前端界面配置可能会被覆盖,详情见:[界面配置](../guide/frontend/config.md)
## 释放资源 `destroy`

Expand Down
185 changes: 185 additions & 0 deletions docs/docs/develop/import-blog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# 置入博客

## 通用方法

<<< @/code/quick-start/cdn.html

#### 什么时候执行 `Artalk.init({})`

- 可以在任意位置引入 JS 和 CSS 资源,但需确保 JS 引入在执行 `Artalk.init({})` 前。
- 执行 `Artalk.init({ el: '#artalk' })` 前需要确保 `<div id="artalk"></div>` 在页面当中。

## Hugo

创建模板文件 `/主题目录/layouts/partials/comment/artalk.html`

<!-- prettier-ignore-start -->

```html
<link href="/lib/artalk/Artalk.css" rel="stylesheet" />
<script src="/lib/artalk/Artalk.js"></script>

<!-- Artalk -->
<div id="Comments"></div>

<script>
Artalk.init({
el: '#Comments',
pageKey: '{{ .Permalink }}',
pageTitle: '{{ .Title }}',
server: '{{ $.Site.Params.artalk.server }}',
site: '{{ $.Site.Params.artalk.site }}',
// ...你的其他配置
})
</script>
```

<!-- prettier-ignore-end -->

文章页模板 `/主题目录/layouts/_default/single.html` 合适的位置添加:

```html
<div class="article-comments">{{- partial "comment/artalk" . -}}</div>
```

修改 Hugo 配置文件:

::: code-group

```toml [config.toml]
[params.artalk]
server = 'https://artalk.example.org'
site = '你的站点名'
```

```yaml [config.yaml]
params:
artalk:
server: 'https://artalk.example.org'
site: '你的站点名'
```
:::
## Hexo
创建 `/主题目录/layout/comment/artalk.ejs`:

```html
<link href="/lib/artalk/Artalk.css" rel="stylesheet" />
<script src="/lib/artalk/Artalk.js"></script>
<div id="Comments"></div>
<script>
var artalk = Artalk.init({
el: '#Comments',
pageKey: '<%= page.permalink %>',
pageTitle: '<%= page.title %>',
server: '<%= theme.comment.artalk.server %>',
site: '<%= theme.comment.artalk.site %>',
})
</script>
```

修改文章模板文件,例如 `/主题目录/layout/post.ejs`:

```html
<div class="article-comments"><%- partial('comment/artalk') %></div>
```

编辑主题配置 `/主题目录/_config.example.yml`:

```yaml
comment:
artalk:
site: '你的站点名'
server: 'https://artalk.example.org'
```

::: tip

NexT 主题可以安装 [Hexo NexT 主题的 Artalk 插件](https://github.com/leirock/hexo-next-artalk)

:::

## VitePress

可参考:[@ArtalkJS/Artalk:/docs/.vitepress](https://github.com/ArtalkJS/Artalk/tree/master/docs/.vitepress)

- `config.ts` 修改配置引入 CSS 资源
- `theme/Artalk.vue` 创建组件
- `theme/index.ts` 注册组件
- `theme/Layout.vue` 使用组件

注:SSG 应用需通过 `import()` 函数异步引入 Artalk,否则会导致构建失败。

```ts
import('artalk').then(({ default: Artalk }) => {
artalk = Artalk.init({
//...
})
})
```

参考文件:[.vitepress/theme/Artalk.vue](https://github.com/ArtalkJS/Artalk/blob/master/docs/.vitepress/theme/Artalk.vue)

## VuePress

(待补充)

::: tip 提示

可参考:[置入框架](./import-framework.md)

:::

## Typecho

修改主题文章模板文件,例如 `post.php`:

```php
<!-- CSS -->
<link href="/lib/artalk/Artalk.css" rel="stylesheet">
<!-- JS -->
<script src="/lib/artalk/Artalk.js"></script>
<!-- Artalk -->
<div id="Comments"></div>
<script>
Artalk.init({
el: '#Comments',
pageKey: '<?php $this->permalink() ?>',
pageTitle: '<?php $this->title() ?>',
server: '<后端地址>',
site: '<?php $this->options->title() ?>',
// ...你的其他配置
})
</script>
```

## WordPress

修改主题文章模板文件,例如 `single.php`:

```php
<!-- CSS -->
<link href="/lib/artalk/Artalk.css" rel="stylesheet">
<!-- JS -->
<script src="/lib/artalk/Artalk.js"></script>
<!-- Artalk -->
<div id="Comments"></div>
<script>
Artalk.init({
el: '#Comments',
pageKey: '<?= addslashes(get_permalink()) ?>',
pageTitle: '<?= addslashes(get_the_title()) ?>',
server: '<后端地址>',
site: '<?= addslashes(get_bloginfo('name')) ?>',
// ...你的其他配置
})
</script>
```
Loading

0 comments on commit 4868cd9

Please sign in to comment.