Skip to content

Commit

Permalink
chore: progress commit
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jul 4, 2023
1 parent e3c855f commit fccb211
Show file tree
Hide file tree
Showing 204 changed files with 7,517 additions and 500 deletions.
13 changes: 0 additions & 13 deletions docs/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions docs/.npmrc

This file was deleted.

1 change: 1 addition & 0 deletions docs/.nuxtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typescript.includeWorkspace=true
37 changes: 0 additions & 37 deletions docs/app.config.ts

This file was deleted.

53 changes: 48 additions & 5 deletions docs/app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,50 @@
<script setup lang="ts">
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation())
provide('navigation', navigation)
// Head
useServerHead({
link: [
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' },
{ rel: 'icon', type: 'image/svg+xml', href: '/icon.svg' },
],
htmlAttrs: {
lang: 'en',
},
bodyAttrs: {
class: 'antialiased font-sans text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-900',
},
})
useServerSeoMeta({
viewport: {
width: 'device-width',
initialScale: '1',
maximumScale: '1',
},
themeColor: [
{ content: '#18181b', media: '(prefers-color-scheme: dark)' },
{ content: 'white', media: '(prefers-color-scheme: light)' },
],
ogImage: '/social-preview.jpg',
twitterImage: '/social-preview.jpg',
twitterCard: 'summary_large_image',
})
</script>

<template>
<AppLayout>
<SeoKit />
<OgImageScreenshot />
<NuxtPage />
</AppLayout>
<div>
<Header />

<UContainer>
<NuxtPage />
</UContainer>

<ClientOnly>
<DocsSearch />
</ClientOnly>

<UNotifications />
</div>
</template>
49 changes: 49 additions & 0 deletions docs/app/router.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { RouterConfig } from '@nuxt/schema'

function findHashPosition(hash): { el: any; behavior: ScrollBehavior; top: number } {
const el = document.querySelector(hash)
// vue-router does not incorporate scroll-margin-top on its own.
if (el) {
const top = Number.parseFloat(getComputedStyle(el).scrollMarginTop)

return {
el: hash,
behavior: 'smooth',
top,
}
}
}

// https://router.vuejs.org/api/#routeroptions
export default <RouterConfig>{
scrollBehavior(to, from, savedPosition) {
const nuxtApp = useNuxtApp()

// If history back
if (savedPosition) {
// Handle Suspense resolution
return new Promise((resolve) => {
nuxtApp.hooks.hookOnce('page:finish', () => {
setTimeout(() => resolve(savedPosition), 50)
})
})
}

// Scroll to heading on click
if (to.hash) {
return new Promise((resolve) => {
if (to.path === from.path) {
setTimeout(() => resolve(findHashPosition(to.hash)), 50)
}
else {
nuxtApp.hooks.hookOnce('page:finish', () => {
setTimeout(() => resolve(findHashPosition(to.hash)), 50)
})
}
})
}

// Scroll to top of window
return { top: 0 }
},
}
Loading

0 comments on commit fccb211

Please sign in to comment.