Skip to content

Commit 7a5c214

Browse files
authored
chore: replace metalsmith-prism with highlight.js (#4493)
Remove a metalsmith plugin that hasn't been updated recently. This has several advantages: * Removes some vulnerabilities the GitHub UI is complaining about. * Eliminates an error message when building involving prism. * Uses the same highlighting library as the docs, setting the stage for possible consolidation and/or alignment.
1 parent 43205b2 commit 7a5c214

5 files changed

Lines changed: 8 additions & 401 deletions

File tree

build.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const discoverHelpers = require('metalsmith-discover-helpers');
1818
const discoverPartials = require('metalsmith-discover-partials');
1919
const layouts = require('metalsmith-layouts');
2020
const markdown = require('@metalsmith/markdown');
21-
const prism = require('metalsmith-prism');
2221
const permalinks = require('@metalsmith/permalinks');
2322
const pagination = require('metalsmith-yearly-pagination');
2423
const defaultsDeep = require('lodash.defaultsdeep');
@@ -46,13 +45,10 @@ const nodejsVersionsContent = require('fs')
4645
.readFileSync('./source/nodejsVersions.md')
4746
.toString();
4847

49-
// Set up the Markdown renderer that we'll use for our Metalsmith build process,
50-
// with the necessary adjustments that we need to make in order to have Prism
51-
// work.
48+
// Set up the Markdown renderer that we'll use for our Metalsmith build process.
5249
const renderer = new marked.Renderer();
5350
renderer.heading = anchorMarkdownHeadings;
5451
const markedOptions = {
55-
langPrefix: 'language-',
5652
renderer
5753
};
5854

@@ -162,7 +158,6 @@ function buildLocale(source, locale, opts) {
162158
)
163159
.use(markdown(markedOptions))
164160
.use(githubLinks({ locale, site: i18nJSON(locale) }))
165-
.use(prism())
166161
// Set pretty permalinks, we don't want .html suffixes everywhere.
167162
.use(
168163
permalinks({

layouts/partials/footer.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@
3636
</footer>
3737

3838
<script src="/static/js/main.js" async defer></script>
39+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/highlight.min.js" integrity="sha512-BNc7saQYlxCL10lykUYhFBcnzdKMnjx5fp5s5wPucDyZ7rKNwCoqJh1GwEAIhuePEK4WM9askJBRsu7ma0Rzvg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
40+
<script>hljs.highlightAll();</script>

layouts/partials/html-head.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600&display=fallback">
99
<link rel="stylesheet" href="/static/css/styles.css">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/styles/a11y-dark.min.css" integrity="sha512-Vj6gPCk8EZlqnoveEyuGyYaWZ1+jyjMPg8g4shwyyNlRQl6d3L9At02ZHQr5K6s5duZl/+YKMnM3/8pDhoUphg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
1011

1112
<meta name="author" content="{{ site.author }}">
1213
<meta name="robots" content="{{#if robots}}{{ robots }}{{else}}index, follow{{/if}}">

0 commit comments

Comments
 (0)