Skip to content

Commit

Permalink
Merge pull request #12 from jorenbroekema/chore/highlight-theme
Browse files Browse the repository at this point in the history
chore: inline hightlight.js css theme for deploy
  • Loading branch information
jorenbroekema authored Jun 27, 2021
2 parents f385998 + 379df92 commit 4359ec5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.d.ts
coverage
demo/index.html
**/custom-elements.json
demo/highlight-hybrid.css
**/custom-elements.json
2 changes: 1 addition & 1 deletion demo/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
content="A Web Component abstraction to declaratively render elements that depend on asynchronous processes"
/>
<title>Suspense Element</title>
<link rel="stylesheet" href="../node_modules/highlight.js/styles/hybrid.css" />
<link rel="stylesheet" href="./highlight-hybrid.css" />
<link rel="stylesheet" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
Expand Down
7 changes: 7 additions & 0 deletions marked/buildHtmlFromMd.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@ export const buildHtmlFromMd = async () => {
path.resolve(rootFolder, `index.html`),
template.replace('{{ content }}', htmlString),
);

// Pick a highlight.js theme and put it in the rootfolder so this folder can
// be deployed and work anywhere (e.g. netlify, heroku, whatever).
await fs.copyFile(
path.resolve('node_modules', 'highlight.js', 'styles', 'hybrid.css'),
path.resolve(rootFolder, 'highlight-hybrid.css'),
);
}
};
2 changes: 2 additions & 0 deletions marked/watch-marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { buildHtmlFromMd } from './buildHtmlFromMd.js';

const watcher = chokidar.watch(path.resolve());

buildHtmlFromMd();

watcher.on('change', (filePath) => {
if (filePath.endsWith('.md') || filePath.endsWith('template.html') || filePath.endsWith('.css')) {
buildHtmlFromMd();
Expand Down

0 comments on commit 4359ec5

Please sign in to comment.