File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1+ // @ts -check
2+
13/**
24 * Pre Render JavaScript
35 */
@@ -36,6 +38,9 @@ const ssr = async url => {
3638 req . continue ( )
3739 } )
3840
41+ await page . evaluateOnNewDocument ( ( ) => {
42+ window . isPuppeteer = true
43+ } )
3944 await page . goto ( url , { waitUntil : 'networkidle2' } )
4045
4146 // https://github.com/lichtquelle/generate-static-site/blob/main/src/crawl.ts
Original file line number Diff line number Diff line change 2121 < script SSROnly src ="//cdn.jsdelivr.net/npm/marked@3/lib/marked.min.js "> </ script >
2222
2323 < script >
24- const darkMode = window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
25- const highlightTheme = darkMode ? 'github-dark.min.css' : 'github.min.css'
26- const link = document . createElement ( 'link' )
27- link . rel = 'stylesheet'
28- link . href = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/' + highlightTheme
29- document . head . appendChild ( link )
24+ // we do not want to to be pre-rendered
25+ const isPuppeteer = window . isPuppeteer === true
26+ if ( ! isPuppeteer ) {
27+ const darkMode = window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
28+ const highlightTheme = darkMode ? 'github-dark.min.css' : 'github.min.css'
29+ const link = document . createElement ( 'link' )
30+ link . rel = 'stylesheet'
31+ link . href = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/' + highlightTheme
32+ document . head . appendChild ( link )
33+ }
3034 </ script >
3135 < script src ="
//cdn.jsdelivr.net/gh/highlightjs/[email protected] /build/highlight.min.js "
> </ script > 3236 </ head >
You can’t perform that action at this time.
0 commit comments