Skip to content

Commit

Permalink
fix: place aside in app.vue to avoid navigation shifts
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Jul 23, 2024
1 parent 7b38e62 commit 4d8b89b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 48 deletions.
19 changes: 17 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
<template>
<NuxtLoadingIndicator :color="false" class="z-100 bg-primary80" />
<ConfigProvider :use-id="useIdFunction">
<NuxtLoadingIndicator :color="false" class="z-100 bg-primary80" />
<NuxtPage />
<LayoutHeader />

<div v-if="$route.path !== '/'" class="border-b min-h-screen">
<div
class="px-4 md:px-8 flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] md:gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10"
:class="[config.main.padded && 'container']"
>
<aside class="fixed top-[102px] md:top-[60px] z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block overflow-y-auto">
<LayoutAside :is-mobile="false" />
</aside>
<NuxtPage />
</div>
</div>
<NuxtPage v-else />

<Toaster />
<LayoutFooter />
</ConfigProvider>
</template>

Expand Down
2 changes: 1 addition & 1 deletion components/layout/Aside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ const tree = computed(() => {
return navigation.value;
});
const path = useRoute().path;
const path = computed(() => useRoute().path);
</script>
74 changes: 31 additions & 43 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,52 +1,40 @@
<template>
<LayoutHeader />
<div class="border-b min-h-screen">
<div
class="px-4 md:px-8 flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] md:gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10"
:class="[config.main.padded && 'container']"
>
<aside class="fixed top-[102px] md:top-[60px] z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block overflow-y-auto">
<LayoutAside :is-mobile="false" />
</aside>
<main class="relative py-6" :class="[config.toc.enable && 'lg:gap-10 lg:py-8 lg:grid lg:grid-cols-[1fr_200px]']">
<div class="mx-auto w-full min-w-0">
<LayoutBreadcrumb v-if="page?.body && config.main.breadCrumb" class="mb-4" />
<main class="relative py-6" :class="[config.toc.enable && 'lg:gap-10 lg:py-8 lg:grid lg:grid-cols-[1fr_200px]']">
<div class="mx-auto w-full min-w-0">
<LayoutBreadcrumb v-if="page?.body && config.main.breadCrumb" class="mb-4" />
<div v-if="config.main.showTitle" class="space-y-2 mb-6">
<ProseH1>
{{ page?.title }}
</ProseH1>
<p class="text-lg text-muted-foreground">
{{ page?.description }}
</p>
</div>
<div v-if="config.main.showTitle" class="space-y-2 mb-6">
<ProseH1>
{{ page?.title }}
</ProseH1>
<p class="text-lg text-muted-foreground">
{{ page?.description }}
</p>
</div>
<Alert
v-if="!page?.body || page?.body?.children?.length === 0"
title="Empty Page"
icon="lucide:circle-x"
>
Start writing in <ProseCodeInline>content/{{ page?._file }}</ProseCodeInline> to see this page taking shape.
</Alert>
<Alert
v-if="!page?.body || page?.body?.children?.length === 0"
title="Empty Page"
icon="lucide:circle-x"
>
Start writing in <ProseCodeInline>content/{{ page?._file }}</ProseCodeInline> to see this page taking shape.
</Alert>
<ContentRenderer
v-else
:key="page._id"
:value="page"
class="docs-content"
/>
<ContentRenderer
v-else
:key="page._id"
:value="page"
class="docs-content"
/>
<LayoutPrevNext />
</div>
<div v-if="config.toc.enable" class="hidden text-sm lg:block">
<div class="sticky top-[90px] h-[calc(100vh-3.5rem)] overflow-hidden">
<LayoutToc :is-small="false" />
</div>
</div>
</main>
<LayoutPrevNext />
</div>
</div>
<LayoutFooter />
<div v-if="config.toc.enable" class="hidden text-sm lg:block">
<div class="sticky top-[90px] h-[calc(100vh-3.5rem)] overflow-hidden">
<LayoutToc :is-small="false" />
</div>
</div>
</main>
</template>
<script setup lang="ts">
Expand Down
2 changes: 0 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<template>
<LayoutHeader />
<div
class="px-4 md:px-8 py-6"
:class="[config.main.padded && 'container']"
Expand All @@ -9,7 +8,6 @@
:value="page"
/>
</div>
<LayoutFooter />
</template>

<script setup lang="ts">
Expand Down

0 comments on commit 4d8b89b

Please sign in to comment.