Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nólëbase integrations #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
*.ttf binary
*.woff binary
*.woff2 binary

*.md linguist-vendored=false
*.md linguist-generated=false
*.md linguist-documentation=false
*.md linguist-detectable=true
52 changes: 43 additions & 9 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import Unocss from 'unocss/vite'
import { cwd } from 'node:process'
import { BiDirectionalLinks } from '@nolebase/markdown-it-bi-directional-links'
import { InlineLinkPreviewElementTransform } from '@nolebase/vitepress-plugin-inline-link-preview/markdown-it'
import MarkdownItFootnote from 'markdown-it-footnote'
import MarkdownItKbd from 'markdown-it-kbd-better'
import {
GitChangelog,
GitChangelogMarkdownSection,
} from '@nolebase/vitepress-plugin-git-changelog/vite'
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vitepress'
import type {
Expand All @@ -26,6 +32,7 @@ import { timeline } from './theme/markdown/timeline'
import { enConfig } from './locales/en'
import { zhConfig } from './locales/zh'
import { jaConfig } from './locales/ja'
import path from 'node:path'

const isProd = process.env.NODE_ENV === 'production'
const commitRef = process.env.COMMIT_REF?.slice(0, 8) || 'dev'
Expand Down Expand Up @@ -167,7 +174,7 @@ export default defineConfig({
srcExclude: [],
scrollOffset: 'header',
cleanUrls: true,
lastUpdated: true,
lastUpdated: false,
sitemap: {
hostname: 'https://yuanshen.site',
},
Expand Down Expand Up @@ -387,6 +394,9 @@ export default defineConfig({
allow: ['../..'],
},
},
optimizeDeps: {
exclude: ['@nolebase/vitepress-plugin-git-changelog/client'],
},
resolve: {
alias: [
{
Expand All @@ -397,9 +407,22 @@ export default defineConfig({
},
],
},
ssr: {
noExternal: [
// If there are other packages that need to be processed by Vite, you can add them here.
'@nolebase/vitepress-plugin-highlight-targeted-heading',
'@nolebase/vitepress-plugin-git-changelog',
],
},
plugins: [
// https://github.com/antfu/unocss
Unocss(),
GitChangelog({
// Fill in your repository URL here
repoURL: () =>
'https://github.com/https://github.com/kongying-tavern/docs',
}),
GitChangelogMarkdownSection(),
],
json: {
stringify: true,
Expand All @@ -410,6 +433,11 @@ export default defineConfig({
image: {
lazyLoading: true,
},
preConfig(md) {
// md.use(BiDirectionalLinks({
// dir: cwd(),
// }))
},
config(md) {
md.use(MarkdownItFootnote)
md.use(colorPreviewPlugin)
Expand All @@ -421,13 +449,19 @@ export default defineConfig({
md.use(obsidianImageSize)
md.use(figure)
md.use(timeline)
md.use(MarkdownItKbd, {
presets: [
{
name: 'icons',
},
],
})
md.use(InlineLinkPreviewElementTransform)
md.use(
BiDirectionalLinks({
dir: path.join(cwd(), '/src'),
}),
)
// md.use(MarkdownItKbd, {
// presets: [
// {
// name: 'icons',
// },
// ],
// })
},
},
})
2 changes: 1 addition & 1 deletion .vitepress/locales/en/docs-feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const docsFeedback: CustomConfig['docsFeedback'] = {
chooseIssues: 'Did you encounter these issues?',
translationIssue: 'Translation',
typosIssue: 'Typos/Punctuation',
ContentImgLinkIssue: 'Inaccurate Content, Image or Link',
contentImgLinkIssue: 'Inaccurate Content, Image or Link',
feedbackDetail: 'Details/Suggestions',
feedbackTip: 'Describe issues or suggestions here',
otherIssue: 'Other (specify below)',
Expand Down
7 changes: 7 additions & 0 deletions .vitepress/locales/en/gitlog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { CustomConfig } from '../types'

const gitlog: CustomConfig['gitlog'] = {
title: 'Contributors',
}

export default gitlog
2 changes: 2 additions & 0 deletions .vitepress/locales/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import DocsFeedback from './docs-feedback'
import Staff from './staff'
import Team from './team'
import Payment from './payment'
import gitlog from './gitlog'

export const enConfig: LocaleSpecificConfig<
DefaultTheme.Config & CustomConfig
Expand Down Expand Up @@ -48,6 +49,7 @@ export const enConfig: LocaleSpecificConfig<
staff: Staff,
team: Team,
payment: Payment,
gitlog: gitlog,

nav: baseHelper(Nav, C.LOCAL_BASE),
sidebar: baseHelper(Sidebar, C.LOCAL_BASE),
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/locales/ja/docs-feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const docsFeedback: CustomConfig['docsFeedback'] = {
chooseIssues: '以下の問題に遭遇しましたか?',
translationIssue: '翻訳の問題',
typosIssue: '誤字/句読点のエラー',
ContentImgLinkIssue:
contentImgLinkIssue:
'不正確なコンテンツ表現、画像読み込みエラー、またはリンクエラー',
feedbackDetail: '詳細/提案',
feedbackTip: 'ここに遭遇した問題や提案を説明してください',
Expand Down
7 changes: 7 additions & 0 deletions .vitepress/locales/ja/gitlog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { CustomConfig } from '../types'

const gitlog: CustomConfig['gitlog'] = {
title: '寄稿者',
}

export default gitlog
2 changes: 2 additions & 0 deletions .vitepress/locales/ja/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import DocsFeedback from './docs-feedback'
import Staff from './staff'
import Team from './team'
import Payment from './payment'
import gitlog from './gitlog'

export const jaConfig: LocaleSpecificConfig<
DefaultTheme.Config & CustomConfig
Expand Down Expand Up @@ -48,6 +49,7 @@ export const jaConfig: LocaleSpecificConfig<
staff: Staff,
team: Team,
payment: Payment,
gitlog: gitlog,

nav: baseHelper(Nav, C.LOCAL_BASE),
sidebar: baseHelper(Sidebar, C.LOCAL_BASE),
Expand Down
5 changes: 4 additions & 1 deletion .vitepress/locales/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface CustomConfig {
chooseIssues: string
translationIssue: string
typosIssue: string
ContentImgLinkIssue: string
contentImgLinkIssue: string
feedbackDetail: string
feedbackTip: string
otherIssue: string
Expand All @@ -87,6 +87,9 @@ export interface CustomConfig {
}[]
}
}
gitlog: {
title: string
}
}

export interface CustomConstant {
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/locales/zh/docs-feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const docsFeedback: CustomConfig['docsFeedback'] = {
chooseIssues: '是否遇到以下问题?',
translationIssue: '翻译问题',
typosIssue: '错别字/标点符号',
ContentImgLinkIssue: '文案表达不准确、图片加载失败或链接错误',
contentImgLinkIssue: '文案表达不准确、图片加载失败或链接错误',
feedbackDetail: '反馈内容/更多建议',
feedbackTip: '请详细描述你在使用文档过程中遇到的问题或优化建议',
otherIssue: '其他问题(请在反馈内容中具体描述)',
Expand Down
7 changes: 7 additions & 0 deletions .vitepress/locales/zh/gitlog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { CustomConfig } from '../types'

const gitlog: CustomConfig['gitlog'] = {
title: '贡献者',
}

export default gitlog
2 changes: 2 additions & 0 deletions .vitepress/locales/zh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import DocsFeedback from './docs-feedback'
import Staff from './staff'
import Team from './team'
import Payment from './payment'
import gitlog from './gitlog'

export const zhConfig: LocaleSpecificConfig<
DefaultTheme.Config & CustomConfig
Expand Down Expand Up @@ -48,6 +49,7 @@ export const zhConfig: LocaleSpecificConfig<
staff: Staff,
team: Team,
payment: Payment,
gitlog: gitlog,

nav: baseHelper(Nav, C.LOCAL_BASE),
sidebar: baseHelper(Sidebar, C.LOCAL_BASE),
Expand Down
18 changes: 0 additions & 18 deletions .vitepress/theme/apis/pageview.ts

This file was deleted.

7 changes: 4 additions & 3 deletions .vitepress/theme/components/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<script setup lang="ts">
import { withBase } from 'vitepress'
import { isLinkExternal, isRelativeLink } from '../utils'
import { computed, defineProps, withDefaults } from 'vue'
import { computed, withDefaults } from 'vue'

import '../styles/card.scss'

Expand Down Expand Up @@ -114,7 +114,7 @@ interface CardProps {
/**
* Card shadow
*
* 是否启用卡片阴影效果,默认启用
* 是否启用卡片阴影效果,默认不启用
*/
shadow?: boolean

Expand All @@ -134,7 +134,7 @@ const props = withDefaults(defineProps<CardProps>(), {
cover: '',
theme: 'normal',
hoverShadow: true,
shadow: true,
shadow: false,
})

const iconMap = {
Expand Down Expand Up @@ -210,3 +210,4 @@ const descText = computed(() => {
}
})
</script>
: { target: any; }: { target: any; }: { target: any; }: { target: any; }
28 changes: 24 additions & 4 deletions .vitepress/theme/components/DocInfo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<div class="doc-info">
<div class="doc-gitlog pb-6" v-if="gitlogIsVisible">
<h3 pt-6 mt-12 font-size-6>{{ theme.gitlog.title }}</h3>
<Contributors />
<Changelog />
</div>
<div class="doc-info" v-else>
<div class="doc-info-left">
{{ theme.lastUpdatedText }}
{{ dayjs(page.lastUpdated).format('YYYY-MM-DD') }}
Expand All @@ -21,13 +26,21 @@ import { useData, useRoute } from 'vitepress'
import { computed, ref, watch } from 'vue'
import dayjs from 'dayjs'
import { getPageInfo } from '../apis/getPageInfo'
import { pageview as PV } from '../apis/pageview'
import { usePageInfoStore } from '../stores/pageinfo'

const router = useRoute()
const { page, theme } = useData()
const { page, theme, frontmatter } = useData()
const pageinfo = usePageInfoStore()
const loading = ref(false)
const gitlogIsVisible = computed(() => {
if (frontmatter.value.gitlog === true) return true
// 默认仅在用户手册中展示
return (
frontmatter.value.gitlog !== false &&
frontmatter.value.layout == 'doc' &&
page.value.filePath.includes('manual')
)
})
const thumbText = computed(() => {
return pageinfo.currentPageinfo.good
? Number(pageinfo.currentPageinfo.good)
Expand All @@ -49,10 +62,16 @@ watch(
loading.value = false
},
)

updateData()
</script>

<style scoped>
<style lang="scss" scoped>
.doc-gitlog {
display: grid;
grid-row-gap: 26px;
}

.doc-info {
display: flex;
justify-content: space-between;
Expand All @@ -66,6 +85,7 @@ updateData()
fill: currentColor;
}
}

.doc-info-right {
justify-content: flex-start;
}
Expand Down
24 changes: 23 additions & 1 deletion .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import DocAside from './components/DocAside.vue'
import DocHeader from './components/DocHeader.vue'
import DocInfo from './components/DocInfo.vue'
import DocFeedback from './components/DocFeedback.vue'
import { NolebaseInlineLinkPreviewPlugin } from '@nolebase/vitepress-plugin-inline-link-preview/client'
import {
InjectionKey,
NolebaseGitChangelog,
NolebaseGitContributors,
} from '@nolebase/vitepress-plugin-git-changelog/client'

import type { Theme } from 'vitepress'

Expand All @@ -22,6 +28,8 @@ import './styles/main.css'
import './styles/ui.css'
import './styles/timeline.css'
import './styles/kbd.css'
import '@nolebase/vitepress-plugin-inline-link-preview/client/style.css'
import '@nolebase/vitepress-plugin-git-changelog/client/style.css'

const pinia = createPinia()

Expand All @@ -44,15 +52,29 @@ export default {
debug: false,
})
app.use(pinia)
app.use(NolebaseInlineLinkPreviewPlugin)

app.component('Link', Link)
app.component('Coins', Coins)
app.component('Card', Card)
app.component('LinkGrid', LinkGrid)
app.component('Badge', VPBadge)
app.component('Changelog', NolebaseGitChangelog)
app.component('Contributors', NolebaseGitContributors)

app.provide(InjectionKey, {
locales: {},
mapAuthors: [
{
name: 'Hyouka',
username: 'jiazengp',
mapByEmailAliases: ['[email protected]'],
},
],
})
},
setup() {
const route = useRoute()
const { lang } = useData()

onMounted(() => {
initZoom()
Expand Down
Loading
Loading