forked from withastro/starlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor collection helper to only return the schema (withastro#28)
- Loading branch information
Showing
2 changed files
with
23 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { defineDocsCollection } from 'starbook/schema'; | ||
import { defineCollection } from 'astro:content'; | ||
import { docsSchema } from 'starbook/schema'; | ||
|
||
export const collections = { | ||
docs: defineDocsCollection(), | ||
docs: defineCollection({ | ||
schema: docsSchema(), | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
import { defineCollection, z } from 'astro:content'; | ||
import { z } from 'astro:content'; | ||
|
||
export function defineDocsCollection() { | ||
return defineCollection({ | ||
schema: z.object({ | ||
/** The title of the current page. Required. */ | ||
title: z.string(), | ||
export function docsSchema() { | ||
return z.object({ | ||
/** The title of the current page. Required. */ | ||
title: z.string(), | ||
|
||
/** | ||
* A short description of the current page’s content. Optional, but recommended. | ||
* A good description is 150–160 characters long and outlines the key content | ||
* of the page in a clear and engaging way. | ||
*/ | ||
description: z.string().optional(), | ||
/** | ||
* A short description of the current page’s content. Optional, but recommended. | ||
* A good description is 150–160 characters long and outlines the key content | ||
* of the page in a clear and engaging way. | ||
*/ | ||
description: z.string().optional(), | ||
|
||
/** | ||
* Custom URL where a reader can edit this page. | ||
* Overrides the `editLink.baseUrl` global config if set. | ||
* | ||
* Can also be set to `false` to disable showing an edit link on this page. | ||
*/ | ||
editUrl: z | ||
.union([z.string().url(), z.boolean()]) | ||
.optional() | ||
.default(true), | ||
}), | ||
/** | ||
* Custom URL where a reader can edit this page. | ||
* Overrides the `editLink.baseUrl` global config if set. | ||
* | ||
* Can also be set to `false` to disable showing an edit link on this page. | ||
*/ | ||
editUrl: z.union([z.string().url(), z.boolean()]).optional().default(true), | ||
}); | ||
} |