Skip to content

Commit f9ed0d4

Browse files
committed
Rename preview index and move to docs
1 parent 58df808 commit f9ed0d4

File tree

6 files changed

+16
-268
lines changed

6 files changed

+16
-268
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.log
44
/_playwright-report
55
/_playwright-results
6+
/docs/preview.html
67
/lib
78
/node_modules
89
/themes

build/html.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ const __dirname = path.dirname(__filename);
88
// Preview
99
// =============================================================================
1010
function generatePreview() {
11-
const file = 'index.html';
1211
const srcPath = path.resolve(__dirname, '..', 'docs');
13-
const srcHTML = fs.readFileSync(path.resolve(srcPath, file), 'utf8');
14-
const outPath = path.resolve(__dirname, '..');
12+
const srcHTML = fs.readFileSync(path.resolve(srcPath, 'index.html'), 'utf8');
13+
const outPath = path.resolve(__dirname, '..', 'docs');
1514
const outHTML = srcHTML
15+
// Append title
16+
.replace(/(<\/title>)/g, ' (Preview)$1')
1617
// Replace CDN URLs with local paths
17-
.replace(/\/\/cdn.jsdelivr.net\/npm\/docsify@4\//g, '/')
18-
// Enable basePath to simulate /docs as root
19-
.replace(/(\/\/ )(basePath:)/, '$2');
18+
.replace(/\/\/cdn.jsdelivr.net\/npm\/docsify@4\//g, '/');
2019

21-
fs.writeFileSync(path.resolve(outPath, file), outHTML);
20+
fs.writeFileSync(path.resolve(outPath, 'preview.html'), outHTML);
2221
}
2322

2423
generatePreview();

docs/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1',
8888
},
8989
auto2top: true,
90-
// basePath: 'docs', // Required for Vercel preview deployment
9190
coverpage: true,
9291
executeScript: true,
9392
loadSidebar: true,

index.html

Lines changed: 0 additions & 238 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@
4242
"docker:test:integration": "npm run docker:cli -- test:integration",
4343
"docker:test:unit": "npm run docker:cli -- test:unit",
4444
"docker:test": "npm run docker:cli -- test",
45-
"prettier": "prettier . --write",
45+
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
4646
"lint:fix": "eslint . --fix",
4747
"lint": "prettier . --check && eslint .",
4848
"postinstall": "opencollective-postinstall",
4949
"prepare": "npm run build",
50+
"prettier": "prettier . --write",
5051
"pub:next": "cross-env RELEASE_TAG=next sh build/release.sh",
5152
"pub": "sh build/release.sh",
52-
"serve": "node server",
53-
"serve:dev": "node server --dev",
53+
"serve:dev": "npm run serve -- --dev",
54+
"serve": "npm run build && node server",
5455
"test:e2e": "playwright test",
5556
"test:integration": "npm run jest -- --selectProjects integration",
5657
"test:unit": "npm run jest -- --selectProjects unit",
5758
"test": "npm run jest && run-s test:e2e",
58-
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
5959
"watch:css": "npm run css -- -o themes -w",
6060
"watch:js": "node build/build.js"
6161
},

server.config.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,10 @@ const defaults = {
1414
match: /https?.*\/CHANGELOG.md/g,
1515
replace: '/CHANGELOG.md',
1616
},
17-
{
18-
// CDN defaults (w/o path)
19-
// Match: Full URL
20-
// Ex1: //cdn.com/package-name
21-
// Ex2: http://cdn.com/package-name@1.0.0
22-
// Ex3: https://cdn.com/package-name@latest
23-
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*(?=["'])/g,
24-
replace: '/lib/docsify.min.js',
25-
},
26-
{
27-
// CDN paths
28-
// Match: Path only
29-
// Ex1: //cdn.com/package-name/path/file.js => /path/file.js
30-
// Ex2: http://cdn.com/package-name@1.0.0/path/file.js => /path/file.js
31-
// Ex3: https://cdn.com/package-name@latest/path/file.js => /path/file.js
32-
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*\/(?:lib\/)/g,
33-
replace: '/lib/',
34-
},
3517
],
3618
server: {
3719
baseDir: 'docs',
20+
index: 'preview.html',
3821
routes: {
3922
'/changelog.md': path.resolve(__dirname, 'CHANGELOG.md'),
4023
'/lib': path.resolve(__dirname, 'lib'),
@@ -58,6 +41,10 @@ export default {
5841
prod: {
5942
...defaults,
6043
port: 8080,
44+
server: {
45+
...defaults.server,
46+
index: 'index.html',
47+
},
6148
},
6249
// Test: (watch disabled, blank page route, unique port)
6350
test: {

0 commit comments

Comments
 (0)