content-query 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/build-C5ef0kkR.mjs +1401 -0
- package/dist/build-DSyoRxkZ.d.mts +24 -0
- package/dist/build.d.mts +2 -0
- package/dist/build.mjs +2 -0
- package/dist/chunk-CJs4Fogs.mjs +34 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +97 -0
- package/dist/computed.d.mts +37 -0
- package/dist/computed.mjs +138 -0
- package/dist/content-Crag1Uch.d.mts +99 -0
- package/dist/content-Dj2fQCJ5.mjs +902 -0
- package/dist/descriptor-Xbo9u5eR.d.mts +19 -0
- package/dist/diagnostics-Dol6ANtq.mjs +79 -0
- package/dist/dist-BQGVLZyl.mjs +5396 -0
- package/dist/errors-C8lWyiy2.mjs +72 -0
- package/dist/github-slugger-BCAkwEOL.mjs +72 -0
- package/dist/glob-DJmebCMM.mjs +159 -0
- package/dist/index.d.mts +60 -0
- package/dist/index.mjs +43 -0
- package/dist/internal/markdown.d.mts +7 -0
- package/dist/internal/markdown.mjs +2 -0
- package/dist/internal.d.mts +54 -0
- package/dist/internal.mjs +89 -0
- package/dist/loaders.d.mts +12 -0
- package/dist/loaders.mjs +85 -0
- package/dist/markdown-CZBL4Ux_.mjs +54 -0
- package/dist/next.d.mts +21 -0
- package/dist/next.mjs +142 -0
- package/dist/operators-BQpLfJlx.mjs +173 -0
- package/dist/query.d.mts +45 -0
- package/dist/query.mjs +2 -0
- package/dist/relational-types-DLniKi5S.d.mts +245 -0
- package/dist/runtime.d.mts +3 -0
- package/dist/runtime.mjs +6 -0
- package/dist/schema-CnCbMosm.mjs +20 -0
- package/dist/schema.d.mts +13 -0
- package/dist/schema.mjs +2 -0
- package/dist/server-only-CIE-FHx0.mjs +7 -0
- package/dist/types-BPh2cBPs.d.mts +48 -0
- package/dist/types-DcvHRmxO.d.mts +20 -0
- package/dist/types-hmDOw87q.d.mts +135 -0
- package/dist/validation-BvvjSUFc.mjs +84 -0
- package/dist/values-B7lo_2_x.mjs +900 -0
- package/dist/vite.d.mts +8 -0
- package/dist/vite.mjs +296 -0
- package/package.json +90 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yangshun Tay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# ContentQuery
|
|
2
|
+
|
|
3
|
+
Typed collections and queries for Markdown, JSON, YAML, and TOML. ContentQuery validates your content at build time and produces portable data your application can query and render on the server.
|
|
4
|
+
|
|
5
|
+
Use it with your existing framework. Your application owns its routes, layouts, and public URLs; production reads prepared content without loading the original source files.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Typed schemas.** Validate metadata with bundled schema builders or any Standard Schema V1 provider, with inferred TypeScript types.
|
|
10
|
+
- **Flexible sources.** Load local files, use Astro-compatible content loaders, or write your own loader.
|
|
11
|
+
- **Queries and relationships.** Select fields, filter, sort, paginate, and load related entries with validated references.
|
|
12
|
+
- **Markdown rendering.** Get HTML, headings, and syntax highlighting separately from metadata queries.
|
|
13
|
+
- **Framework integrations.** Use Vite, Next.js, or the standalone CLI, with content updates during development.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Requires Node.js 22.12 or later. Install ContentQuery:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install content-query
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Define `content-query.config.ts`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { defineCollection } from "content-query";
|
|
27
|
+
import { schema } from "content-query/schema";
|
|
28
|
+
|
|
29
|
+
export const collections = {
|
|
30
|
+
posts: defineCollection({
|
|
31
|
+
source: "./content/posts",
|
|
32
|
+
schema: schema.object({
|
|
33
|
+
title: schema.string(),
|
|
34
|
+
draft: schema.boolean().default(false),
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Add Markdown files with `title` frontmatter under `content/posts/`, then build:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npx content-query build
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Query the generated module from server code:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { content } from "./.content-query/server.js";
|
|
50
|
+
import { eq } from "content-query/query";
|
|
51
|
+
|
|
52
|
+
const posts = await content
|
|
53
|
+
.select("id", "title")
|
|
54
|
+
.from("posts")
|
|
55
|
+
.where((fields) => eq(fields.draft, false))
|
|
56
|
+
.orderBy("title");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Add `.content-query/` to `.gitignore`. Follow the quick start for a complete walkthrough, or choose a framework example below.
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
- [Quick start](https://github.com/yangshun/content-query/blob/main/website/content/guides/quick-start.md)
|
|
64
|
+
- [Framework examples](https://github.com/yangshun/content-query/blob/main/examples/README.md)
|
|
65
|
+
- [API and usage](https://github.com/yangshun/content-query/blob/main/docs/API.md)
|
|
66
|
+
- [Guides and reference](https://github.com/yangshun/content-query/blob/main/docs/README.md)
|
|
67
|
+
|
|
68
|
+
The Vite integration supports Vite 8, and the Next.js integration supports Next.js 16. Both integrations are optional; standalone builds and queries require neither framework.
|
|
69
|
+
|
|
70
|
+
Released under the [MIT license](https://github.com/yangshun/content-query/blob/main/LICENSE).
|