Skip to content

Commit

Permalink
chore: add debug logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 17, 2025
1 parent 7c5daab commit 2d93dff
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
23 changes: 21 additions & 2 deletions themes/theme-default/src/client/components/VPPage.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
<script setup lang="ts">
import VPPageMeta from '@theme/VPPageMeta.vue'
import VPPageNav from '@theme/VPPageNav.vue'
import { watchImmediate } from '@vueuse/core'
import type { VNode } from 'vue'
import { Content } from 'vuepress/client'
import { h } from 'vue'
import { Content, useRoutePath } from 'vuepress/client'
defineSlots<{
'top'?: (props: Record<never, never>) => VNode | VNode[] | null
'bottom'?: (props: Record<never, never>) => VNode | VNode[] | null
'content-top'?: (props: Record<never, never>) => VNode | VNode[] | null
'content-bottom'?: (props: Record<never, never>) => VNode | VNode[] | null
}>()
watchImmediate(useRoutePath(), () => {
console.log('page route path changed')

Check warning on line 17 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 17 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
})
watchImmediate(
useRoutePath(),
() => {
console.log('page route path changed post')

Check warning on line 22 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 22 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
},
{ flush: 'post' },
)
const MarkdownContent = () => {

Check warning on line 27 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / build-check

Missing return type on function

Check warning on line 27 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / bundle-check

Missing return type on function
console.log('render')

Check warning on line 28 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 28 in themes/theme-default/src/client/components/VPPage.vue

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
return h(Content)
}
</script>

<template>
Expand All @@ -19,7 +38,7 @@ defineSlots<{
<div vp-content>
<slot name="content-top" />

<Content />
<MarkdownContent />

<slot name="content-bottom" />
</div>
Expand Down
14 changes: 13 additions & 1 deletion themes/theme-default/src/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { setupHeaders } from '@theme/useHeaders'
import { useScrollPromise } from '@theme/useScrollPromise'
import { setupSidebarItems } from '@theme/useSidebarItems'
import { hasGlobalComponent } from '@vuepress/helper/client'
import { defineClientConfig } from 'vuepress/client'
import { watchImmediate } from '@vueuse/core'
import { defineClientConfig, useRoutePath } from 'vuepress/client'
import { Badge } from './components/global/index.js'
import Layout from './layouts/Layout.vue'
import NotFound from './layouts/NotFound.vue'
Expand All @@ -28,6 +29,17 @@ export default defineClientConfig({
setupDarkMode()
setupHeaders()
setupSidebarItems()

watchImmediate(useRoutePath(), () => {
console.log('root route path changed')

Check warning on line 34 in themes/theme-default/src/client/config.ts

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 34 in themes/theme-default/src/client/config.ts

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
})
watchImmediate(
useRoutePath(),
() => {
console.log('root route path changed post')

Check warning on line 39 in themes/theme-default/src/client/config.ts

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 39 in themes/theme-default/src/client/config.ts

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
},
{ flush: 'post' },
)
},

layouts: {
Expand Down
19 changes: 18 additions & 1 deletion themes/theme-default/src/client/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import VPSidebar from '@theme/VPSidebar.vue'
import { useScrollPromise } from '@theme/useScrollPromise'
import { useSidebarItems } from '@theme/useSidebarItems'
import { useThemeLocaleData } from '@theme/useThemeData'
import { watchImmediate } from '@vueuse/core'
import type { VNode } from 'vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { usePageData, usePageFrontmatter, useRouter } from 'vuepress/client'
import {
usePageData,
usePageFrontmatter,
useRoutePath,
useRouter,
} from 'vuepress/client'
import type { DefaultThemePageFrontmatter } from '../../shared/index.js'
defineSlots<{
Expand Down Expand Up @@ -91,6 +97,17 @@ onUnmounted(() => {
unregisterRouterHook()
})
watchImmediate(useRoutePath(), () => {
console.log('layout route path changed')

Check warning on line 101 in themes/theme-default/src/client/layouts/Layout.vue

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 101 in themes/theme-default/src/client/layouts/Layout.vue

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
})
watchImmediate(
useRoutePath(),
() => {
console.log('layout route path changed post')

Check warning on line 106 in themes/theme-default/src/client/layouts/Layout.vue

View workflow job for this annotation

GitHub Actions / build-check

Unexpected console statement

Check warning on line 106 in themes/theme-default/src/client/layouts/Layout.vue

View workflow job for this annotation

GitHub Actions / bundle-check

Unexpected console statement
},
{ flush: 'post' },
)
// handle scrollBehavior with transition
const scrollPromise = useScrollPromise()
const onBeforeEnter = scrollPromise.resolve
Expand Down

0 comments on commit 2d93dff

Please sign in to comment.