Skip to content

Commit

Permalink
fix: fix error about plugin-theme-data
Browse files Browse the repository at this point in the history
  • Loading branch information
recoluan committed Nov 22, 2023
1 parent b122524 commit 6c9377e
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 19 deletions.
6 changes: 4 additions & 2 deletions packages/@vuepress-reco/plugin-bulletin-popover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
"access": "public"
},
"dependencies": {
"@vuepress-reco/tailwindcss-config": "workspace:2.0.0-beta.68",
"@vuepress-reco/tailwindcss-config": "workspace:*",
"@vuepress/client": "2.0.0-rc.0",
"@vuepress/core": "2.0.0-rc.0",
"@vuepress/plugin-theme-data": "2.0.0-rc.0",
"@vuepress/shared": "2.0.0-rc.0",
"@vuepress/utils": "2.0.0-rc.0",
"vue": "^3.3.8"
"vue": "^3.3.8",
"vue-router": "^4.2.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ref, onMounted, computed } from 'vue'
import { useThemeLocaleData } from '@vuepress/plugin-theme-data/client'
import { useRouter } from 'vue-router'
import { resolveLocalePath } from '@vuepress/shared'
import { useThemeData, resolveThemeLocaleData } from '@vuepress/plugin-theme-data/client'

export function useVisible() {
const themeLocal = useThemeLocaleData()
Expand Down Expand Up @@ -66,3 +68,18 @@ export function useHandleNodes() {

return { bodyNodes, handleNode }
}

function useThemeLocaleData() {
const themeData = useThemeData()
const router = useRouter()
const routePath = computed(() => router.currentRoute.value.path)
const routeLocale = computed(() =>
resolveLocalePath(themeData.value.locales, routePath.value),
)

const themeLocaleData = computed(() =>
resolveThemeLocaleData(themeData.value, routeLocale.value),
)

return themeLocaleData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@vuepress/plugin-theme-data/client'
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ declare module '*.vue' {
const comp: ComponentOptions
export default comp
}

declare module '@vuepress/plugin-theme-data/client'
1 change: 1 addition & 0 deletions packages/@vuepress-reco/plugin-comments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@vuepress/client": "2.0.0-rc.0",
"@vuepress/core": "2.0.0-rc.0",
"@vuepress/plugin-theme-data": "2.0.0-rc.0",
"@vuepress/shared": "2.0.0-rc.0",
"@vuepress/utils": "2.0.0-rc.0",
"@waline/client": "^2.14.7",
"valine": "1.4.18",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineComponent, toRefs, h, watch } from 'vue'
import { useSiteLocaleData } from '@vuepress/client'
import { defineComponent, toRefs, h } from 'vue'
import { useRoute } from 'vue-router'

export default defineComponent({
Expand All @@ -18,21 +17,14 @@ export default defineComponent({
},

setup(props) {
const siteLocal = useSiteLocaleData()
const route = useRoute()
const { idVal, numStyle, flagTitle } = toRefs(props)

const getIdVal = (path) => {
return (
siteLocal.value.base.slice(0, siteLocal.value.base.length - 1) + path
)
}

return () =>
h(
'span',
{
'id': getIdVal(idVal.value || route.path),
'id': idVal.value || route.path,
'class': 'leancloud-visitors',
'data-flag-title': flagTitle.value,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { computed } from 'vue'
import { useThemeLocaleData } from '@vuepress/plugin-theme-data/client'
import { useRouter } from 'vue-router'
import { resolveLocalePath } from '@vuepress/shared'
import { useThemeData, resolveThemeLocaleData } from '@vuepress/plugin-theme-data/client'

export function useComment() {
const themeLocal = useThemeLocaleData()
Expand All @@ -25,3 +27,18 @@ export function useComment() {

return { solution, options }
}

function useThemeLocaleData() {
const themeData = useThemeData()
const router = useRouter()
const routePath = computed(() => router.currentRoute.value.path)
const routeLocale = computed(() =>
resolveLocalePath(themeData.value.locales, routePath.value),
)

const themeLocaleData = computed(() =>
resolveThemeLocaleData(themeData.value, routeLocale.value),
)

return themeLocaleData
}
7 changes: 7 additions & 0 deletions packages/@vuepress-reco/plugin-comments/src/types/shim.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module '*.vue' {
import type { ComponentOptions } from 'vue'
const comp: ComponentOptions
export default comp
}

declare module '@vuepress-reco/shared'
5 changes: 4 additions & 1 deletion packages/@vuepress-reco/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
},
"dependencies": {
"@vuepress/core": "2.0.0-rc.0",
"vue": "^3.3.8"
"@vuepress/shared": "2.0.0-rc.0",
"@vuepress/plugin-theme-data": "2.0.0-rc.0",
"vue": "^3.3.8",
"vue-router": "^4.2.5"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 2 additions & 0 deletions packages/@vuepress-reco/shared/src/types/shim.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ declare module '*.vue' {
const comp: ComponentOptions
export default comp
}

declare module '@vuepress/plugin-theme-data/client'
2 changes: 1 addition & 1 deletion packages/vuepress-theme-reco/src/node/recoTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const __dirname = getDirname(import.meta.url)

export const recoTheme = (themeConfig: Record<string, unknown>): Theme => {
const plugins = [
themeDataPlugin({ themeData: themeConfig }),
bulletinPopoverPlugin(),
commentsPlugin(),
pagePlugin(pages || [], themeConfig),
gitPlugin(),
themeDataPlugin({ themeData: themeConfig }),
searchPlugin({
hotKeys: [{ key: 's', ctrl: true }],
}),
Expand Down
14 changes: 13 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c9377e

Please sign in to comment.