chore(docs): dynamically import webvitals
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
import { Handle, Position, VueFlow, useVueFlow } from '@vue-flow/core'
|
import { Handle, Position, VueFlow, useVueFlow } from '@vue-flow/core'
|
||||||
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
|
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
|
||||||
import { Background } from '@vue-flow/background'
|
import { Background } from '@vue-flow/background'
|
||||||
import { onBeforeUnmount } from 'vue'
|
|
||||||
import Heart from '~icons/mdi/heart'
|
import Heart from '~icons/mdi/heart'
|
||||||
|
|
||||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||||
@@ -57,7 +56,7 @@ const initialEdges = [
|
|||||||
style: { strokeWidth: 4, stroke: '#0ea5e9' },
|
style: { strokeWidth: 4, stroke: '#0ea5e9' },
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const { getNodes, findNode, setEdges, updateNodeInternals, dimensions, nodes } = useVueFlow({
|
const { getNodes, findNode, setEdges, updateNodeInternals, dimensions, onNodesInitialized } = useVueFlow({
|
||||||
nodes: [
|
nodes: [
|
||||||
{ id: 'intro', type: 'box', position: { x: 0, y: 0 } },
|
{ id: 'intro', type: 'box', position: { x: 0, y: 0 } },
|
||||||
{ id: 'examples', type: 'box', position: { x: -50, y: 400 } },
|
{ id: 'examples', type: 'box', position: { x: -50, y: 400 } },
|
||||||
@@ -181,9 +180,11 @@ const setElements = useDebounceFn(
|
|||||||
() => (currentBreakpoint.value === null ? 5 : 50),
|
() => (currentBreakpoint.value === null ? 5 : 50),
|
||||||
)
|
)
|
||||||
|
|
||||||
const { stop } = useResizeObserver(el, setElements)
|
onNodesInitialized(() => {
|
||||||
|
setElements()
|
||||||
|
})
|
||||||
|
|
||||||
onBeforeUnmount(stop)
|
useResizeObserver(el, setElements)
|
||||||
|
|
||||||
function scrollTo() {
|
function scrollTo() {
|
||||||
const el = document.getElementById('acknowledgement')
|
const el = document.getElementById('acknowledgement')
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
import { watch } from 'vue'
|
import { watch } from 'vue'
|
||||||
import { useRoute } from 'vitepress'
|
import { useRoute } from 'vitepress'
|
||||||
import DefaultTheme from 'vitepress/theme'
|
import DefaultTheme from 'vitepress/theme'
|
||||||
import { webVitals } from '../../plugins/vercel-web-vitals-api'
|
|
||||||
|
|
||||||
const { Layout: ParentLayout } = DefaultTheme
|
const { Layout: ParentLayout } = DefaultTheme
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
webVitals({ analyticsId: '__ANALYTICS_ID__', debug: false })
|
if (!import.meta.env.DEV) {
|
||||||
|
const { webVitals } = await import('../../plugins/vercel-web-vitals-api')
|
||||||
|
webVitals({ analyticsId: '__ANALYTICS_ID__', debug: false })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
Reference in New Issue
Block a user