diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index f7614a9..e86774a 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'vitepress' export default defineConfig({ title: 'Velite', - description: "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.", + description: "Velite is a tool for building type-safe data layer, turns Markdown/MDX, YAML, JSON, or other files into app's data layer with Zod schema.", lastUpdated: true, cleanUrls: true, head: [ diff --git a/docs/examples/basic.md b/docs/examples/basic.md index 177d25d..ab3b1d8 100644 --- a/docs/examples/basic.md +++ b/docs/examples/basic.md @@ -52,7 +52,7 @@ basic ```shell $ npm install # install dependencies -$ npm run dev # run build with watch mode +$ npm run dev # run build in watch mode $ npm run build # build content by velite ``` diff --git a/docs/examples/nextjs.md b/docs/examples/nextjs.md index deeda6c..899decd 100644 --- a/docs/examples/nextjs.md +++ b/docs/examples/nextjs.md @@ -69,7 +69,7 @@ nextjs ```shell $ npm install # install dependencies -$ npm run dev # run build with watch mode +$ npm run dev # run build in watch mode $ npm run build # build content by velite ``` diff --git a/docs/guide/code-highlighting.md b/docs/guide/code-highlighting.md index a01e78a..9497da4 100644 --- a/docs/guide/code-highlighting.md +++ b/docs/guide/code-highlighting.md @@ -1,8 +1,6 @@ # Code Highlighting -Considering that not all content contains code, and that syntax highlighting often comes with custom styles, Velite doesn't want to subjectively determine the final presentation of your content. So we don't include built-in code highlighting features. - -If you think code highlighting is necessary for your content, you can implement if by referring to the following methods. +Velite doesn't include built-in code highlighting features because not all content contains code, and that syntax highlighting often comes with custom styles. But you can easily implement it yourself with build-time plugins or client-side highlighters. ## rehype-pretty-code @@ -38,7 +36,7 @@ export default defineConfig({ }) ``` -Add some necessary styles, such as: +`rehype-pretty-code` creates the proper HTML structure for syntax highlighting, you can then add styles however you like. Here is an example stylesheet: ```css [data-rehype-pretty-code-figure] pre { @@ -78,7 +76,7 @@ Add some necessary styles, such as: } ``` -refer to [examples](https://github.com/zce/velite/blob/main/examples/nextjs/velite.config.ts) for more details. +Refer to [examples](https://github.com/zce/velite/blob/main/examples/nextjs/velite.config.ts) for more details. ## @shikijs/rehype @@ -165,9 +163,9 @@ export default defineConfig({ ## Client-side -Code highlighting in Client-side. You can use [prismjs](https://prismjs.com) or [shiki](https://shiki.matsu.io) to highlight code in client-side. +You can use [prismjs](https://prismjs.com) or [shiki](https://shiki.matsu.io) to highlight code on the client side. Client-side highlighting does not add build overhead to Velite. -for example: +For example: ```js import { codeToHtml } from 'https://esm.sh/shikiji' @@ -179,6 +177,6 @@ Array.from(document.querySelectorAll('pre code[class*="language-"]')).map(async ::: tip -This method is most recommended if there are a large number of documents that need to be processed frequently. Because syntax highlighting and parsing is very time-consuming, it will greatly affect the construction speed of Velite. +If you have a large of number of documents that need to be syntax highlighted, it is recommended to use the client-side method. Because syntax highlighting and parsing can be very time-consuming, and it will greatly affect the construction speed of Velite. ::: diff --git a/docs/guide/custom-loader.md b/docs/guide/custom-loader.md index 9bde01c..6eac26e 100644 --- a/docs/guide/custom-loader.md +++ b/docs/guide/custom-loader.md @@ -1,6 +1,6 @@ # Custom Loader -built-in loaders are: +Built-in loaders are: - `matter-loader`: parse frontmatter and provide content and data - `json-loader`: parse document as json diff --git a/docs/guide/custom-schema.md b/docs/guide/custom-schema.md index d3e4939..bcf1a69 100644 --- a/docs/guide/custom-schema.md +++ b/docs/guide/custom-schema.md @@ -2,7 +2,7 @@ > Schema is the core of Velite. It defines the structure and type of your content and validates it. > -> refer to [Velite Schemas](velite-schemas.md) for more information about built-in schema. +> Refer to [Velite Schemas](velite-schemas.md) for more information about built-in schema. Velite supports custom schema. A schema is a JavaScript function that returns a [Zod](https://zod.dev) schema object. @@ -33,7 +33,7 @@ export const hello = defineSchema(() => ) ``` -refer to [Zod documentation](https://zod.dev) for more information about Zod. +Refer to [Zod documentation](https://zod.dev) for more information about Zod. ## Define a Transformation Schema diff --git a/docs/guide/define-collections.md b/docs/guide/define-collections.md index 2be19f7..b924f73 100644 --- a/docs/guide/define-collections.md +++ b/docs/guide/define-collections.md @@ -1,6 +1,6 @@ # Define Collections -Content collections are the best way to manage and author content in content-first applications. Velite help to organize and validate your your contents, and provide automatic TypeScript type-safety for all of your contents. +Content collections are the best way to manage and author content in content-first applications. Velite helps you organize and validate your contents, and provides type-safety through automatic type generations. ## What is a Collection? @@ -86,7 +86,7 @@ const site = defineCollection({ Velite uses [Zod](https://zod.dev) to validate the content items in a collection. The `schema` option is used to define the Zod schema used to validate the content items in the collection. -To use Zod in Velite, import the `z` utility from `'velite'`. This is a re-export of the Zod library, and it supports all of the features of Zod. See [Zod's Docs](https://zod.dev) for complete documentation on how Zod works and what features are available. +To use Zod in Velite, import the `z` utility from `'velite'`. This is a re-export of Zod's `z` object, and it supports all of the features of Zod. See [Zod's Docs](https://zod.dev) for a complete documentation on how Zod works and what features are available. ```js import { z } from 'velite' @@ -104,7 +104,7 @@ The schema is usually a `ZodObject`, validating the shape of the content item. B ::: -For more useful schemas, I recommend that you use [Velite extended schemas `s`](velite-schemas.md): +For more complex 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. @@ -156,7 +156,7 @@ const posts = defineCollection({ ### Transform Context Metadata -The transform function can receive a second argument, which is the context object. This is useful for adding computed fields to the content items in a collection. +The `transform()` function can receive a second argument, which is the context object. This is useful for adding computed fields to the content items in a collection. ```js const posts = defineCollection({ @@ -176,9 +176,9 @@ the type of `meta` is `ZodMeta`, which extends [`VeliteFile`](../reference/types ## Content Body -Velite built-in Loader keep content raw body in `meta.content`, and plain text body in `meta.plain`. +Velite's built-in loader keeps content's raw body in `meta.content`, and the plain text body in `meta.plain`. -To extract the original content, you can customize a schema. +To add them as a field, you can use a custom schema. ```js const posts = defineCollection({ @@ -237,11 +237,11 @@ Velite can extract excerpt from content files. This is useful for adding compute ```js const posts = defineCollection({ schema: s.object({ - excerpt: s.excerpt() // excerpt of markdown content + excerpt: s.excerpt({ length: 200 }) // excerpt of the markdown body }) }) ``` #### Reference -- [`s.excerpt()`](velite-schemas.md#s-excerpt) +- [`s.excerpt(options)`](velite-schemas.md#s-excerpt) diff --git a/docs/guide/introduction.md b/docs/guide/introduction.md index 8dbe42b..e699288 100644 --- a/docs/guide/introduction.md +++ b/docs/guide/introduction.md @@ -2,7 +2,7 @@ ::: 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. +🚧 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. @@ -10,7 +10,7 @@ However, I have provided some [examples](https://github.com/zce/velite/tree/main ## 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. +Velite is a tool for building type-safe data layer, turns Markdown / MDX, YAML, JSON, or other files into app's data layer with Zod schema.   @@ -24,7 +24,7 @@ Velite is a tool for building type-safe data layer, turn Markdown / MDX, YAML, J ## Key Features - **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. +- **Type-safe**: Contents schema validation by [Zod](https://zod.dev), and generate type definitions for TypeScript. - **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. @@ -51,13 +51,13 @@ You can try Velite directly in your browser on StackBlitz, It runs Velite direct ### Type-Safe Contents -Velite validates your contents by [Zod](https://zod.dev) schema, and generates type inference for TypeScript. so you can use the output data in your application with confidence. +Velite validates your contents by [Zod](https://zod.dev) schema, and generates type definitions for TypeScript. so you can use the output data in your application with confidence. ### Full Type inference
-- auto-generate TypeScript type inference for each collection +- auto-generate TypeScript type definitions for each collection - support IDE IntelliSense, auto-completion & type checking & refactoring & etc. ### Full Controllable Content Transform diff --git a/docs/guide/last-modified.md b/docs/guide/last-modified.md index 779503b..b34d94e 100644 --- a/docs/guide/last-modified.md +++ b/docs/guide/last-modified.md @@ -1,24 +1,34 @@ # Last Modified Schema -We provide a last modified timestamp schema based on file stat and git timestamp. +You can create a custom schema to show the last modified time for your contents. This can be based on: + +- File stat + +- Git timestamp ## Based on file stat -create a timestamp schema based on file stat. +Create a timestamp schema based on file stat. ```ts -const timestamp = () => - s.custom