Skip to content

Commit d4e902a

Browse files
committed
feat: add Docusaurus redirect mapping for stable and placeholder URLs
1 parent c5bf74e commit d4e902a

File tree

4 files changed

+544
-362
lines changed

4 files changed

+544
-362
lines changed

app-links.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* @file Phoenix “App Links” redirect map for Docusaurus.
3+
*
4+
* Integrates with: @docusaurus/plugin-client-redirects (>= 3.7.0)
5+
*
6+
* WHAT THIS IS
7+
* ------------
8+
* A central, stable index of URLs the Phoenix app (desktop/browser) and docs
9+
* can safely link to as: https://docs.phcode.dev/app-links/*
10+
*
11+
* You can also use these entries to **predefine placeholder URLs**
12+
* before the corresponding documentation exists — this allows wiring
13+
* links into the Phoenix app early, while keeping URLs stable for when
14+
* docs are added later.
15+
*
16+
* The idea: the `from` side never changes; you’re free to restructure docs and
17+
* simply update the `to` target here—no broken links in the app or shared docs.
18+
*
19+
* DEV VS BUILD
20+
* ------------
21+
* - `npm run start` (Docusaurus dev server): redirect pages are NOT generated.
22+
* You will NOT see /app-links/* work here.
23+
* - To verify redirects end-to-end:
24+
* 1) `npm run build` → generates static pages for each redirect
25+
* 2) `npm run serve` → serves the built site with working redirects
26+
*
27+
* SCHEMA
28+
* ------
29+
* Each entry: { from: string, to: string }
30+
* - `from` MUST be an absolute path starting with `/app-links/...`
31+
* - `to` can be:
32+
* • an internal path (e.g. `/docs/editing-text#line-height`)
33+
* • a full external URL (e.g. `https://google.com`)
34+
*
35+
* CONVENTIONS & TIPS
36+
* ------------------
37+
* - Keep all stable links under `/app-links/*` to make deprecations easy.
38+
* - Use leading slashes for internal `to` values; include hash anchors if needed.
39+
* - External URLs are supported; the plugin will create a client page that
40+
* performs a redirect (meta refresh + JS).
41+
*
42+
* EXTERNAL REDIRECT EXAMPLE
43+
* -------------------------
44+
* {
45+
* from: '/app-links/google-search',
46+
* to: 'https://google.com',
47+
* }
48+
*
49+
* TEST CHECKLIST
50+
* --------------
51+
* - After updating this file:
52+
* - Run `npm run build` then `npm run serve`
53+
* - Open a few /app-links/* routes and confirm they land on the right pages
54+
*/
55+
56+
57+
/** @type {Array<{from: string, to: string}>} */
58+
export const appLinks = [
59+
{
60+
from: '/app-links/extn-line-height', // https://docs.phcode.dev/app-links/extn-line-height
61+
to: '/docs/editing-text#line-height', // https://docs.phcode.dev/docs/editing-text#line-height
62+
},
63+
{
64+
from: '/app-links/live-preview',
65+
to: '/docs/Features/Live Preview/live-preview',
66+
},
67+
{
68+
from: '/app-links/keyboard-shortcuts',
69+
to: '/docs/Features/keyboard-shortcuts',
70+
},
71+
{
72+
from: '/app-links/auto-rename-tag',
73+
to: '/docs/editing-text#auto-rename-tag',
74+
},
75+
{
76+
from: '/app-links/indent-guide-lines',
77+
to: '/docs/editing-text#indent-guide-lines',
78+
},
79+
{
80+
from: '/app-links/emmet',
81+
to: '/docs/editing-text#emmet',
82+
}
83+
];

docusaurus.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { themes as prismThemes } from "prism-react-renderer";
88
import remarkMath from "remark-math";
99
import rehypeKatex from "rehype-katex";
10+
import { appLinks } from "./app-links.js";
1011

1112
/** @type {import('@docusaurus/types').Config} */
1213
const config = {
@@ -107,6 +108,12 @@ const config = {
107108
[
108109
"@gracefullight/docusaurus-plugin-microsoft-clarity",
109110
{ projectId: "nq44d74m1v" }
111+
],
112+
[
113+
"@docusaurus/plugin-client-redirects",
114+
{
115+
redirects: appLinks,
116+
}
110117
]
111118
],
112119
themeConfig:

0 commit comments

Comments
 (0)