@geenius/docs 0.1.0 → 0.4.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/CHANGELOG.md +7 -0
- package/README.md +53 -1
- package/package.json +96 -13
- package/packages/convex/dist/index.d.ts +503 -0
- package/packages/convex/dist/index.js +482 -0
- package/packages/convex/dist/index.js.map +1 -0
- package/packages/react/dist/index.d.ts +439 -0
- package/packages/react/dist/index.js +4954 -0
- package/packages/react/dist/index.js.map +1 -0
- package/packages/react-css/{src/styles.css → dist/index.css} +183 -223
- package/packages/react-css/dist/index.css.map +1 -0
- package/packages/react-css/dist/index.d.ts +443 -0
- package/packages/react-css/dist/index.js +5058 -0
- package/packages/react-css/dist/index.js.map +1 -0
- package/packages/shared/dist/index.d.ts +684 -0
- package/packages/shared/dist/index.js +788 -0
- package/packages/shared/dist/index.js.map +1 -0
- package/packages/solidjs/dist/index.d.ts +435 -0
- package/packages/solidjs/dist/index.js +4584 -0
- package/packages/solidjs/dist/index.js.map +1 -0
- package/packages/solidjs-css/{src/styles.css → dist/index.css} +183 -223
- package/packages/solidjs-css/dist/index.css.map +1 -0
- package/packages/solidjs-css/dist/index.d.ts +432 -0
- package/packages/solidjs-css/dist/index.js +4934 -0
- package/packages/solidjs-css/dist/index.js.map +1 -0
- package/.changeset/config.json +0 -11
- package/.github/CODEOWNERS +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -16
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -11
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/ci.yml +0 -23
- package/.github/workflows/release.yml +0 -29
- package/.nvmrc +0 -1
- package/.project/ACCOUNT.yaml +0 -4
- package/.project/IDEAS.yaml +0 -7
- package/.project/PROJECT.yaml +0 -11
- package/.project/ROADMAP.yaml +0 -15
- package/CODE_OF_CONDUCT.md +0 -16
- package/CONTRIBUTING.md +0 -26
- package/SECURITY.md +0 -15
- package/SUPPORT.md +0 -8
- package/packages/convex/README.md +0 -1
- package/packages/convex/package.json +0 -12
- package/packages/convex/src/convex.config.ts +0 -3
- package/packages/convex/src/index.ts +0 -3
- package/packages/convex/src/mutations.ts +0 -270
- package/packages/convex/src/queries.ts +0 -175
- package/packages/convex/src/schema.ts +0 -55
- package/packages/react/README.md +0 -1
- package/packages/react/package.json +0 -36
- package/packages/react/src/DocsLayout.tsx +0 -116
- package/packages/react/src/DocsProvider.tsx +0 -93
- package/packages/react/src/RouterDocsContent.tsx +0 -148
- package/packages/react/src/RouterDocsLayout.tsx +0 -161
- package/packages/react/src/components/Breadcrumbs.tsx +0 -34
- package/packages/react/src/components/DocPage.tsx +0 -191
- package/packages/react/src/components/DocSearch.tsx +0 -140
- package/packages/react/src/components/DocSidebar.tsx +0 -86
- package/packages/react/src/components/DocsLayout.tsx +0 -62
- package/packages/react/src/components/EditButton.tsx +0 -26
- package/packages/react/src/components/PageNavigation.tsx +0 -45
- package/packages/react/src/components/TableOfContents.tsx +0 -46
- package/packages/react/src/components/VersionSelector.tsx +0 -60
- package/packages/react/src/components/index.ts +0 -9
- package/packages/react/src/hooks/index.ts +0 -8
- package/packages/react/src/hooks/useDocSearch.ts +0 -55
- package/packages/react/src/hooks/useDocs.ts +0 -57
- package/packages/react/src/hooks/useDocsAdmin.ts +0 -151
- package/packages/react/src/hooks/useTableOfContents.ts +0 -66
- package/packages/react/src/index.ts +0 -38
- package/packages/react/src/pages/DocSearchPage.tsx +0 -129
- package/packages/react/src/pages/DocViewPage.tsx +0 -158
- package/packages/react/src/pages/DocsAdminPage.tsx +0 -330
- package/packages/react/src/pages/DocsIndexPage.tsx +0 -172
- package/packages/react/src/pages/index.ts +0 -4
- package/packages/react/src/useDocs.ts +0 -58
- package/packages/react/tsup.config.ts +0 -12
- package/packages/react-css/README.md +0 -1
- package/packages/react-css/package.json +0 -37
- package/packages/react-css/src/DocsLayout.tsx +0 -117
- package/packages/react-css/src/DocsProvider.tsx +0 -93
- package/packages/react-css/src/RouterDocsContent.tsx +0 -60
- package/packages/react-css/src/RouterDocsLayout.tsx +0 -101
- package/packages/react-css/src/components/DocPage.tsx +0 -21
- package/packages/react-css/src/components/DocSearch.tsx +0 -55
- package/packages/react-css/src/components/DocSidebar.tsx +0 -56
- package/packages/react-css/src/components/DocsLayout.tsx +0 -28
- package/packages/react-css/src/components/common.tsx +0 -93
- package/packages/react-css/src/components/index.ts +0 -5
- package/packages/react-css/src/hooks/index.ts +0 -2
- package/packages/react-css/src/index.ts +0 -6
- package/packages/react-css/src/index.tsx +0 -3
- package/packages/react-css/src/pages/DocViewPage.tsx +0 -78
- package/packages/react-css/src/pages/DocsAdminPage.tsx +0 -101
- package/packages/react-css/src/pages/DocsIndexPage.tsx +0 -68
- package/packages/react-css/src/pages/index.ts +0 -3
- package/packages/react-css/src/useDocs.ts +0 -58
- package/packages/react-css/tsconfig.json +0 -19
- package/packages/react-css/tsup.config.ts +0 -10
- package/packages/shared/README.md +0 -1
- package/packages/shared/package.json +0 -31
- package/packages/shared/src/__tests__/docs.test.ts +0 -69
- package/packages/shared/src/config.ts +0 -80
- package/packages/shared/src/index.ts +0 -179
- package/packages/shared/src/providers/astro.ts +0 -94
- package/packages/shared/src/providers/fumadocs.ts +0 -116
- package/packages/shared/src/providers/internal.ts +0 -80
- package/packages/shared/src/types.ts +0 -73
- package/packages/shared/tsconfig.json +0 -18
- package/packages/shared/tsup.config.ts +0 -12
- package/packages/shared/vitest.config.ts +0 -4
- package/packages/solidjs/README.md +0 -1
- package/packages/solidjs/package.json +0 -33
- package/packages/solidjs/src/DocsLayout.tsx +0 -87
- package/packages/solidjs/src/DocsProvider.tsx +0 -95
- package/packages/solidjs/src/RouterDocsContent.tsx +0 -147
- package/packages/solidjs/src/RouterDocsLayout.tsx +0 -161
- package/packages/solidjs/src/components/Breadcrumbs.tsx +0 -27
- package/packages/solidjs/src/components/DocPage.tsx +0 -110
- package/packages/solidjs/src/components/DocSearch.tsx +0 -81
- package/packages/solidjs/src/components/DocSidebar.tsx +0 -92
- package/packages/solidjs/src/components/DocsLayout.tsx +0 -38
- package/packages/solidjs/src/components/EditButton.tsx +0 -15
- package/packages/solidjs/src/components/PageNavigation.tsx +0 -31
- package/packages/solidjs/src/components/TableOfContents.tsx +0 -41
- package/packages/solidjs/src/components/VersionSelector.tsx +0 -30
- package/packages/solidjs/src/components/index.ts +0 -9
- package/packages/solidjs/src/createDocs.ts +0 -62
- package/packages/solidjs/src/index.ts +0 -28
- package/packages/solidjs/src/pages/DocSearchPage.tsx +0 -72
- package/packages/solidjs/src/pages/DocViewPage.tsx +0 -80
- package/packages/solidjs/src/pages/DocsAdminPage.tsx +0 -123
- package/packages/solidjs/src/pages/DocsIndexPage.tsx +0 -85
- package/packages/solidjs/src/pages/index.ts +0 -4
- package/packages/solidjs/src/primitives/createDocSearch.ts +0 -42
- package/packages/solidjs/src/primitives/createDocs.ts +0 -35
- package/packages/solidjs/src/primitives/createDocsAdmin.ts +0 -63
- package/packages/solidjs/src/primitives/createTableOfContents.ts +0 -51
- package/packages/solidjs/src/primitives/index.ts +0 -4
- package/packages/solidjs/tsup.config.ts +0 -12
- package/packages/solidjs-css/README.md +0 -1
- package/packages/solidjs-css/package.json +0 -36
- package/packages/solidjs-css/src/DocsLayout.tsx +0 -106
- package/packages/solidjs-css/src/DocsProvider.tsx +0 -95
- package/packages/solidjs-css/src/RouterDocsContent.tsx +0 -54
- package/packages/solidjs-css/src/RouterDocsLayout.tsx +0 -104
- package/packages/solidjs-css/src/createDocs.ts +0 -62
- package/packages/solidjs-css/src/index.ts +0 -7
- package/packages/solidjs-css/src/index.tsx +0 -17
- package/packages/solidjs-css/src/pages/DocViewPage.tsx +0 -111
- package/packages/solidjs-css/src/pages/DocsAdminPage.tsx +0 -332
- package/packages/solidjs-css/src/pages/DocsIndexPage.tsx +0 -116
- package/packages/solidjs-css/src/pages/index.ts +0 -3
- package/packages/solidjs-css/src/primitives/index.ts +0 -1
- package/packages/solidjs-css/tsconfig.json +0 -20
- package/packages/solidjs-css/tsup.config.ts +0 -10
- package/pnpm-workspace.yaml +0 -2
package/.changeset/config.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
|
3
|
-
"changelog": "@changesets/cli/changelog",
|
|
4
|
-
"commit": false,
|
|
5
|
-
"fixed": [],
|
|
6
|
-
"linked": [],
|
|
7
|
-
"access": "public",
|
|
8
|
-
"baseBranch": "main",
|
|
9
|
-
"updateInternalDependencies": "patch",
|
|
10
|
-
"ignore": []
|
|
11
|
-
}
|
package/.github/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @mxn2020
|
package/.github/dependabot.yml
DELETED
package/.github/workflows/ci.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
branches: [main]
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
check:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v4
|
|
13
|
-
- uses: pnpm/action-setup@v4
|
|
14
|
-
with:
|
|
15
|
-
version: 10
|
|
16
|
-
- uses: actions/setup-node@v4
|
|
17
|
-
with:
|
|
18
|
-
node-version-file: '.nvmrc'
|
|
19
|
-
cache: 'pnpm'
|
|
20
|
-
- run: pnpm install --frozen-lockfile
|
|
21
|
-
- run: pnpm build
|
|
22
|
-
- run: pnpm lint
|
|
23
|
-
- run: pnpm test
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches: [main]
|
|
5
|
-
|
|
6
|
-
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
release:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v4
|
|
13
|
-
- uses: pnpm/action-setup@v4
|
|
14
|
-
with:
|
|
15
|
-
version: 10
|
|
16
|
-
- uses: actions/setup-node@v4
|
|
17
|
-
with:
|
|
18
|
-
node-version-file: '.nvmrc'
|
|
19
|
-
cache: 'pnpm'
|
|
20
|
-
registry-url: 'https://registry.npmjs.org'
|
|
21
|
-
- run: pnpm install --frozen-lockfile
|
|
22
|
-
- run: pnpm build
|
|
23
|
-
- uses: changesets/action@v1
|
|
24
|
-
with:
|
|
25
|
-
publish: pnpm changeset publish
|
|
26
|
-
version: pnpm changeset version
|
|
27
|
-
env:
|
|
28
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
29
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
22
|
package/.project/ACCOUNT.yaml
DELETED
package/.project/IDEAS.yaml
DELETED
package/.project/PROJECT.yaml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
name: geenius-docs
|
|
2
|
-
description: "Geenius Docs — Provider-based documentation system (Astro/Fumadocs/Internal) for React + SolidJS"
|
|
3
|
-
category: library
|
|
4
|
-
priority: high
|
|
5
|
-
tags:
|
|
6
|
-
- geenius
|
|
7
|
-
- npm-package
|
|
8
|
-
- react
|
|
9
|
-
- solidjs
|
|
10
|
-
deploy_url: null
|
|
11
|
-
npm_scope: "@geenius-docs"
|
package/.project/ROADMAP.yaml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
version: "0.1"
|
|
2
|
-
milestones:
|
|
3
|
-
- name: "v0.1.0 — Initial Release"
|
|
4
|
-
status: in-progress
|
|
5
|
-
items:
|
|
6
|
-
- "Core shared types and logic"
|
|
7
|
-
- "React hooks and components"
|
|
8
|
-
- "SolidJS primitives"
|
|
9
|
-
- "npm publishing via Changesets"
|
|
10
|
-
- name: "v0.2.0 — Stability"
|
|
11
|
-
status: planned
|
|
12
|
-
items:
|
|
13
|
-
- "Test coverage ≥ 50%"
|
|
14
|
-
- "API documentation"
|
|
15
|
-
- "Convex adapter"
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
8
|
-
education, socio-economic status, nationality, personal appearance, race,
|
|
9
|
-
religion, or sexual identity and orientation.
|
|
10
|
-
|
|
11
|
-
## Enforcement
|
|
12
|
-
|
|
13
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
14
|
-
reported to the project team at conduct@geenius.app.
|
|
15
|
-
|
|
16
|
-
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Contributing to @geenius-docs
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing!
|
|
4
|
-
|
|
5
|
-
## Development Setup
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
git clone https://github.com/mxn2020/geenius-docs.git
|
|
9
|
-
cd geenius-docs
|
|
10
|
-
pnpm install
|
|
11
|
-
pnpm build
|
|
12
|
-
pnpm test
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Pull Request Process
|
|
16
|
-
|
|
17
|
-
1. Fork the repo and create a feature branch from `main`
|
|
18
|
-
2. Add or update tests as appropriate
|
|
19
|
-
3. Run `pnpm changeset` to describe your changes for the changelog
|
|
20
|
-
4. Open a PR against `main`
|
|
21
|
-
|
|
22
|
-
## Code Style
|
|
23
|
-
|
|
24
|
-
- TypeScript strict mode
|
|
25
|
-
- ESLint + Prettier formatting
|
|
26
|
-
- Conventional commits preferred
|
package/SECURITY.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
| Version | Supported |
|
|
6
|
-
| ------- | --------- |
|
|
7
|
-
| 0.x.x | ✅ |
|
|
8
|
-
|
|
9
|
-
## Reporting a Vulnerability
|
|
10
|
-
|
|
11
|
-
Please report security vulnerabilities by emailing **security@geenius.app**.
|
|
12
|
-
|
|
13
|
-
Do **not** open a public GitHub issue for security vulnerabilities.
|
|
14
|
-
|
|
15
|
-
We will acknowledge receipt within 48 hours and provide a detailed response within 5 business days.
|
package/SUPPORT.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Support
|
|
2
|
-
|
|
3
|
-
## Getting Help
|
|
4
|
-
|
|
5
|
-
- 📖 [Documentation](https://docs.geenius.app)
|
|
6
|
-
- 🐛 [Bug Reports](https://github.com/mxn2020/geenius-docs/issues/new?template=bug_report.md)
|
|
7
|
-
- 💡 [Feature Requests](https://github.com/mxn2020/geenius-docs/issues/new?template=feature_request.md)
|
|
8
|
-
- 📧 Email: support@geenius.app
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# ✦ @geenius-docs/convex\n\n> A premium module for the Geenius Boilerplate Ecosystem.\n\n---\n\n## Overview\nBuilt with Steve Jobs-level minimalism and Jony Ive-level craftsmanship, this package is designed to deliver unparalleled developer experience (DX) and rock-solid performance.\n\n## Installation\n\n```bash\npnpm add @geenius-docs/convex\n```\n\n## Usage\n\n```typescript\nimport { init } from '@geenius-docs/convex';\n\n// Initialize the module with absolute precision\ninit({\n mode: 'premium',\n});\n```\n\n## Architecture\n- **Zero-config**: It just works.\n- **Strictly Typed**: Fully written in TypeScript for flawless IntelliSense.\n- **Framework Agnostic**: seamlessly integrates into the Geenius ecosystem.\n\n---\n\n*Designed by Antigravity HQ*\n
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { v } from "convex/values";
|
|
2
|
-
import { mutation } from "./_generated/server.js";
|
|
3
|
-
|
|
4
|
-
// ─── Sections ────────────────────────────────────────────────
|
|
5
|
-
|
|
6
|
-
export const createSection = mutation({
|
|
7
|
-
args: {
|
|
8
|
-
title: v.string(),
|
|
9
|
-
slug: v.string(),
|
|
10
|
-
parentId: v.optional(v.id("doc_sections")),
|
|
11
|
-
order: v.number(),
|
|
12
|
-
icon: v.optional(v.string()),
|
|
13
|
-
description: v.optional(v.string()),
|
|
14
|
-
access: v.union(v.literal("public"), v.literal("team"), v.literal("admin")),
|
|
15
|
-
},
|
|
16
|
-
returns: v.id("doc_sections"),
|
|
17
|
-
handler: async (ctx, args) => {
|
|
18
|
-
return await ctx.db.insert("doc_sections", {
|
|
19
|
-
...args,
|
|
20
|
-
createdAt: Date.now(),
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const updateSection = mutation({
|
|
26
|
-
args: {
|
|
27
|
-
sectionId: v.id("doc_sections"),
|
|
28
|
-
title: v.optional(v.string()),
|
|
29
|
-
slug: v.optional(v.string()),
|
|
30
|
-
order: v.optional(v.number()),
|
|
31
|
-
icon: v.optional(v.string()),
|
|
32
|
-
description: v.optional(v.string()),
|
|
33
|
-
access: v.optional(
|
|
34
|
-
v.union(v.literal("public"), v.literal("team"), v.literal("admin"))
|
|
35
|
-
),
|
|
36
|
-
},
|
|
37
|
-
returns: v.null(),
|
|
38
|
-
handler: async (ctx, args) => {
|
|
39
|
-
const { sectionId, ...updates } = args;
|
|
40
|
-
const clean = Object.fromEntries(
|
|
41
|
-
Object.entries(updates).filter(([, val]) => val !== undefined)
|
|
42
|
-
);
|
|
43
|
-
await ctx.db.patch(sectionId, clean);
|
|
44
|
-
return null;
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export const deleteSection = mutation({
|
|
49
|
-
args: { sectionId: v.id("doc_sections") },
|
|
50
|
-
returns: v.null(),
|
|
51
|
-
handler: async (ctx, args) => {
|
|
52
|
-
// Delete all pages in this section
|
|
53
|
-
const pages = await ctx.db
|
|
54
|
-
.query("doc_pages")
|
|
55
|
-
.withIndex("by_sectionId", (q) => q.eq("sectionId", args.sectionId))
|
|
56
|
-
.collect();
|
|
57
|
-
|
|
58
|
-
for (const page of pages) {
|
|
59
|
-
// Delete search index entries for each page
|
|
60
|
-
const indexEntries = await ctx.db
|
|
61
|
-
.query("doc_search_index")
|
|
62
|
-
.withIndex("by_pageId", (q) => q.eq("pageId", page._id))
|
|
63
|
-
.collect();
|
|
64
|
-
for (const entry of indexEntries) {
|
|
65
|
-
await ctx.db.delete(entry._id);
|
|
66
|
-
}
|
|
67
|
-
await ctx.db.delete(page._id);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
await ctx.db.delete(args.sectionId);
|
|
71
|
-
return null;
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export const reorderSections = mutation({
|
|
76
|
-
args: { sectionIds: v.array(v.id("doc_sections")) },
|
|
77
|
-
returns: v.null(),
|
|
78
|
-
handler: async (ctx, args) => {
|
|
79
|
-
for (let i = 0; i < args.sectionIds.length; i++) {
|
|
80
|
-
await ctx.db.patch(args.sectionIds[i], { order: i });
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// ─── Pages ───────────────────────────────────────────────────
|
|
87
|
-
|
|
88
|
-
export const createPage = mutation({
|
|
89
|
-
args: {
|
|
90
|
-
title: v.string(),
|
|
91
|
-
slug: v.string(),
|
|
92
|
-
content: v.string(),
|
|
93
|
-
sectionId: v.id("doc_sections"),
|
|
94
|
-
access: v.union(v.literal("public"), v.literal("team"), v.literal("admin")),
|
|
95
|
-
tags: v.optional(v.array(v.string())),
|
|
96
|
-
version: v.optional(v.string()),
|
|
97
|
-
status: v.optional(
|
|
98
|
-
v.union(
|
|
99
|
-
v.literal("draft"),
|
|
100
|
-
v.literal("published"),
|
|
101
|
-
v.literal("archived")
|
|
102
|
-
)
|
|
103
|
-
),
|
|
104
|
-
author: v.optional(
|
|
105
|
-
v.object({ name: v.string(), avatar: v.optional(v.string()) })
|
|
106
|
-
),
|
|
107
|
-
excerpt: v.optional(v.string()),
|
|
108
|
-
order: v.optional(v.number()),
|
|
109
|
-
},
|
|
110
|
-
returns: v.id("doc_pages"),
|
|
111
|
-
handler: async (ctx, args) => {
|
|
112
|
-
const now = Date.now();
|
|
113
|
-
const stripped = args.content
|
|
114
|
-
.replace(/```[\s\S]*?```/g, "")
|
|
115
|
-
.replace(/[#*_~>|-]/g, "")
|
|
116
|
-
.trim();
|
|
117
|
-
const words = stripped.split(/\s+/).filter(Boolean);
|
|
118
|
-
const wordCount = words.length;
|
|
119
|
-
const readingTime = Math.max(1, Math.ceil(wordCount / 225));
|
|
120
|
-
|
|
121
|
-
return await ctx.db.insert("doc_pages", {
|
|
122
|
-
title: args.title,
|
|
123
|
-
slug: args.slug,
|
|
124
|
-
content: args.content,
|
|
125
|
-
excerpt: args.excerpt,
|
|
126
|
-
sectionId: args.sectionId,
|
|
127
|
-
order: args.order ?? 0,
|
|
128
|
-
author: args.author ?? { name: "Anonymous" },
|
|
129
|
-
version: args.version,
|
|
130
|
-
access: args.access,
|
|
131
|
-
tags: args.tags ?? [],
|
|
132
|
-
status: args.status ?? "draft",
|
|
133
|
-
createdAt: now,
|
|
134
|
-
updatedAt: now,
|
|
135
|
-
wordCount,
|
|
136
|
-
readingTime,
|
|
137
|
-
viewCount: 0,
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
export const updatePage = mutation({
|
|
143
|
-
args: {
|
|
144
|
-
pageId: v.id("doc_pages"),
|
|
145
|
-
title: v.optional(v.string()),
|
|
146
|
-
slug: v.optional(v.string()),
|
|
147
|
-
content: v.optional(v.string()),
|
|
148
|
-
excerpt: v.optional(v.string()),
|
|
149
|
-
sectionId: v.optional(v.id("doc_sections")),
|
|
150
|
-
order: v.optional(v.number()),
|
|
151
|
-
access: v.optional(
|
|
152
|
-
v.union(v.literal("public"), v.literal("team"), v.literal("admin"))
|
|
153
|
-
),
|
|
154
|
-
tags: v.optional(v.array(v.string())),
|
|
155
|
-
version: v.optional(v.string()),
|
|
156
|
-
status: v.optional(
|
|
157
|
-
v.union(
|
|
158
|
-
v.literal("draft"),
|
|
159
|
-
v.literal("published"),
|
|
160
|
-
v.literal("archived")
|
|
161
|
-
)
|
|
162
|
-
),
|
|
163
|
-
lastEditedBy: v.optional(
|
|
164
|
-
v.object({ name: v.string(), editedAt: v.string() })
|
|
165
|
-
),
|
|
166
|
-
},
|
|
167
|
-
returns: v.null(),
|
|
168
|
-
handler: async (ctx, args) => {
|
|
169
|
-
const { pageId, ...updates } = args;
|
|
170
|
-
const clean: Record<string, unknown> = Object.fromEntries(
|
|
171
|
-
Object.entries(updates).filter(([, val]) => val !== undefined)
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
// Recalculate word count if content changed
|
|
175
|
-
if (typeof clean.content === "string") {
|
|
176
|
-
const stripped = (clean.content as string)
|
|
177
|
-
.replace(/```[\s\S]*?```/g, "")
|
|
178
|
-
.replace(/[#*_~>|-]/g, "")
|
|
179
|
-
.trim();
|
|
180
|
-
const words = stripped.split(/\s+/).filter(Boolean);
|
|
181
|
-
clean.wordCount = words.length;
|
|
182
|
-
clean.readingTime = Math.max(1, Math.ceil(words.length / 225));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
clean.updatedAt = Date.now();
|
|
186
|
-
await ctx.db.patch(pageId, clean);
|
|
187
|
-
return null;
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
export const publishPage = mutation({
|
|
192
|
-
args: { pageId: v.id("doc_pages") },
|
|
193
|
-
returns: v.null(),
|
|
194
|
-
handler: async (ctx, args) => {
|
|
195
|
-
await ctx.db.patch(args.pageId, {
|
|
196
|
-
status: "published",
|
|
197
|
-
updatedAt: Date.now(),
|
|
198
|
-
});
|
|
199
|
-
return null;
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
export const archivePage = mutation({
|
|
204
|
-
args: { pageId: v.id("doc_pages") },
|
|
205
|
-
returns: v.null(),
|
|
206
|
-
handler: async (ctx, args) => {
|
|
207
|
-
await ctx.db.patch(args.pageId, {
|
|
208
|
-
status: "archived",
|
|
209
|
-
updatedAt: Date.now(),
|
|
210
|
-
});
|
|
211
|
-
return null;
|
|
212
|
-
},
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
export const deletePage = mutation({
|
|
216
|
-
args: { pageId: v.id("doc_pages") },
|
|
217
|
-
returns: v.null(),
|
|
218
|
-
handler: async (ctx, args) => {
|
|
219
|
-
// Delete search index entries
|
|
220
|
-
const indexEntries = await ctx.db
|
|
221
|
-
.query("doc_search_index")
|
|
222
|
-
.withIndex("by_pageId", (q) => q.eq("pageId", args.pageId))
|
|
223
|
-
.collect();
|
|
224
|
-
for (const entry of indexEntries) {
|
|
225
|
-
await ctx.db.delete(entry._id);
|
|
226
|
-
}
|
|
227
|
-
await ctx.db.delete(args.pageId);
|
|
228
|
-
return null;
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
export const reorderPages = mutation({
|
|
233
|
-
args: { pageIds: v.array(v.id("doc_pages")) },
|
|
234
|
-
returns: v.null(),
|
|
235
|
-
handler: async (ctx, args) => {
|
|
236
|
-
for (let i = 0; i < args.pageIds.length; i++) {
|
|
237
|
-
await ctx.db.patch(args.pageIds[i], { order: i });
|
|
238
|
-
}
|
|
239
|
-
return null;
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
export const incrementViewCount = mutation({
|
|
244
|
-
args: { pageId: v.id("doc_pages") },
|
|
245
|
-
returns: v.null(),
|
|
246
|
-
handler: async (ctx, args) => {
|
|
247
|
-
const page = await ctx.db.get(args.pageId);
|
|
248
|
-
if (page) {
|
|
249
|
-
await ctx.db.patch(args.pageId, { viewCount: (page.viewCount ?? 0) + 1 });
|
|
250
|
-
}
|
|
251
|
-
return null;
|
|
252
|
-
},
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
export const movePage = mutation({
|
|
256
|
-
args: {
|
|
257
|
-
pageId: v.id("doc_pages"),
|
|
258
|
-
newSectionId: v.id("doc_sections"),
|
|
259
|
-
newOrder: v.number(),
|
|
260
|
-
},
|
|
261
|
-
returns: v.null(),
|
|
262
|
-
handler: async (ctx, args) => {
|
|
263
|
-
await ctx.db.patch(args.pageId, {
|
|
264
|
-
sectionId: args.newSectionId,
|
|
265
|
-
order: args.newOrder,
|
|
266
|
-
updatedAt: Date.now(),
|
|
267
|
-
});
|
|
268
|
-
return null;
|
|
269
|
-
},
|
|
270
|
-
});
|