Skip to content

Commit

Permalink
📃 docs: 文档更新
Browse files Browse the repository at this point in the history
  • Loading branch information
白云苍狗 committed Aug 29, 2024
1 parent ee5c0b9 commit 9184454
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish-theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
cp ./README_zh-CN.md ./packages/vitepress-theme-async
cp ./README.md ./packages/vitepress-theme-async
node ./scripts/publish.mjs
yarn config:build
rm ./packages/vitepress-theme-async/config/index.ts ./packages/vitepress-theme-async/config/languages.ts ./packages/vitepress-theme-async/config/less.ts
rm -r ./packages/vitepress-theme-async/plugin
yarn config:build
rm ./packages/vitepress-theme-async/config/index.ts ./packages/vitepress-theme-async/config/languages.ts ./packages/vitepress-theme-async/config/less.ts
rm -r ./packages/vitepress-theme-async/plugin
zip -r vitepress-theme-async ./packages/vitepress-theme-async
env:
RELEASE_VERSION: ${{ github.ref }}
Expand Down
18 changes: 18 additions & 0 deletions docs/.vitepress/assets/log.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
{
"large_version": "v0.0.x",
"children": [
{
"version": "0.0.14",
"date": "2024-08-29",
"logs": [
{
"type": "feat",
"text": "滚动动画"
},
{
"type": "feat",
"text": "文章和友链破图设置"
},
{
"type": "feat",
"text": "远程加载友链列表"
}
]
},
{
"version": "0.0.13",
"date": "2024-08-26",
Expand Down
21 changes: 20 additions & 1 deletion docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export default defineConfig({
});
```

## 文章详情页
## 文章详情

这里是一些关于文章相关配置合集。

Expand Down Expand Up @@ -460,6 +460,25 @@ export default defineConfig({
<<< @/../packages/vitepress-theme-async/types/theme.d.ts#NoticeOutdateConfig
:::

### 破图配置

您可以添加图片加载失败时显示默认图片,通过配置 `errorImg` 字段使用。

::: code-group

```ts [config.ts]
export default defineConfig({
themeConfig: {
errorImg: { // [!code ++]
... // [!code ++]
} // [!code ++]
}
});
```

<<< @/../packages/vitepress-theme-async/types/theme.d.ts#ErrorImgConfig
:::

## 其他配置

### 固定按钮
Expand Down
14 changes: 14 additions & 0 deletions docs/guide/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ export default defineConfig({

:::

links 也支持通过 api 加载数据,返回数据格式需要与定义类型保持一致。

```ts [config.ts]
import links from './links' // [!code --]
export default defineConfig({
themeConfig: {
links: links, // [!code --]
links: 'https://api.xx.xx' // [!code ++]
},
});
```


## 关于页 About

`layout``about` 时,根据配置生成页面。
Expand Down
4 changes: 3 additions & 1 deletion packages/vitepress-theme-async/components/TrmPageLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import TrmDividerTitle from "./global/TrmDividerTitle.vue";
import TrmCardLink from "./global/TrmCardLink.vue";
import { data } from '../composables/links.data'
import { useTheme } from "../composables";
import { withBase } from "vitepress";
let i = 0;
const theme = useTheme();
const flink = theme.value.errorImg?.flink ? withBase(theme.value.errorImg?.flink) : undefined
</script>
<template>
<slot name="links-before" />
Expand Down Expand Up @@ -40,7 +42,7 @@ const theme = useTheme();
<TrmDividerTitle :title="$t('title.links')" :index="`0${++i}`" />
</div>
<div v-for="item in data" :key="item.url" class="col-lg-6">
<TrmCardLink v-bind="item" :err="theme.errorImg?.flink" />
<TrmCardLink v-bind="item" :err="flink" />
</div>
</div>
<slot name="links-after" />
Expand Down
7 changes: 4 additions & 3 deletions packages/vitepress-theme-async/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ import TrmPageArchive from "../components/TrmPageArchive.vue";
import TrmPageAbout from "../components/TrmPageAbout.vue";
import TrmPageLinks from "../components/TrmPageLinks.vue";
import errimg from '../assets/404.jpg'
import { useData, useRoute } from "vitepress";
import { useData, useRoute, withBase } from "vitepress";
import { initJustifiedGallery, initPictures, initPostErrorImg, initScrollAnimation } from "../utils/client";
import { onMounted, onUnmounted, watch, WatchStopHandle, nextTick } from "vue";
const route = useRoute()
const { frontmatter, page, theme } = useData<AsyncThemeConfig>();
const eimg = theme.value.errorImg?.postPage ? withBase(theme.value.errorImg?.postPage) : errimg
let watcher: WatchStopHandle
onMounted(() => {
watcher = watch(
() => route.path,
() => {
const flag = initPostErrorImg(theme.value.errorImg?.postPage || errimg)
const flag = initPostErrorImg(eimg)
nextTick(() => {
initScrollAnimation()
!flag && initPostErrorImg(theme.value.errorImg?.postPage || errimg)
!flag && initPostErrorImg(eimg)
if (theme.value.plugin?.plugins?.flickrJustifiedGallery) {
initJustifiedGallery(theme.value.plugin?.thirdPartyProvider + theme.value.plugin.plugins.flickrJustifiedGallery)
}
Expand Down

0 comments on commit 9184454

Please sign in to comment.