1- import { readdirSync } from 'node:fs'
2- import { join } from 'node:path'
3- import { defineCollection , z } from 'astro:content'
4- import { glob } from 'astro/loaders'
1+ import { glob } from "astro/loaders" ;
2+ import { defineCollection , z } from "astro:content" ;
3+ import { readdirSync } from "node:fs" ;
4+ import { join } from "node:path" ;
55
66export const docSchema = z . object ( {
77 title : z . string ( ) ,
88 description : z . string ( ) ,
99 permalink : z . string ( ) . optional ( ) ,
1010 icon : z . string ( ) . optional ( ) ,
11- visibility : z . array ( z . enum ( [ ' navbar' ] ) ) . default ( [ ] ) ,
12- } )
11+ visibility : z . array ( z . enum ( [ " navbar" ] ) ) . default ( [ ] ) ,
12+ } ) ;
1313
1414export const docDefaultSchema = z . object ( {
1515 label : z . string ( ) ,
1616 description : z . string ( ) ,
1717 permalink : z . string ( ) ,
1818 icon : z . string ( ) . optional ( ) ,
1919 collection : z . array ( z . string ( ) ) ,
20- } )
20+ } ) ;
2121
2222export const docDefaults = defineCollection ( {
2323 loader : glob ( {
24- pattern : ' **/_default.{md,mdx}' ,
25- base : ' ./content/docs' ,
24+ pattern : " **/_default.{md,mdx}" ,
25+ base : " ./content/docs" ,
2626 } ) ,
2727 schema : docDefaultSchema ,
28- } )
28+ } ) ;
2929
3030export const deepDocDefaults = defineCollection ( {
3131 loader : glob ( {
32- pattern : ' **/*_default.{md,mdx}' ,
33- base : ' ./content/docs' ,
32+ pattern : " **/*_default.{md,mdx}" ,
33+ base : " ./content/docs" ,
3434 } ) ,
3535 schema : docDefaultSchema ,
36- } )
36+ } ) ;
3737
3838export const docs = defineCollection ( {
3939 loader : glob ( {
40- pattern : ' **/[^_]*.{md,mdx}' ,
41- base : ' ./content/docs' ,
40+ pattern : " **/[^_]*.{md,mdx}" ,
41+ base : " ./content/docs" ,
4242 } ) ,
4343 schema : docSchema ,
44- } )
44+ } ) ;
4545
4646const pages = defineCollection ( {
4747 loader : glob ( {
48- pattern : [ ' **/*.{md,mdx}' , 'blog/index.{md,mdx}' , ' !docs/**/*' ] ,
49- base : ' ./content' ,
48+ pattern : [ " **/*.{md,mdx}" , " !docs/**/*" ] ,
49+ base : " ./content" ,
5050 } ) ,
5151 schema : z . object ( {
5252 layout : z . string ( ) . optional ( ) ,
5353 title : z . string ( ) . optional ( ) ,
5454 description : z . string ( ) . optional ( ) ,
5555 } ) ,
56- } )
56+ } ) ;
5757
58- const directories = readdirSync ( join ( process . cwd ( ) , ' content/docs' ) )
58+ const directories = readdirSync ( join ( process . cwd ( ) , " content/docs" ) ) ;
5959const documentations = Object . fromEntries (
6060 directories . map ( ( directory ) => [
6161 directory ,
6262 defineCollection ( {
6363 loader : glob ( {
64- pattern : ' **/[^_]*.{md,mdx}' ,
64+ pattern : " **/[^_]*.{md,mdx}" ,
6565 base : `./content/docs/${ directory } ` ,
6666 } ) ,
6767 schema : docSchema ,
6868 } ) ,
6969 ] ) ,
70- )
70+ ) ;
7171
7272const blog = defineCollection ( {
7373 loader : glob ( {
74- pattern : [ ' **/*.{md,mdx}' , '!blog/index.{md,mdx}' ] ,
75- base : ' ./content/blog' ,
74+ pattern : [ " **/*.{md,mdx}" ] ,
75+ base : " ./content/blog" ,
7676 } ) ,
7777 schema : z . object ( {
7878 title : z . string ( ) ,
@@ -84,7 +84,7 @@ const blog = defineCollection({
8484 draft : z . boolean ( ) . optional ( ) . default ( false ) ,
8585 publishedAt : z . string ( ) . optional ( ) ,
8686 } ) ,
87- } )
87+ } ) ;
8888
8989export const collections = {
9090 pages,
@@ -93,4 +93,4 @@ export const collections = {
9393 docs,
9494 blog,
9595 ...documentations ,
96- }
96+ } ;
0 commit comments