diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 4fa16b8..f6915a1 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -54,7 +54,7 @@ export default defineConfig({ { text: 'Quick Start', link: 'quick-start' }, { text: 'Define Collections', link: 'define-collections' }, { text: 'Using Collections', link: 'using-collections' }, - { text: 'Velite Schemas', link: 'velite-shemas' } + { text: 'Velite Schemas', link: 'velite-schemas' } ] }, { diff --git a/docs/guide/asset-handling.md b/docs/guide/asset-handling.md index 8d37fb1..ef62274 100644 --- a/docs/guide/asset-handling.md +++ b/docs/guide/asset-handling.md @@ -4,10 +4,10 @@ This documentation is still being written. Please check back later. ## Refer -- [File Field](./velite-schemas.md#s-file) -- [Image Field](./velite-schemas.md#s-image) -- [Markdown Field](./velite-schemas.md#s-markdown) -- [MDX Field](./velite-schemas.md#s-mdx) +- [File Field](velite-schemas.md#s-file) +- [Image Field](velite-schemas.md#s-image) +- [Markdown Field](velite-schemas.md#s-markdown) +- [MDX Field](velite-schemas.md#s-mdx) ## Uploading Assets diff --git a/docs/guide/define-collections.md b/docs/guide/define-collections.md index 0267852..8b42bed 100644 --- a/docs/guide/define-collections.md +++ b/docs/guide/define-collections.md @@ -99,7 +99,7 @@ const posts = defineCollection({ The schema is usually a `ZodObject`, validating the shape of the content item. But it can be any valid Zod schema. ::: -For more useful schemas, I recommend that you use [Velite extended schemas `s`](velite-shemas.md): +For more useful schemas, I recommend that you use [Velite extended schemas `s`](velite-schemas.md): - `s.slug()`: validate slug format, unique in posts collection. - `s.isodate()`: format date string to ISO date string. @@ -131,7 +131,7 @@ const posts = defineCollection({ }) ``` -For more information about Velite extended field schema, see [Velite Schemas](velite-shemas.md). +For more information about Velite extended field schema, see [Velite Schemas](velite-schemas.md). ## Schema Transform (Computed Fields) @@ -191,8 +191,8 @@ The `content` field will be transformed from markdown to html, and the result wi #### Reference -- [`s.markdown(options)`](velite-shemas.md#s-markdown-options) -- [`s.mdx(options)`](velite-shemas.md#s-mdx-options) +- [`s.markdown(options)`](velite-schemas.md#s-markdown-options) +- [`s.mdx(options)`](velite-schemas.md#s-mdx-options) ### Metadata @@ -208,7 +208,7 @@ const posts = defineCollection({ #### Reference -- [`s.metadata()`](velite-shemas.md#s-metadata) +- [`s.metadata()`](velite-schemas.md#s-metadata) ### Excerpt @@ -225,5 +225,5 @@ const posts = defineCollection({ #### Reference -- [`s.summary()`](velite-shemas.md#s-summary) -- [`s.excerpt()`](velite-shemas.md#s-excerpt) +- [`s.summary()`](velite-schemas.md#s-summary) +- [`s.excerpt()`](velite-schemas.md#s-excerpt) diff --git a/docs/guide/introduction.md b/docs/guide/introduction.md index 4f0d1f1..638b56e 100644 --- a/docs/guide/introduction.md +++ b/docs/guide/introduction.md @@ -1,9 +1,11 @@ # Introduction ::: warning + 🚧 this documentation is not yet complete currently. but the functionality is mostly stable, although there is still a possibility of significant changes being made. However, I have provided some [examples](https://github.com/zce/velite/tree/main/examples) for your consideration. + ::: ## What is Velite? @@ -13,8 +15,6 @@ Velite is a tool for building type-safe data layer, turn Markdown / MDX, YAML, J ![Velite Workflow](/assets/flow-dark.svg#dark 'Velite Workflow') ![Velite Workflow](/assets/flow.svg#light 'Velite Workflow') -Inspired by [Contentlayer](https://contentlayer.dev), based on [Zod](https://zod.dev) and [Unified](https://unifiedjs.com), and powered by [ESBuild](https://esbuild.github.io). - ### Naming Origin "Velite" comes from the English word "elite". @@ -25,11 +25,11 @@ Inspired by [Contentlayer](https://contentlayer.dev), based on [Zod](https://zod - **Easy to use**: Move your contents into `content` folder, define collections schema, run `velite`, then use the output data in your application. - **Type-safe**: Contents schema validation by [Zod](https://zod.dev), and generate type inference for TypeScript. -- **Framework Agnostic**: JSON & Entry & DTS output, out of the box support for React, Vue, Svelte, Solid, etc. +- **Framework Agnostic**: JSON & Entry & DTS output, out of the box support for any JavaScript framework or library. - **Light-weight**: Choose more native APIs instead of bloated NPM modules, less runtime dependencies, so it is fast and efficiently. - **Still powerful**: Built-in Markdown / MDX, YAML, JSON support, relative files & images processing, schema validation, etc. - **Configurable**: Both input and output directories can be customized, and support for custom loaders, hooks, etc. -- **Extensible**: Support any file types by custom loaders, Custom field validation and transform by custom schema, and any output formats by hooks +- **Extensible**: Support any file types by custom loaders, Custom field validation and transform by custom schema, and any output formats by hooks. Check out our detailed [Why Velite](#why-velite) to learn more about what makes Velite special. ✨ @@ -61,7 +61,7 @@ Velite validates your contents against a [Zod](https://zod.dev) schema, and gene ### Framework Agnostic -Velite is a tool for building type-safe data layer, it is framework agnostic, and out of the box support for React, Vue, Svelte, Solid, etc. +Velite is framework agnostic, and out of the box support for React, Vue, Svelte, Solid, etc. ### Less Runtime Dependencies @@ -80,3 +80,5 @@ Velite is a tool for building type-safe data layer, it is framework agnostic, an - custom collection schema validation - error reporting friendly - etc. + +Velite is inspired by [Contentlayer](https://contentlayer.dev). diff --git a/docs/guide/quick-start.md b/docs/guide/quick-start.md index a51db22..bf4c27a 100644 --- a/docs/guide/quick-start.md +++ b/docs/guide/quick-start.md @@ -70,7 +70,7 @@ export default defineConfig({ }) ``` -For more information about Velite extended field schemas, see [Velite Schemas](velite-shemas.md). +For more information about Velite extended field schemas, see [Velite Schemas](velite-schemas.md). ::: tip diff --git a/docs/guide/velite-shemas.md b/docs/guide/velite-schemas.md similarity index 100% rename from docs/guide/velite-shemas.md rename to docs/guide/velite-schemas.md diff --git a/docs/other/roadmap.md b/docs/other/roadmap.md index f48fa4a..33b6509 100644 --- a/docs/other/roadmap.md +++ b/docs/other/roadmap.md @@ -3,10 +3,10 @@ The following are the features I want to achieve or are under development: - [ ] Full documentation -- [ ] Optimize the config structure, bundle & load +- [ ] Refactor Static Assets Processing to Support More Scenarios (e.g. OSS) - [ ] More built-in schemas -- [ ] Assets OSS support -- [ ] Unit & E2E tests ? +- [ ] Unit & E2E tests? +- [ ] Turborepo? - [ ] Scoffolding tool - [ ] Next.js plugin - [ ] Gatsby plugin diff --git a/readme.md b/readme.md index 79039c7..96babe5 100644 --- a/readme.md +++ b/readme.md @@ -15,15 +15,10 @@
NPM Downloads Install Size - Repo Size Dependencies Status

-🚧 the [documentation](https://velite.js.org) is not yet complete currently. but the functionality is mostly stable, although there is still a possibility of significant changes being made. - -However, I have provided some [examples](https://github.com/zce/velite/tree/main/examples) for your consideration. - ## What is Velite? Velite is a tool for building type-safe data layer, turn Markdown / MDX, YAML, JSON, or other files into app's data layer with Zod schema. @@ -33,8 +28,6 @@ Velite is a tool for building type-safe data layer, turn Markdown / MDX, YAML, J Velite Workflow -Inspired by [Contentlayer](https://contentlayer.dev), based on [Zod](https://zod.dev) and [Unified](https://unifiedjs.com), and powered by [ESBuild](https://esbuild.github.io). - ### Naming Origin "Velite" comes from the English word "elite". @@ -45,11 +38,11 @@ Inspired by [Contentlayer](https://contentlayer.dev), based on [Zod](https://zod - **Easy to use**: Move your contents into `content` folder, define collections schema, run `velite`, then use the output data in your application. - **Type-safe**: Contents schema validation by [Zod](https://zod.dev), and generate type inference for TypeScript. -- **Framework Agnostic**: JSON & Entry & DTS output, out of the box support for React, Vue, Svelte, Solid, etc. +- **Framework Agnostic**: JSON & Entry & DTS output, out of the box support for any JavaScript framework or library. - **Light-weight**: Choose more native APIs instead of bloated NPM modules, less runtime dependencies, so it is fast and efficiently. -- **Still powerful**: Built-in Markdown, YAML, JSON support, relative files & images processing, schema validation, etc. +- **Still powerful**: Built-in Markdown / MDX, YAML, JSON support, relative files & images processing, schema validation, etc. - **Configurable**: Both input and output directories can be customized, and support for custom loaders, hooks, etc. -- **Extensible**: Support any file types by custom loaders, Custom field validation and transform by custom schema, and any output formats by hooks +- **Extensible**: Support any file types by custom loaders, Custom field validation and transform by custom schema, and any output formats by hooks. Check out our detailed [Why Velite](https://velite.js.org/guide/introduction#why-velite) to learn more about what makes Velite special. ✨ @@ -65,8 +58,6 @@ You can try Velite directly in your browser on StackBlitz: The following are the features I want to achieve or are under development: - [ ] Full documentation -- [ ] File \_raw output? -- [ ] Optimize the config structure, bundle & load - [ ] Refactor Static Assets Processing to Support More Scenarios (e.g. OSS) - [ ] More built-in schemas - [ ] Unit & E2E tests? @@ -87,7 +78,8 @@ See the [open issues](https://github.com/zce/velite/issues) for a list of propos 5. **Push** your work back up to your fork: `git push -u origin my-awesome-feature` 6. Submit a **Pull Request** so that we can review your changes. -> **NOTE**: Be sure to merge the latest from "upstream" before making a pull request! +> [!NOTE] +> Be sure to merge the latest from "upstream" before making a pull request! ## License diff --git a/src/build.ts b/src/build.ts index 7be7ecd..37864ee 100644 --- a/src/build.ts +++ b/src/build.ts @@ -136,7 +136,7 @@ const init = async (configFile?: string, clean?: boolean, logLevel?: LogLevel): const dts: string[] = [`import config from '${configModPath}'\n`] Object.entries(collections).map(([name, collection]) => { - const funcName = `get${name[0].toUpperCase() + name.slice(1)}` // getPosts + const funcName = `get${name[0].toUpperCase() + name.slice(1)}` // e.g. getPosts entry.push(`export const ${funcName} = async () => await import('./${name}.json').then(m => m.default)\n`) dts.push(`export type ${collection.name} = NonNullable['${name}']['schema']['_output']`) dts.push(`export declare const ${funcName}: () => Promise<${collection.name + (collection.single ? '' : '[]')}>\n`)