Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Clean up server implementation and update test docs (#2316)
- Replace live-server with existing Browsersync dependency as web server - Remove duplicate `index.html` file - Add `build:html` script to generate `/docs/preview.html`
- Loading branch information
1 parent
cf61192
commit 1c5a701
Showing
23 changed files
with
898 additions
and
2,918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import * as url from 'node:url'; | ||
import prettier from 'prettier'; | ||
import stripIndent from 'common-tags/lib/stripIndent/index.js'; | ||
|
||
const __filename = url.fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const prettierConfig = prettier.resolveConfig.sync(__dirname); | ||
|
||
// Preview | ||
// ============================================================================= | ||
function generatePreview() { | ||
const comment = stripIndent` | ||
<!-- | ||
This file is generated by the build/html.js script. | ||
Do not edit this file directly. | ||
--> | ||
`; | ||
const srcFile = 'index.html'; | ||
const srcPath = path.resolve(__dirname, '..', 'docs'); | ||
const srcHTML = fs.readFileSync(path.resolve(srcPath, srcFile), 'utf8'); | ||
const outFile = 'preview.html'; | ||
const outPath = path.resolve(__dirname, '..', 'docs'); | ||
const outHTML = srcHTML | ||
// Append comment | ||
.replace(/(<!DOCTYPE html>)/, `${comment}\n$1`) | ||
// Modify title | ||
.replace(/(<\/title>)/, ' (Preview)$1') | ||
// Replace CDN URLs with local paths | ||
.replace(/\/\/cdn.jsdelivr.net\/npm\/docsify@4\//g, '/'); | ||
const formattedHTML = prettier.format(outHTML, { | ||
...prettierConfig, | ||
filepath: outFile, | ||
}); | ||
|
||
console.log(`\nBuilding ${outFile} in ${outPath}`); | ||
|
||
fs.writeFileSync(path.resolve(outPath, outFile), formattedHTML); | ||
} | ||
|
||
generatePreview(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1c5a701
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docsify-preview – ./
www.docsifyjs.org
docsifyjs.org
docsify-preview-docsifyjs.vercel.app
docsify-preview-git-develop-docsifyjs.vercel.app
docsify-preview.vercel.app