Skip to content

Commit

Permalink
feat: search config
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 25, 2024
1 parent 6a53e63 commit a26254a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ export default defineAppConfig({
enable: true,
title: 'On This Page',
},
search: {
enable: true,
inAside: false,
},
},
});
7 changes: 4 additions & 3 deletions components/layout/Aside.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<UiScrollArea orientation="vertical" class="relative overflow-hidden h-full py-6 pr-6 text-sm" type="auto">
<LayoutHeaderNavMobile v-if="isMobile" class="border-b pb-2 mb-5" />
<ul v-if="useLevel" class="pb-4 border-b mb-1">
<LayoutSearchButton v-if="config.search.inAside" />
<ul v-if="config.aside.useLevel" class="pb-4 border-b mb-1">
<li v-for="link in navigation" :key="link.id">
<NuxtLink
:to="link._path"
Expand Down Expand Up @@ -29,12 +30,12 @@ defineProps<{ isMobile: boolean }>();
const { navDirFromPath } = useContentHelpers();
const { navigation } = useContent();
const { useLevel } = useConfig().value.aside;
const config = useConfig();
const tree = computed(() => {
const route = useRoute();
const path = route.path.split('/');
if (useLevel) {
if (config.value.aside.useLevel) {
const leveledPath = path.splice(0, 2).join('/');
const dir = navDirFromPath(leveledPath, navigation.value);
Expand Down
2 changes: 1 addition & 1 deletion components/layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LayoutMobileNav />
<LayoutHeaderNav class="hidden lg:flex flex-1" />
<div class="flex flex-1 justify-end gap-2">
<LayoutHeaderSearchButton />
<LayoutSearchButton v-if="!config.search.inAside" />
<div class="flex">
<DarkModeToggle v-if="config.header.darkModeToggle" />
<NuxtLink
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<UiButton
v-if="enable"
variant="outline"
class="pr-1.5 h-8 self-center w-full md:w-40 lg:w-64 rounded-lg"
class="pr-1.5 h-8 self-center w-full rounded-md"
:class="[inAside ? 'mb-4' : 'md:w-40 lg:w-64']"
@click="isOpen = true"
>
<span class="text-muted-foreground overflow-hidden mr-auto">
Expand All @@ -17,4 +19,5 @@

<script setup lang="ts">
const isOpen = ref(false);
const { enable, inAside } = useConfig().value.search;
</script>

0 comments on commit a26254a

Please sign in to comment.