Skip to content

Commit 2397342

Browse files
authored
Refactor build to cake's new node based vitepress theme package (#8262)
* Refactor build to cake's new node based vitepress theme package * clarify readme
1 parent d8db449 commit 2397342

File tree

16 files changed

+2263
-357
lines changed

16 files changed

+2263
-357
lines changed

.github/.markdownlint-cli2.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"no-emphasis-as-heading": false
7676
},
7777
"customRules": [
78-
"./markdownlint-rules/no-space-after-fence.js"
78+
"./markdownlint-rules/no-space-after-fence.cjs"
7979
],
8080
"ignores": [
8181
"node_modules/**"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ function checkLink(link, docsDir, lang) {
5151
* e.g., "toc_en.json" -> "en"
5252
*/
5353
function getLangFromTocFile(tocFile) {
54-
const match = tocFile.match(/^toc_(\w+)\.json$/);
54+
const match = tocFile.match(/toc_(\w+)\.json$/);
5555
return match ? match[1] : null;
5656
}
5757

5858
/**
5959
* Main validation function
6060
*/
6161
function validateTocFiles() {
62-
const tocFiles = fs.readdirSync(".").filter((f) => f.match(/^toc_.*\.json$/));
62+
const tocFiles = fs.readdirSync(".vitepress").filter((f) => f.match(/^toc_.*\.json$/)).map((f) => `.vitepress/${f}`);
6363

6464
if (tocFiles.length === 0) {
6565
console.error("No toc_*.json files found");
File renamed without changes.

.github/workflows/docs-validation.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
- name: Validate JSON syntax
4242
run: |
43-
for file in toc_*.json; do
43+
for file in .vitepress/toc_*.json; do
4444
if ! jq empty "$file" 2>/dev/null; then
4545
echo "Invalid JSON: $file"
4646
exit 1
@@ -57,7 +57,7 @@ jobs:
5757
uses: actions/checkout@v6
5858

5959
- name: Check TOC links exist
60-
run: node bin/check-toc-links.js
60+
run: node .github/check-toc-links.cjs
6161

6262
markdown-lint:
6363
name: Lint Markdown
@@ -121,4 +121,4 @@ jobs:
121121
122122
- name: Check internal links
123123
if: steps.changed-files.outputs.files != ''
124-
run: node bin/check-links.js --baseline .github/linkchecker-baseline.json ${{ steps.changed-files.outputs.files }}
124+
run: node .github/check-links.cjs --baseline .github/linkchecker-baseline.json ${{ steps.changed-files.outputs.files }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
.vitepress/.temp
66
/node_modules/
77
.temp/
8+
docs/public/favicon/
9+
docs/public/fonts/
10+
docs/public/icons/
11+
docs/public/logo.svg
812

913
# IDE and editor specific files #
1014
#################################

.vitepress/config.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import baseConfig from '@cakephp/docs-skeleton/config'
2+
3+
import { createRequire } from "module";
4+
const require = createRequire(import.meta.url);
5+
const toc_en = require("./toc_en.json");
6+
const toc_ja = require("./toc_ja.json");
7+
8+
const versions = {
9+
text: "5.x",
10+
items: [
11+
{ text: "5.x (latest)", link: "https://book.cakephp.org/5.x/", target: '_self' },
12+
{ text: "4.x", link: "https://book.cakephp.org/4.x/", target: '_self' },
13+
{ text: "3.x", link: "https://book.cakephp.org/3.x/", target: '_self' },
14+
{ text: "2.x", link: "https://book.cakephp.org/2.x/", target: '_self' },
15+
{ text: "Next releases", items: [
16+
{ text: "5.next", link: "https://book.cakephp.org/5.next/", target: '_self' },
17+
{ text: "6.x", link: "https://book.cakephp.org/6.x/", target: '_self' },
18+
]},
19+
],
20+
};
21+
22+
// This file contains overrides for .vitepress/config.js
23+
export default {
24+
extends: baseConfig,
25+
base: "/5.x/",
26+
rewrites: {
27+
"en/:slug*": ":slug*",
28+
},
29+
sitemap: {
30+
hostname: "https://book.cakephp.org/5.x/",
31+
},
32+
themeConfig: {
33+
socialLinks: [
34+
{ icon: "github", link: "https://github.com/cakephp/cakephp" },
35+
],
36+
editLink: {
37+
pattern: "https://github.com/cakephp/docs/edit/5.x/docs/:path",
38+
text: "Edit this page on GitHub",
39+
},
40+
sidebar: toc_en,
41+
nav: [
42+
{ text: "Guide", link: "/intro" },
43+
{ text: "API", link: "https://api.cakephp.org/" },
44+
{ text: "Documentation", link: "/" },
45+
{ ...versions },
46+
],
47+
},
48+
substitutions: {
49+
'|phpversion|': { value: '8.5', format: 'bold' },
50+
'|minphpversion|': { value: '8.2', format: 'italic' },
51+
'|cakeversion|': '5.3',
52+
'|cakefullversion|': 'CakePHP 5',
53+
},
54+
locales: {
55+
root: {
56+
label: "English",
57+
lang: "en",
58+
},
59+
ja: {
60+
label: "Japanese",
61+
lang: "ja",
62+
themeConfig: {
63+
nav: [
64+
{ text: "ガイド", link: "/ja/intro" },
65+
{ text: "API", link: "https://api.cakephp.org/" },
66+
{ text: "ドキュメント", link: "/ja/" },
67+
{ ...versions },
68+
],
69+
sidebar: toc_ja,
70+
},
71+
},
72+
},
73+
};

.vitepress/theme/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '@cakephp/docs-skeleton'
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)