Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b37e8b0
feat: implement new LeftNav and RightNav components for improved navi…
shhdgit Dec 18, 2025
e39608c
chore: update subproject commit reference in docs
shhdgit Dec 18, 2025
0254666
feat: add "Improve this document" link in TitleAction component
shhdgit Dec 18, 2025
468fbf0
fix: update feedback translation for clarity in English and Japanese
shhdgit Dec 18, 2025
af715b7
fix: update TitleAction component for improved layout and button text
shhdgit Dec 19, 2025
6cb99b0
fix: update color in RightNav component for better visibility
shhdgit Dec 22, 2025
5f229c9
fix: conditionally render TOC in RightNav component
shhdgit Jan 7, 2026
8c66aff
feat: enhance header layout and functionality
shhdgit Jan 9, 2026
0915790
Merge branch 'master' into feat/restructure
shhdgit Jan 9, 2026
bc22e86
feat: add new Header components for enhanced navigation and functiona…
shhdgit Jan 10, 2026
a662b03
refactor: enhance header components and introduce mobile navigation
shhdgit Jan 10, 2026
8f3de84
refactor: reorganize getPageType utility for improved structure
shhdgit Jan 10, 2026
ed55166
refactor: replace getPageType with usePageType for improved modularity
shhdgit Jan 10, 2026
b2bd473
refactor: replace KeyboardArrowDownIcon with ChevronDownIcon across c…
shhdgit Jan 10, 2026
5f19cd3
feat: enhance HeaderNav with dynamic navigation configuration
shhdgit Jan 10, 2026
48fdade
feat: enhance navigation components with selected item handling
shhdgit Jan 10, 2026
e88d075
refactor: update HeaderAction and theme for improved button styling
shhdgit Jan 12, 2026
6cad662
refactor: replace ActionButton with Button in FeedbackSection for con…
shhdgit Jan 12, 2026
085f3f5
refactor: improve LangSwitch and theme button styles for consistency
shhdgit Jan 12, 2026
8f5cb40
refactor: simplify Box styling in NavGroup for improved readability
shhdgit Jan 12, 2026
fec2374
refactor: enhance LeftNavTree with session storage for expanded IDs a…
shhdgit Jan 12, 2026
44148c0
feat: implement clearAllNavStates function for navigation state manag…
shhdgit Jan 12, 2026
3fff947
refactor: update VersionSelect component for improved styling and con…
shhdgit Jan 12, 2026
2fbbc44
refactor: enhance theme styles for selected TreeItem states
shhdgit Jan 12, 2026
06485dd
refactor: update CloudPlan imports and usage for consistency
shhdgit Jan 12, 2026
a7d398c
Feat/link resolver v1 (#669)
shhdgit Jan 14, 2026
56953c5
Merge branch 'feat/restructure' of github.com:pingcap/website-docs in…
shhdgit Jan 14, 2026
e2e2965
refactor: remove unused CONFIG import from link resolver configuration
shhdgit Jan 14, 2026
65bacb1
feat: introduce TOCNamespace for improved navigation handling
shhdgit Jan 14, 2026
3741c4a
refactor: update navigation and path handling for TOCNamespace
shhdgit Jan 14, 2026
18fbd59
refactor: enhance URL resolver configuration for tidb and tidb-in-kub…
shhdgit Jan 14, 2026
24aebc1
feat: add link resolver and URL resolver configurations for tidb-oper…
shhdgit Jan 14, 2026
226d15e
refactor: update link and URL resolver configurations for tidb releases
shhdgit Jan 14, 2026
f1ea0ad
refactor: integrate TOCNamespace into documentation components for im…
shhdgit Jan 14, 2026
de7b3d1
refactor: enhance HeaderNavMobile component for improved navigation a…
shhdgit Jan 14, 2026
a988a42
refactor: replace pageUrl with namespace in layout and header compone…
shhdgit Jan 14, 2026
c36af24
refactor: update link resolver configuration to include language support
shhdgit Jan 14, 2026
b352edb
refactor: enhance URL and link resolver functionality with caching an…
shhdgit Jan 14, 2026
67f4e63
refactor: extend TOCNamespace for enhanced navigation in templates
shhdgit Jan 14, 2026
0a6fbc2
refactor: update URL resolver and configuration for enhanced path han…
shhdgit Jan 15, 2026
3258700
refactor: update link and URL resolver configurations for tidb releas…
shhdgit Jan 15, 2026
00f1afb
refactor: enhance popover handling in HeaderNav component
shhdgit Jan 15, 2026
a94de95
feat: add URL and link resolver documentation for improved clarity
shhdgit Jan 16, 2026
9360533
feat: add repository guidelines and enhance Header components
shhdgit Jan 16, 2026
a1f89b3
refactor: update URL mapping and link resolution for developer namespace
shhdgit Jan 16, 2026
1abb775
fix: adjust Header and Search component styles for improved layout
shhdgit Jan 16, 2026
07f17b4
fix: adjust Header component styles for improved layout
shhdgit Jan 16, 2026
605f132
refactor: standardize namespace terminology in URL mapping and link r…
shhdgit Jan 16, 2026
be3466c
chore: test commit
shhdgit Jan 16, 2026
f9aa42c
chore: update GitHub Actions workflow and clean up HeaderAction compo…
shhdgit Jan 16, 2026
eb5c6a6
feat: enhance URL mapping with nested _index rule and update TOC name…
shhdgit Jan 16, 2026
6032a74
docs: expand LinkResolver and UrlResolver configuration options in do…
shhdgit Jan 16, 2026
b683eba
feat: extend URL mapping and link resolution to include AI namespace
shhdgit Jan 16, 2026
8efcbd8
chore: update subproject commit reference in documentation
shhdgit Jan 16, 2026
49e1002
feat: refactor header height calculations and improve layout responsi…
shhdgit Jan 17, 2026
b172d30
feat: enhance header scroll behavior with CSS variables and refactor …
shhdgit Jan 17, 2026
0e6e65c
feat: add back-to-top button functionality and improve scroll behavior
shhdgit Jan 17, 2026
f3ec1bf
feat: update back-to-top button visibility for responsive design
shhdgit Jan 17, 2026
72c013c
feat: refactor navigation item selection logic and integrate into Doc…
shhdgit Jan 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .codex/skills/website-docs-url-mapping/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: website-docs-url-mapping
description: Modify URL mapping rules in the website-docs Gatsby site by editing gatsby/url-resolver/config.ts and gatsby/link-resolver/config.ts, updating Jest tests, updating gatsby/URL_MAPPING_ARCHITECTURE.md, and reviewing gatsby-plugin-react-i18next matchPath when URL prefixes or languages change.
---

# Website-docs URL Mapping

## Overview

Modify the mapping rules between docs source paths and site URLs, and resolve internal Markdown links, while keeping tests and docs in sync.

## Workflow

### 1) Gather Requirements (Clarify First)

Ask the user for “input → expected output” examples (at least 3 of each; more is better):
- Page URLs: `sourcePath/slug -> pageUrl` (whether to omit default language `/en/`, and trailing slash expectations)
- Link resolution: `(linkPath, currentPageUrl) -> resolvedUrl` (include edge cases: hash, no leading slash, relative paths, etc.)

### 2) Review Existing Design (Align Terms and Current Behavior)

Open and quickly locate the rules sections:
- `gatsby/URL_MAPPING_ARCHITECTURE.md` (Configuration Rules)
- `gatsby/url-resolver/README.md` (pattern/alias/filenameTransform)
- `gatsby/link-resolver/README.md` (direct vs path-based, conditions/pathConditions)

### 3) Edit URL Resolver (Page URLs)

Edit: `gatsby/url-resolver/config.ts`
- `pathMappings` are matched in order (first match wins); new rules usually go before more general ones.
- `sourcePattern` supports `{var}` and `{...var}`; `conditions` use extracted variables to decide applicability.
- Use `filenameTransform` to handle `_index` / `_docHome` (ignore filename or switch `targetPattern`).
- If branch display logic changes, update `aliases` as well (e.g. `{branch:branch-alias-tidb}`).

### 4) Edit Link Resolver (Markdown Links)

Edit: `gatsby/link-resolver/config.ts`
- Direct mapping: only `linkPattern` (does not depend on the current page)
- Path-based mapping: `pathPattern + linkPattern`, constrained by `pathConditions`
- Use `namespaceTransform` for namespace migrations (e.g. `develop -> developer`)
- Watch `defaultLanguage` omission logic and `url-resolver.trailingSlash` (tests should cover both)

### 5) Update/Add Tests (Prevent Regressions)

- `gatsby/url-resolver/__tests__/url-resolver.test.ts`
- `gatsby/link-resolver/__tests__/link-resolver.test.ts`

Coverage (at minimum, every new/changed rule has assertions):
- New rule match vs fallback (ordering)
- `en/zh/ja` + whether `/en/` is omitted
- `_index` vs non-`_index`
- Links: preserve hash, no leading slash, path depth, multi-segment prefixes, etc.

### 6) Run Tests

- Full suite: `yarn test`
- Or run a single test file first: `yarn test gatsby/url-resolver/__tests__/url-resolver.test.ts`, `yarn test gatsby/link-resolver/__tests__/link-resolver.test.ts`

### 7) Update Architecture Doc (Keep It In Sync)

Edit: `gatsby/URL_MAPPING_ARCHITECTURE.md`
- Update interpretations under “URL Resolver Configuration Rules” and “Link Resolver Configuration Rules”
- Keep rule numbering/order consistent with `config.ts`, and update input/output examples

### 8) Check i18n Routing (Often Required When URL Prefixes Change)

Review: `gatsby-config.js` → `gatsby-plugin-react-i18next`:
- Ensure `languages` matches supported site languages (currently `en/zh/ja`)
- Ensure `pages[].matchPath` includes any new/renamed top-level path prefixes (e.g. `developer`, `best-practices`, `api`, `releases`, and repo keys in `docs/docs.json`)
63 changes: 63 additions & 0 deletions .github/workflows/sync-nextgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: sync-nextgen

on:
push:
branches:
- "feat/restructure"

concurrency:
group: sync-nextgen
cancel-in-progress: true

permissions:
contents: write
actions: write

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Merge feat/restructure into preview-nextgen
env:
SOURCE_BRANCH: "feat/restructure"
TARGET_BRANCH: "preview-nextgen"
run: |
set -euo pipefail

git fetch origin "${SOURCE_BRANCH}" --prune
git fetch origin "${TARGET_BRANCH}" --prune || true

if git show-ref --verify --quiet "refs/remotes/origin/${TARGET_BRANCH}"; then
git switch -c "${TARGET_BRANCH}" "origin/${TARGET_BRANCH}" || git switch "${TARGET_BRANCH}"
else
# Create the target branch the first time if it doesn't exist yet.
git switch -c "${TARGET_BRANCH}" "origin/${SOURCE_BRANCH}"
fi

git merge --no-ff "origin/${SOURCE_BRANCH}" -m "sync-nextgen: merge ${SOURCE_BRANCH} into ${TARGET_BRANCH}"
git push origin "${TARGET_BRANCH}"

- name: Dispatch production workflow on preview-nextgen
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "production.yml",
ref: "preview-nextgen",
inputs: {
hash: "nextgen",
},
});
46 changes: 46 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Repository Guidelines

