From a4b5f4a5e316e0b8c4d5f2522114c45feb2329ae Mon Sep 17 00:00:00 2001 From: Jeffrey Esquivel S Date: Sun, 21 Apr 2024 21:32:51 -0600 Subject: [PATCH 1/3] Fix 'ReferenceError: document is not defined' error Make sure 'document' is only accessed on a browser context. --- .vitepress/theme/components/header/Header.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vitepress/theme/components/header/Header.vue b/.vitepress/theme/components/header/Header.vue index 49c1d08..8527cdb 100644 --- a/.vitepress/theme/components/header/Header.vue +++ b/.vitepress/theme/components/header/Header.vue @@ -2,6 +2,7 @@ import { breakpointsTailwind, useMagicKeys } from '@vueuse/core' import { watch } from 'vue' import { ContextMenu } from 'radix-vue/namespaced' +import { inBrowser } from 'vitepress' import { getIconSnippet } from '../../composables/icons/icon' const SearchBox = defineAsyncComponent(() => import('vitepress/dist/client/theme-default/components/VPLocalSearchBox.vue')) @@ -29,7 +30,7 @@ const { copy, isSupported } = useClipboard({ copiedDuring: 3000 }) const showEnvironment = __BUILD_ENVIRONMENT__ !== 'production' -const isMac = document.documentElement.classList.contains('mac') +const isMac = inBrowser ? document.documentElement.classList.contains('mac') : false