Skip to content

Commit 06cfb47

Browse files
authored
fix(docs): create local marked-loader.js (#2380)
1 parent ff25314 commit 06cfb47

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

docs/nuxt.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs')
2+
const path = require('path')
23
const hljs = require('highlightjs')
34
const marked = require('marked')
45

@@ -35,14 +36,17 @@ module.exports = {
3536
extend (config, { loaders }) {
3637
config.resolve.alias.vue = 'vue/dist/vue.common'
3738

39+
config.resolveLoader.alias = config.resolveLoader.alias || {}
40+
config.resolveLoader.alias['marked-loader'] = path.join(__dirname, './utils/marked-loader')
41+
3842
config.devtool = 'source-map'
3943

4044
config.module.rules.push({
4145
test: /\.md$/,
4246
use: [
4347
{ loader: 'html-loader' },
4448
{
45-
loader: 'markdown-loader',
49+
loader: 'marked-loader',
4650
options: {
4751
renderer,
4852
headerIds: true,

docs/utils/marked-loader.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Based on https://github.com/peerigon/markdown-loader/
2+
// Converts markdown files into HTML format
3+
// Config options are passed directly to marked
4+
// - https://marked.js.org/#/USING_ADVANCED.md#options
5+
6+
const marked = require('marked')
7+
const { getOptions } = require('loader-utils')
8+
9+
module.exports = function (markdown) {
10+
// merge params and default config
11+
const options = getOptions(this)
12+
// Make results cacheable
13+
this.cacheable()
14+
// Pass our options
15+
marked.setOptions(options)
16+
// Return the converted file as HTML
17+
return marked(markdown)
18+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@
113113
"highlightjs": "^9.12.0",
114114
"html-loader": "^0.5.5",
115115
"jest": "^23.6.0",
116+
"loader-utils": "^1.2.3",
116117
"lodash": "^4.17.11",
117-
"markdown-loader": "^4.0.0",
118-
"marked": "^0.5.2",
118+
"marked": "^0.6.0",
119119
"node-sass": "^4.11.0",
120120
"nuxt-edge": "^2.4.0-25770819.0e9eca2f",
121121
"postcss-cli": "^6.1.0",

0 commit comments

Comments
 (0)