@geenius/docs 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/.changeset/config.json +11 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/ci.yml +23 -0
- package/.github/workflows/release.yml +29 -0
- package/.nvmrc +1 -0
- package/.project/ACCOUNT.yaml +4 -0
- package/.project/IDEAS.yaml +7 -0
- package/.project/PROJECT.yaml +11 -0
- package/.project/ROADMAP.yaml +15 -0
- package/CHANGELOG.md +11 -0
- package/CODE_OF_CONDUCT.md +16 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/SECURITY.md +15 -0
- package/SUPPORT.md +8 -0
- package/package.json +58 -0
- package/packages/convex/README.md +1 -0
- package/packages/convex/package.json +12 -0
- package/packages/convex/src/convex.config.ts +3 -0
- package/packages/convex/src/index.ts +3 -0
- package/packages/convex/src/mutations.ts +270 -0
- package/packages/convex/src/queries.ts +175 -0
- package/packages/convex/src/schema.ts +55 -0
- package/packages/react/README.md +1 -0
- package/packages/react/package.json +36 -0
- package/packages/react/src/DocsLayout.tsx +116 -0
- package/packages/react/src/DocsProvider.tsx +93 -0
- package/packages/react/src/RouterDocsContent.tsx +148 -0
- package/packages/react/src/RouterDocsLayout.tsx +161 -0
- package/packages/react/src/components/Breadcrumbs.tsx +34 -0
- package/packages/react/src/components/DocPage.tsx +191 -0
- package/packages/react/src/components/DocSearch.tsx +140 -0
- package/packages/react/src/components/DocSidebar.tsx +86 -0
- package/packages/react/src/components/DocsLayout.tsx +62 -0
- package/packages/react/src/components/EditButton.tsx +26 -0
- package/packages/react/src/components/PageNavigation.tsx +45 -0
- package/packages/react/src/components/TableOfContents.tsx +46 -0
- package/packages/react/src/components/VersionSelector.tsx +60 -0
- package/packages/react/src/components/index.ts +9 -0
- package/packages/react/src/hooks/index.ts +8 -0
- package/packages/react/src/hooks/useDocSearch.ts +55 -0
- package/packages/react/src/hooks/useDocs.ts +57 -0
- package/packages/react/src/hooks/useDocsAdmin.ts +151 -0
- package/packages/react/src/hooks/useTableOfContents.ts +66 -0
- package/packages/react/src/index.ts +38 -0
- package/packages/react/src/pages/DocSearchPage.tsx +129 -0
- package/packages/react/src/pages/DocViewPage.tsx +158 -0
- package/packages/react/src/pages/DocsAdminPage.tsx +330 -0
- package/packages/react/src/pages/DocsIndexPage.tsx +172 -0
- package/packages/react/src/pages/index.ts +4 -0
- package/packages/react/src/useDocs.ts +58 -0
- package/packages/react/tsup.config.ts +12 -0
- package/packages/react-css/README.md +1 -0
- package/packages/react-css/package.json +37 -0
- package/packages/react-css/src/DocsLayout.tsx +117 -0
- package/packages/react-css/src/DocsProvider.tsx +93 -0
- package/packages/react-css/src/RouterDocsContent.tsx +60 -0
- package/packages/react-css/src/RouterDocsLayout.tsx +101 -0
- package/packages/react-css/src/components/DocPage.tsx +21 -0
- package/packages/react-css/src/components/DocSearch.tsx +55 -0
- package/packages/react-css/src/components/DocSidebar.tsx +56 -0
- package/packages/react-css/src/components/DocsLayout.tsx +28 -0
- package/packages/react-css/src/components/common.tsx +93 -0
- package/packages/react-css/src/components/index.ts +5 -0
- package/packages/react-css/src/hooks/index.ts +2 -0
- package/packages/react-css/src/index.ts +6 -0
- package/packages/react-css/src/index.tsx +3 -0
- package/packages/react-css/src/pages/DocViewPage.tsx +78 -0
- package/packages/react-css/src/pages/DocsAdminPage.tsx +101 -0
- package/packages/react-css/src/pages/DocsIndexPage.tsx +68 -0
- package/packages/react-css/src/pages/index.ts +3 -0
- package/packages/react-css/src/styles.css +1271 -0
- package/packages/react-css/src/useDocs.ts +58 -0
- package/packages/react-css/tsconfig.json +19 -0
- package/packages/react-css/tsup.config.ts +10 -0
- package/packages/shared/README.md +1 -0
- package/packages/shared/package.json +31 -0
- package/packages/shared/src/__tests__/docs.test.ts +69 -0
- package/packages/shared/src/config.ts +80 -0
- package/packages/shared/src/index.ts +179 -0
- package/packages/shared/src/providers/astro.ts +94 -0
- package/packages/shared/src/providers/fumadocs.ts +116 -0
- package/packages/shared/src/providers/internal.ts +80 -0
- package/packages/shared/src/types.ts +73 -0
- package/packages/shared/tsconfig.json +18 -0
- package/packages/shared/tsup.config.ts +12 -0
- package/packages/shared/vitest.config.ts +4 -0
- package/packages/solidjs/README.md +1 -0
- package/packages/solidjs/package.json +33 -0
- package/packages/solidjs/src/DocsLayout.tsx +87 -0
- package/packages/solidjs/src/DocsProvider.tsx +95 -0
- package/packages/solidjs/src/RouterDocsContent.tsx +147 -0
- package/packages/solidjs/src/RouterDocsLayout.tsx +161 -0
- package/packages/solidjs/src/components/Breadcrumbs.tsx +27 -0
- package/packages/solidjs/src/components/DocPage.tsx +110 -0
- package/packages/solidjs/src/components/DocSearch.tsx +81 -0
- package/packages/solidjs/src/components/DocSidebar.tsx +92 -0
- package/packages/solidjs/src/components/DocsLayout.tsx +38 -0
- package/packages/solidjs/src/components/EditButton.tsx +15 -0
- package/packages/solidjs/src/components/PageNavigation.tsx +31 -0
- package/packages/solidjs/src/components/TableOfContents.tsx +41 -0
- package/packages/solidjs/src/components/VersionSelector.tsx +30 -0
- package/packages/solidjs/src/components/index.ts +9 -0
- package/packages/solidjs/src/createDocs.ts +62 -0
- package/packages/solidjs/src/index.ts +28 -0
- package/packages/solidjs/src/pages/DocSearchPage.tsx +72 -0
- package/packages/solidjs/src/pages/DocViewPage.tsx +80 -0
- package/packages/solidjs/src/pages/DocsAdminPage.tsx +123 -0
- package/packages/solidjs/src/pages/DocsIndexPage.tsx +85 -0
- package/packages/solidjs/src/pages/index.ts +4 -0
- package/packages/solidjs/src/primitives/createDocSearch.ts +42 -0
- package/packages/solidjs/src/primitives/createDocs.ts +35 -0
- package/packages/solidjs/src/primitives/createDocsAdmin.ts +63 -0
- package/packages/solidjs/src/primitives/createTableOfContents.ts +51 -0
- package/packages/solidjs/src/primitives/index.ts +4 -0
- package/packages/solidjs/tsup.config.ts +12 -0
- package/packages/solidjs-css/README.md +1 -0
- package/packages/solidjs-css/package.json +36 -0
- package/packages/solidjs-css/src/DocsLayout.tsx +106 -0
- package/packages/solidjs-css/src/DocsProvider.tsx +95 -0
- package/packages/solidjs-css/src/RouterDocsContent.tsx +54 -0
- package/packages/solidjs-css/src/RouterDocsLayout.tsx +104 -0
- package/packages/solidjs-css/src/createDocs.ts +62 -0
- package/packages/solidjs-css/src/index.ts +7 -0
- package/packages/solidjs-css/src/index.tsx +17 -0
- package/packages/solidjs-css/src/pages/DocViewPage.tsx +111 -0
- package/packages/solidjs-css/src/pages/DocsAdminPage.tsx +332 -0
- package/packages/solidjs-css/src/pages/DocsIndexPage.tsx +116 -0
- package/packages/solidjs-css/src/pages/index.ts +3 -0
- package/packages/solidjs-css/src/primitives/index.ts +1 -0
- package/packages/solidjs-css/src/styles.css +1271 -0
- package/packages/solidjs-css/tsconfig.json +20 -0
- package/packages/solidjs-css/tsup.config.ts +10 -0
- package/pnpm-workspace.yaml +2 -0
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @mxn2020
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1,29 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22
|
|
@@ -0,0 +1,11 @@
|
|
|
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"
|
|
@@ -0,0 +1,15 @@
|
|
|
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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-03-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release
|
|
@@ -0,0 +1,16 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mehdi Nabhani
|
|
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 @@
|
|
|
1
|
+
# ✦ geenius-docs\n\n> Geenius Docs — Provider-based documentation system (Astro/Fumadocs/Internal) for React + SolidJS\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\n```\n\n## Usage\n\n```typescript\nimport { init } from 'geenius-docs';\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
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geenius/docs",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Geenius Docs — Provider-based documentation system (Astro/Fumadocs/Internal) for React + SolidJS",
|
|
6
|
+
"author": "Antigravity HQ",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"docs",
|
|
10
|
+
"documentation",
|
|
11
|
+
"mdx",
|
|
12
|
+
"astro",
|
|
13
|
+
"fumadocs",
|
|
14
|
+
"react",
|
|
15
|
+
"solidjs",
|
|
16
|
+
"geenius"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "pnpm -r build",
|
|
20
|
+
"clean": "pnpm -r clean",
|
|
21
|
+
"type-check": "pnpm -r type-check"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20.0.0"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./packages/shared/dist/index.d.ts",
|
|
29
|
+
"import": "./packages/shared/dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./shared": {
|
|
32
|
+
"types": "./packages/shared/dist/index.d.ts",
|
|
33
|
+
"import": "./packages/shared/dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./convex": {
|
|
36
|
+
"types": "./packages/convex/dist/index.d.ts",
|
|
37
|
+
"import": "./packages/convex/dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./react": {
|
|
40
|
+
"types": "./packages/react/dist/index.d.ts",
|
|
41
|
+
"import": "./packages/react/dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./react-css": {
|
|
44
|
+
"types": "./packages/react-css/dist/index.d.ts",
|
|
45
|
+
"import": "./packages/react-css/dist/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./solidjs": {
|
|
48
|
+
"types": "./packages/solidjs/dist/index.d.ts",
|
|
49
|
+
"import": "./packages/solidjs/dist/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./solidjs-css": {
|
|
52
|
+
"types": "./packages/solidjs-css/dist/index.d.ts",
|
|
53
|
+
"import": "./packages/solidjs-css/dist/index.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"main": "./packages/shared/dist/index.js",
|
|
57
|
+
"types": "./packages/shared/dist/index.d.ts"
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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
|
|
@@ -0,0 +1,270 @@
|
|
|
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
|
+
});
|