Commit dcd6fc45 authored by Guillaume Grossetie's avatar Guillaume Grossetie 🎧
Browse files

remove cdn reference

parent 4787c3ed
......@@ -12,6 +12,10 @@ module.exports = function (eleventyConfig, rest) {
files: ['_site/**/*'],
open: true,
})
eleventyConfig.addPassthroughCopy({
"node_modules/highlight.js/styles/default.css": "assets/css/highlightjs/default.css",
"node_modules/highlight.js/styles/monokai-sublime.css": "assets/css/highlightjs/monokai-sublime.css",
})
eleventyConfig.addExtension('adoc', {
compile: function (fileContents, path) {
return function (data) {
......
import { init as initTabSet } from './tabs-block-behavior.js'
import { init as initToggle } from './toggle-behavior.js'
import { init as initInteractiveEditor } from './interactive-editor.js'
import { init as initSyntaxHighlighting } from './syntax-highlighting.js'
initTabSet()
initToggle()
initInteractiveEditor()
initSyntaxHighlighting()
import hljs from "highlight.js/lib/highlight.js"
import xmlLanguage from "highlight.js/lib/languages/xml.js"
import asciidocLanguage from "highlight.js/lib/languages/asciidoc.js"
import markdownLanguage from "highlight.js/lib/languages/markdown.js"
import rubyLanguage from "highlight.js/lib/languages/ruby.js"
import initHljsNumbers from 'highlightjs-line-numbers.js'
export function init() {
hljs.registerLanguage('asciidoc', asciidocLanguage)
hljs.registerLanguage('xml', xmlLanguage)
hljs.registerLanguage('markdown', markdownLanguage)
hljs.registerLanguage('ruby', rubyLanguage)
initHljsNumbers(hljs)
hljs.registerLanguage("rst", function (e) {
return {}
})
if (!hljs.initHighlighting.called) {
hljs.initHighlighting.called = true
;[].slice.call(document.querySelectorAll('pre.highlight > code')).forEach(function (el) {
hljs.highlightBlock(el)
})
hljs.initLineNumbersOnLoad()
}
}
......@@ -19,6 +19,8 @@
"@codemirror/view": "^0.19.40",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"highlight.js": "^9.18.3",
"highlightjs-line-numbers.js": "^2.8.0",
"node-html-parser": "^5.2.0",
"rollup": "^2.67.0",
"rollup-plugin-terser": "^7.0.2"
......@@ -1911,6 +1913,22 @@
"he": "bin/he"
}
},
"node_modules/highlight.js": {
"version": "9.18.3",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.3.tgz",
"integrity": "sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ==",
"deprecated": "Version no longer supported. Upgrade to @latest",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/highlightjs-line-numbers.js": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/highlightjs-line-numbers.js/-/highlightjs-line-numbers.js-2.8.0.tgz",
"integrity": "sha512-TEf1gw0c8mb8nan0QwliqS7obT4cpUd9hzsGzsZLweteNnWea/VIqy5/aQqsa5wnz9lnvmtAkS1ZtDTjB/goYQ==",
"dev": true
},
"node_modules/http-errors": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
......@@ -5940,6 +5958,18 @@
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true
},
"highlight.js": {
"version": "9.18.3",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.3.tgz",
"integrity": "sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ==",
"dev": true
},
"highlightjs-line-numbers.js": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/highlightjs-line-numbers.js/-/highlightjs-line-numbers.js-2.8.0.tgz",
"integrity": "sha512-TEf1gw0c8mb8nan0QwliqS7obT4cpUd9hzsGzsZLweteNnWea/VIqy5/aQqsa5wnz9lnvmtAkS1ZtDTjB/goYQ==",
"dev": true
},
"http-errors": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
......
......@@ -8,8 +8,8 @@
{# % include 'seo.njk' % #}
{% include 'favicon.njk' %}
<title>AsciiDoc</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/styles/default.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/monokai-sublime.min.css">
<link rel="stylesheet" href="/assets/css/highlightjs/default.css">
<link rel="stylesheet" href="/assets/css/highlightjs/monokai-sublime.css">
<link rel="stylesheet" href="./assets/css/main.css">
<link rel="stylesheet" href="./assets/css/doc.css">
</head>
......@@ -166,23 +166,5 @@
</div>
</footer>
<script src="./assets/js/main.bundle.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/highlightjs-line-numbers.js/dist/highlightjs-line-numbers.min.js"></script>
<script>
hljs.registerLanguage("rst", function (e) {
return {}
})
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/languages/asciidoc.min.js"></script>
<script>
if (!hljs.initHighlighting.called) {
hljs.initHighlighting.called = true
;[].slice.call(document.querySelectorAll('pre.highlight > code')).forEach(function (el) {
hljs.highlightBlock(el)
})
hljs.initLineNumbersOnLoad()
}
</script>
</body>
</html>
......@@ -2,9 +2,27 @@ import { nodeResolve } from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs"
import { terser } from "rollup-plugin-terser"
if (process.env.BUILD === 'production') {
function wrap() {
return {
name: 'rollup-plugin-wrap',
transform(content, id) {
if (id.endsWith('highlightjs-line-numbers.js/src/highlightjs-line-numbers.js')) {
content = `export default function init(hljs) {
window.hljs = hljs
;${content}
}`;
return {
code: content,
map: { mappings: '' }
}
}
return null;
}
}
}
export default {
input: "assets/js/main.js",
output: {
......@@ -13,6 +31,7 @@ export default {
strict: false // Opal does not work in strict mode :|
},
plugins: [
wrap(),
nodeResolve({ browser: true }),
commonjs(),
process.env.BUILD === 'production' ? terser() : ''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment