Skip to content

Commit

Permalink
Adding new languages for code highlights (#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
louisachu authored May 1, 2023
1 parent ac77938 commit 3d24836
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/gatsby-theme-aio/src/components/Code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ import '@adobe/prism-adobe';
import { ActionButton } from '../ActionButton';
import PropTypes from 'prop-types';

import Prism from "prism-react-renderer/prism";

(typeof global !== "undefined" ? global : window).Prism = Prism;

const getLoader = require('prismjs/dependencies');
const components = require('prismjs/components');

const componentsToLoad = ['java', 'php', 'csharp', 'kotlin', 'swift', 'bash', 'sql', 'typescript', 'objectivec', 'yaml', 'json'];
const loadedComponents = ['clike', 'javascript'];

const loader = getLoader(components, componentsToLoad, loadedComponents);
try{
loader.load(id => {
require(`prismjs/components/prism-${id}.min.js`);
});
} catch (e) {
console.log(e);
}

const openTooltip = (setIsTooltipOpen) => {
setIsTooltipOpen(true);
setTimeout(() => {
Expand Down

0 comments on commit 3d24836

Please sign in to comment.