Skip to content

Commit f55d8ad

Browse files
authored
Merge branch 'main' into cloudflare-deployment-docs
2 parents 59a7775 + dd23540 commit f55d8ad

531 files changed

Lines changed: 20584 additions & 6497 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
ALGOLIA_API_KEY=algolia_api_key
2-
ALGOLIA_APPLICATION_ID=algolia_application_id
1+
TYPESENSE_URL=https://your-cluster.a1.typesense.net
2+
TYPESENSE_PUBLIC_API_KEY=your_search_only_api_key
3+
TYPESENSE_PRIVATE_API_KEY=typesense_private_api_key_required_for_indexing_only
4+
# Optional. Overrides the branch-derived read alias.
5+
# TYPESENSE_COLLECTION=directus-docs
36
DIRECTUS_URL=https://marketing-directus-url.com
47
GOOGLE_TAG_MANAGER_ID=GTM-PTLT3GH
5-
NUXT_UI_PRO_LICENSE=nuxt_ui_pro_license_key_needed_to_build
68
POSTHOG_API_HOST=https://directus.io/ingest
79
POSTHOG_API_KEY=phc_secret_key_here
10+
NUXT_PUBLIC_SITE_URL=https://directus.com
11+
NUXT_PUBLIC_OG_BASE_URL=https://og.directus.com
12+
# Required outside local OG worker dev.
13+
# NUXT_OG_SIGNING_SECRET=shared_secret_from_website_og_worker
14+
# OG_SIGNING_SECRET=shared_secret_from_website_og_worker
15+
# Optional. Fine-grained PAT, public repos read-only. Required for code search and raises GitHub raw rate limits.
16+
# GITHUB_TOKEN=github_pat_...

.githooks/pre-commit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if ! command -v pnpm >/dev/null 2>&1; then
5+
echo "warning: pnpm not found; skipping stable ID hook" >&2
6+
exit 0
7+
fi
8+
9+
pnpm stable-ids:ensure --staged

.githooks/pre-push

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if ! git fetch origin main --quiet; then
5+
echo "warning: failed to fetch origin/main; using local ref for redirect check" >&2
6+
fi
7+
8+
if git diff --quiet origin/main...HEAD -- content redirects.json content.config.ts; then
9+
exit 0
10+
fi
11+
12+
echo "Checking redirects for docs changes..."
13+
pnpm redirects:check

