Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: changes preview. #2322

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c2c0d76
Preven dev site break on Carbon Ads plugin error
jhildenbiddle Dec 1, 2023
71a5fd3
Replace live-server with browsersync
jhildenbiddle Dec 2, 2023
4756e59
Update test docs
jhildenbiddle Dec 2, 2023
34477d8
Preview fix test
jhildenbiddle Dec 3, 2023
0709c47
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
adad7b3
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
0bcc4f3
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
b7cf1a3
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
f9b969c
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
8a9a649
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
58df808
Preview fix test (continued)
jhildenbiddle Dec 3, 2023
f9ed0d4
Rename preview index and move to docs
jhildenbiddle Dec 4, 2023
b5848b9
Remove need for duplicate themes folder in root
jhildenbiddle Dec 4, 2023
5b21dac
Handle server args and log config details on start
jhildenbiddle Dec 4, 2023
9373ab6
Remove unnecessary entry
jhildenbiddle Dec 4, 2023
a3e92b3
Append build comment to preview.html
jhildenbiddle Dec 4, 2023
9f11819
Build HTML only on serve:dev
jhildenbiddle Dec 4, 2023
4904ef3
Add Vercel preview redirect
jhildenbiddle Dec 4, 2023
b55fb54
Fix lint error
jhildenbiddle Dec 4, 2023
9c2d29f
Clean up index.html
jhildenbiddle Dec 4, 2023
239402b
update: changes.
Koooooo-7 Dec 5, 2023
63b7294
ci.
Koooooo-7 Dec 5, 2023
5986b29
chore: polish.
Koooooo-7 Dec 5, 2023
cb7a7f0
chore: polish.
Koooooo-7 Dec 5, 2023
670109d
fix: test.
Koooooo-7 Dec 5, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*.log
/_playwright-report
/_playwright-results
/index.html
/lib
/node_modules
/themes

# exceptions
!.gitkeep
47 changes: 47 additions & 0 deletions build/html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 basePath = "basePath: '/docs/',";
const srcFile = 'index.html';
const srcPath = path.resolve(__dirname, '..', 'docs');
const srcHTML = fs.readFileSync(path.resolve(srcPath, srcFile), 'utf8');
const outFile = 'index.html';
const outPath = path.resolve(__dirname, '..');
const outHTML = srcHTML
// Append comment
.replace(/(<!DOCTYPE html>)/, `${comment}\n$1`)
// Modify title
.replace(/(<\/title>)/, ' (Preview)$1')
// Replace docsify.min.js to docsify.js
.replace(/docsify.min.js/, 'docsify.js')
// Replace CDN URLs with local paths
.replace(/\/\/cdn.jsdelivr.net\/npm\/docsify@4\//g, '/')
// Inject basePath, use nameLink as an "archor"
.replace(/(nameLink)/, `${basePath}\n$1`);
const formattedHTML = prettier.format(outHTML, {
...prettierConfig,
filepath: outFile,
});

console.log(`\nBuilding ${outFile} in ${outPath}`);

fs.writeFileSync(path.resolve(outPath, outFile), formattedHTML);
}

generatePreview();
34 changes: 15 additions & 19 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@
width: auto !important;
}
</style>
<script>
(function () {
const lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);

// Set html "lang" attribute based on URL
if (lang) {
document.documentElement.setAttribute('lang', lang[1]);
}
})();
</script>
</head>

<body>
<div id="app">Loading ...</div>
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1"></script>
<script>
// Set html "lang" attribute based on URL
const lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);

if (lang) {
document.documentElement.setAttribute('lang', lang[1]);
}

// Docsify configuration
window.$docsify = {
alias: {
Expand Down Expand Up @@ -184,7 +187,9 @@
},
},
plugins: [
DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'),
function () {
DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg');
},
function (hook, vm) {
hook.beforeEach(html => {
if (/githubusercontent\.com/.test(vm.route.file)) {
Expand Down Expand Up @@ -214,21 +219,12 @@
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/ga.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/matomo.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-markdown.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-nginx.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
<script>
// Public site only
if (/docsify/.test(location.host)) {
document.write(
'<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/ga.min.js"><\/script>'
);
document.write(
'<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/matomo.min.js"><\/script>'
);
}
</script>
<script src="//cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js"></script>
<!-- <script src="//cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script> -->
</body>
Expand Down
190 changes: 0 additions & 190 deletions index.html

This file was deleted.

6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TEST_HOST } from './test/config/server.js';
import serverConfig from './server.config.js';

const { hostname, port } = serverConfig.test;
const TEST_HOST = `http://${hostname}:${port}`;
const sharedConfig = {
errorOnDeprecated: true,
globalSetup: './test/config/jest.setup.js',
Expand All @@ -11,6 +13,8 @@ const sharedConfig = {
testURL: `${TEST_HOST}/_blank.html`,
};

process.env.TEST_HOST = TEST_HOST;

export default {
transform: {},
projects: [
Expand Down
Loading