Skip to content

Commit

Permalink
feat: toc container
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 May 23, 2024
1 parent 180f18c commit a0695b4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion components/content/ProseCode.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<UiCard class="[&:not(:first-child)]:mt-5 mb-5 overflow-hidden">
<div v-if="filename" class="p-3 border-b flex">
<div v-if="filename" class="p-3 border-b flex text-sm font-mono">
{{ filename }}
<span class="ml-auto mr-1">
<Transition name="fade" mode="out-in">
Expand Down
4 changes: 2 additions & 2 deletions components/layout/Aside.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<aside
class="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block overflow-y-auto"
class="fixed top-16 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block overflow-y-auto"
>
<UiScrollArea orientation="vertical" class="relative overflow-hidden h-full py-6 pr-6 lg:py-8" type="auto">
<UiScrollArea orientation="vertical" class="relative overflow-hidden h-full py-6 pr-6" type="auto">
Aside
</UiScrollArea>
</aside>
Expand Down
11 changes: 1 addition & 10 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<template>
<div class="min-h-screen">
<LayoutHeader />
<div class="border-b">
<div class="container 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">
<LayoutAside />
<div class="py-6 lg:py-8">
<slot />
</div>
</div>
</div>
<LayoutFooter />
<slot />
</div>
</template>
64 changes: 40 additions & 24 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
<template>
<main>
<LayoutBreadcrumb class="mb-4" />
<div class="space-y-2 mb-6">
<ProseH1>
{{ page?.title }}
</ProseH1>
<p class="text-lg text-muted-foreground">
{{ page?.description }}
</p>
<LayoutHeader />
<div class="border-b">
<div class="container 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">
<LayoutAside />
<main class="relative py-6 lg:gap-10 lg:py-8 xl:grid xl:grid-cols-[1fr_250px]">
<div class="mx-auto w-full min-w-0">
<LayoutBreadcrumb class="mb-4" />
<div 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>
<ContentRenderer
v-else
:key="page._id"
:value="page"
class="docs-content"
/>
<LayoutPrevNext />
</div>
<div class="hidden text-sm xl:block">
<div class="sticky top-16 -mt-10 h-[calc(100vh-3.5rem)] overflow-hidden pt-6">
<div class="w-10">
TOC
</div>
</div>
</div>
</main>
</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>
<ContentRenderer
v-else
:key="page._id"
:value="page"
class="docs-content"
/>
<LayoutPrevNext />
</main>
</div>
<LayoutFooter />
</template>

<script setup lang="ts">
Expand Down

0 comments on commit a0695b4

Please sign in to comment.