## Project Structure & Module Organization

- `src/`: Gatsby site code (React components, templates, state, theme, and styles).
- `gatsby/`: build-time utilities (page creation, link/url resolvers, custom plugins) and unit tests.
- `docs/`: documentation content (git submodule pointing to `pingcap/docs-staging`).
- `locale/`: i18n dictionaries (`locale/{en,zh,ja}/translation.json`).
- `static/`, `src/media/`, `images/`: static assets used by the site/README.
- Generated (do not commit): `.cache/`, `public/`, `coverage/`.

## Build, Test, and Development Commands

- `yarn`: install dependencies and apply `patches/` via `patch-package`.
- `git submodule update --init --depth 1 --remote`: fetch/update the docs submodule content.
- `yarn start` (or `yarn dev`): run local development server (Gatsby develop).
- `yarn build`: create a production build.
- `yarn serve`: serve the production build locally.
- `yarn clean`: remove Gatsby build caches (`.cache/`, `public/`).
- `yarn test`: run Jest with coverage for code under `gatsby/`.

## Coding Style & Naming Conventions

- Indentation: 2 spaces (see `.editorconfig`); keep TypeScript `strict` passing.
- Formatting: Prettier runs via Husky + lint-staged on commit (`.husky/pre-commit`).
- Components: PascalCase folders/files (e.g. `src/components/Layout/`); utilities/hooks: camelCase.
- Styles: prefer CSS Modules (`*.module.css`); shared CSS in `src/styles/*.css`.
- Imports: `tsconfig.json` sets `baseUrl: "./src"` (absolute imports like `shared/utils/...` are preferred).

