Skip to content

Commit

Permalink
fix(client): enable prism when ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Feb 7, 2021
1 parent 5d551b3 commit fc72e09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
12 changes: 2 additions & 10 deletions packages/client/src/components/ContentView/Base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, memo } from 'react';
import { SlideCore } from '../SlideCore';
import { Prism } from '../../setup/prism';
import { createVMEnv } from '../../utils/createVMEnv';
import { getSearchParams } from '../../utils/getSearchParams';
import { useMermaid } from '../../hooks/useMermaid';

export const Base = memo(
Expand All @@ -14,19 +14,11 @@ export const Base = memo(
mermaid?.reload();
}

(async () => {
const { Prism } = await import('../../setup/prism');

Prism.highlightAll();
})();
Prism.highlightAll();
}, [hash]);
}

useEffect(() => {
// don't run when creating html
if (!getSearchParams().get('ssr')) {
import(/* webpackMode: "eager" */ '../../setup/prism');
}
if (slides.some(({ fusumaProps }) => !!fusumaProps.hasExecutableCode)) {
createVMEnv();
}
Expand Down
5 changes: 2 additions & 3 deletions packages/client/src/setup/prism.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Prism from 'prismjs';

import(/* webpackPreload: true */ '../../assets/style/code.css');
import '../../assets/style/code.css';

// check https://github.com/PrismJS/prism/issues/1487
Prism.highlightAll();
setTimeout(Prism.highlightAll);

export { Prism };
7 changes: 2 additions & 5 deletions packages/fusuma/src/server/dynamicRenderingServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ async function dynamicRenderingServer(outputDirPath, publicPath, spinner, isThum
if (issues.length) {
spinner.stop();

// only filter code 'WCAG2AA.Principle1.Guideline1_4.1_4_3.G145.Fail'
const filteredIssues = issues.filter(({ code, context }) => {
return !(
code === 'WCAG2AA.Principle1.Guideline1_4.1_4_3.G145.Fail' && context.includes('language-')
);
const filteredIssues = issues.filter(({ selector }) => {
return !selector.includes('> code');
});

if (filteredIssues.length) {
Expand Down

0 comments on commit fc72e09

Please sign in to comment.