.github/workflows/search-index.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Search Index
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths: &index-paths
8+
- 'content/**'
9+
- 'scripts/index-docs.ts'
10+
- 'scripts/index-docs-chunker.ts'
11+
- 'shared/utils/parseTypesenseUrl.ts'
12+
- 'shared/utils/docsSections.ts'
13+
- 'app/utils/slugify.ts'
14+
- 'server/data/synonyms.ts'
15+
- 'lib/typesenseAlias.ts'
16+
- 'pnpm-lock.yaml'
17+
- '.github/workflows/search-index.yml'
18+
pull_request:
19+
branches:
20+
- main
21+
paths: *index-paths
22+
workflow_dispatch:
23+
24+
concurrency:
25+
group: search-index-${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: false
27+
28+
permissions:
29+
contents: read
30+
31+
jobs:
32+
preview-index:
33+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
34+
runs-on: ubuntu-latest
35+
env:
36+
TYPESENSE_URL: ${{ secrets.TYPESENSE_URL }}
37+
TYPESENSE_PUBLIC_API_KEY: ${{ secrets.TYPESENSE_PUBLIC_API_KEY }}
38+
TYPESENSE_PRIVATE_API_KEY: ${{ secrets.TYPESENSE_PRIVATE_API_KEY }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- uses: pnpm/action-setup@v4
43+
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: 22
47+
cache: pnpm
48+
49+
- name: Install dependencies
50+
run: pnpm install --frozen-lockfile
51+
52+
- name: Index preview collection
53+
run: pnpm index:docs
54+
55+
prod-index:
56+
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
57+
runs-on: ubuntu-latest
58+
env:
59+
TYPESENSE_URL: ${{ secrets.TYPESENSE_URL }}
60+
TYPESENSE_PUBLIC_API_KEY: ${{ secrets.TYPESENSE_PUBLIC_API_KEY }}
61+
TYPESENSE_PRIVATE_API_KEY: ${{ secrets.TYPESENSE_PRIVATE_API_KEY }}
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- uses: pnpm/action-setup@v4
66+
67+
- uses: actions/setup-node@v4
68+
with:
69+
node-version: 22
70+
cache: pnpm
71+
72+
- name: Install dependencies
73+
run: pnpm install --frozen-lockfile
74+
75+
- name: Index production collection
76+
run: pnpm index:docs

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ logs
2727
.vercel
2828

2929
.vscode
30+
31+
.claude/scheduled_tasks.lock

.nuxtrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setups.@nuxt/test-utils="4.0.3"

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Reusable content fragments live in `/content/_partials/` and are included via th
6262

6363
### Modules & Integrations
6464

65-
Nuxt modules: `@nuxt/ui-pro`, `@nuxt/content`, `@nuxtjs/seo`, `@nuxtjs/algolia` (conditional on env vars), `@vueuse/nuxt`, `@nuxt/scripts`. Custom PostHog module in `/modules/posthog/`.
65+
Nuxt modules: `@nuxt/ui-pro`, `@nuxt/content`, `@nuxtjs/robots`, `@nuxtjs/sitemap`, `@nuxtjs/algolia` (conditional on env vars), `@vueuse/nuxt`, `@nuxt/scripts`. Custom PostHog module in `/modules/posthog/`.
6666

6767
## Code Style
6868

README.md

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Welcome! This is the repo for [Directus' documentation](https://docs.directus.io
1313

1414
### Requirements
1515

16-
- Node.js 22
16+
- Node.js 22.18 or later
1717
- pnpm
1818

1919
### Install Dependencies
@@ -47,6 +47,48 @@ pnpm dev
4747
pnpm build
4848
```
4949

50+
### Repository Tooling
51+
52+
The repository includes scripts that keep docs routes stable when files move and that index the docs into Typesense.
53+
54+
```bash
55+
pnpm stable-ids:ensure # Add missing stableId frontmatter
56+
pnpm stable-ids:check # Validate stableId frontmatter
57+
pnpm redirects:sync # Update redirects.json for moved pages
58+
pnpm redirects:check # Check redirect coverage without writing files
59+
pnpm index:docs # Build the search index in Typesense
60+
pnpm typecheck:scripts # Type check repository scripts
61+
```
62+
63+
`pnpm install` configures `.githooks` for the repository when no custom `core.hooksPath` is set. The pre-commit hook can add missing `stableId` values to staged docs files. The pre-push hook checks redirects when docs content, redirect configuration, or content configuration changes.
64+
65+
## ✍️ Authoring Content
66+
67+
Pages live as Markdown files under `content/`. Frontmatter fields are validated by the schema in `content.config.ts`.
68+
69+
### Framework Guides
70+
71+
Framework guides live under `content/frameworks/<framework>/`. The numeric prefix on filenames (`01.`, `02.`, …) controls sidebar sort order only — it has no semantic meaning, renumber freely.
72+
73+
The `section` frontmatter field controls grouping on the `/frameworks/<framework>` hub page:
74+
75+
- `section: start-here` — appears in the "Start Here" block at the top.
76+
- `section: guides` (or unset) — appears in the "Guides" block below.
77+
78+
Minimal frontmatter for a new framework guide:
79+
80+
```yaml
81+
---
82+
title: Fetch Data from Directus with Foo
83+
description: Learn how to integrate Directus in your Foo app.
84+
section: start-here
85+
technologies:
86+
- foo
87+
navigation:
88+
title: Data Fetching
89+
---
90+
```
91+
5092
## ☁️ Deploying the Docs
5193

5294
The documentation automatically deploys to Vercel when changes are merged into the main branch. Simply:
@@ -68,9 +110,45 @@ The documentation automatically deploys to Vercel when changes are merged into t
68110
- [GitHub Issues](https://github.com/directus/docs/issues) (Report Bugs)
69111
- [Roadmap](https://roadmap.directus.io) (Roadmap & Feature Requests)
70112

71-
## Making changes to Algolia Search
113+
## 🔍 Search
114+
115+
Search is powered by [Typesense](https://typesense.org). The browser palette (`UCommandPalette`-based) lives at `app/components/DocsSearchPalette.vue` and queries Typesense directly via `app/services/typesenseService.ts`. The official `typesense` npm client is used by the indexer only.
116+
117+
### Indexing
118+
119+
The indexer at `scripts/index-docs.ts` walks `/content`, chunks each Markdown page, attaches synonyms, and pushes everything to Typesense. OpenAPI indexing is deferred to a later branch. Run it locally with:
120+
121+
```bash
122+
pnpm index:docs
123+
```
124+
125+
CI runs the same command on every push to `main` (production index) and on every PR commit (per-branch preview index). See `.github/workflows/search-index.yml`.
126+
127+
### Collection naming
128+
129+
Indexes use a blue/green slot pattern with a stable alias:
130+
131+
- `main` -> alias `directus-docs`, slots `directus-docs-a` / `directus-docs-b`
132+
- Branch `bry/foo` -> alias `directus-docs-preview-bry-foo`, slots `...-a` / `...-b`
133+
- Local branch runs use the same branch-derived alias as CI
134+
135+
Each indexer run writes to whichever slot the alias is not currently pointing at, swaps the alias, then deletes the previous slot.
136+
137+
For one-off writes, override the index target with `TYPESENSE_INDEX_TARGET=...`.
138+
139+
The browser reads from `TYPESENSE_COLLECTION` when set. Otherwise it derives the same branch alias as the indexer. The app reads the alias, never the `-a` / `-b` slot name.
140+
141+
### Ranking
142+
143+
Section boosts and personalization live in `buildPersonalizedSortBy` in `app/composables/useDocsSearch.ts`. The same `sectionPriority` array drives both the Typesense `_eval` boost order and the chip-bar render order in the palette.
144+
145+
### Synonyms
146+
147+
Search synonyms live in `server/data/synonyms.ts` and are pushed to Typesense on every indexer run. Two formats: `multiway` (equivalent terms) and `oneway` (directional shorthand -> canonical, e.g. `db -> database`). Header comment in the file explains both.
148+
149+
### Search-friendly content
72150

73-
The docs make use of the Algolia Crawler to index the content. The crawler is found at the bottom left in the Algolia dashboard under `Data Sources > Crawler > directus`. To make changes on how the crawler works, go to the `Editor` tab and make your changes. By default the crawler runs once a day but you can also manually run it. In order to tweak the ranking of search results, go to the `Search > Configure > Index > Configuration > Ranking and Sorting` tab.
151+
Write H2s and first paragraphs so they work as standalone search results.
74152

75153
<br />
76154

0 commit comments

Comments
 (0)