## Testing Guidelines

- Framework: Jest + `ts-jest` (`jest.config.js`).
- Location/pattern: `gatsby/**/__tests__/**/*.test.{ts,tsx,js,jsx}`.
- Add/adjust tests when changing resolver logic or Gatsby build utilities.

## Commit & Pull Request Guidelines

- Commit messages follow a Conventional Commits pattern (common types: `feat:`, `fix:`, `refactor:`, `chore:`).
- PRs should include: clear description + rationale, linked issue(s), and screenshots for UI changes.
- Before requesting review, ensure `yarn test` and `yarn build` pass locally.

## Security & Configuration Tips

- Put local-only env vars in `.env.development` (e.g. `GATSBY_ALGOLIA_APPLICATION_ID`, `GATSBY_ALGOLIA_API_KEY`).
- If GitHub API rate-limits during development, set `GITHUB_AUTHORIZATION_TOKEN=...` when running commands.
- Never commit `.env*` files (they are gitignored).
4 changes: 3 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ module.exports = {
getLanguageFromPath: false,
},
{
matchPath: `/:lang?/(${Object.keys(docs.docs).join("|")})/(.*)`,
matchPath: `/:lang?/(${Object.keys(docs.docs).join(
"|"
)}|developer|best-practices|api|ai|releases)/(.*)`,
getLanguageFromPath: true,
},
{
Expand Down
5 changes: 3 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
createDocSearch,
create404,
} = require("./gatsby/create-pages");
const { createExtraType } = require("./gatsby/create-types");
const { createFrontmatter, createNavs } = require("./gatsby/create-types");
const {
createConditionalToc,
} = require("./gatsby/plugin/conditional-toc/conditional-toc");
Expand All @@ -26,6 +26,7 @@ exports.createPages = async ({ graphql, actions }) => {
};

exports.createSchemaCustomization = (options) => {
createExtraType(options);
createFrontmatter(options);
createNavs(options);
createConditionalToc(options);
};
Loading