This commit is contained in:
2025-11-25 20:07:01 +08:00
parent db55d8fd83
commit df1ac48813
3 changed files with 4 additions and 6 deletions

View File

@@ -3,7 +3,6 @@ import { defineCollection, z } from 'astro:content';
import { glob, file } from 'astro/loaders'; // 不适用于旧版 API
const docs = defineCollection({
// loader: glob({ pattern: '**/*.md', base: './src/data/blogs' }),
loader: glob({ pattern: '**/[^_]*.md', base: './src/data/docs' }),
schema: z.object({
title: z.string().optional(),
@@ -17,6 +16,7 @@ const docs = defineCollection({
* 在侧边栏隐藏该文档
*/
hideInMenu: z.boolean().optional().default(false),
order: z.number().optional().default(0),
}),
});

View File

@@ -52,7 +52,9 @@ const {
{
showMenu && (
<aside class='w-64 min-w-64 h-full flex flex-col'>
<Menu items={menu!} client:only basename={basename} />
<slot name='menu'>
<Menu items={menu!} client:only basename={basename} />
</slot>
</aside>
)
}

View File

@@ -17,7 +17,6 @@ type Post = {
// 2. 对于你的模板,你可以直接从 prop 获取条目
const { post } = Astro.props as { post: Post };
const { Content } = await render(post);
console.log('post', post);
const showMenu = post.data?.showMenu;
const staticPaths = await getStaticPaths();
const menu = staticPaths.map((item) => item.data);
@@ -25,7 +24,4 @@ const menu = staticPaths.map((item) => item.data);
<Main showMenu={showMenu} menu={menu} basename={basename}>
<Content />
<div slot='menu'>
<div>sdfsdfsdf sfsdfsdf</div>
</div>
</Main>