Skip to content

Commit

Permalink
fix review, add raw-loader and use vue-markdown-render instead
Browse files Browse the repository at this point in the history
  • Loading branch information
preschian committed Mar 23, 2022
1 parent 2f1699e commit dceee3b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
33 changes: 29 additions & 4 deletions components/ContentMarkdown.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
<template>
<section class="content">
<Contributing v-if="type === 'contribute'" />
<FirstTime v-else />
<VueMarkdown :source="text()" :options="options" />
</section>
</template>

<script lang="ts">
import { Component, Vue, Prop } from 'nuxt-property-decorator'
import hljs from 'highlight.js'
import Contributing from '../CONTRIBUTING.md'
import FirstTime from '../FIRST_TIME.md'
const highlight = function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(str, { language: lang }).value
} catch (__) {
return ''
}
}
return ''
}
@Component({
components: {
Contributing,
FirstTime,
VueMarkdown: () => import('vue-markdown-render'),
},
data() {
return {
options: {
highlight,
},
}
},
})
export default class Contribute extends Vue {
@Prop(String) public type!: 'contribute' | 'first_time'
text() {
if (this.type === 'contribute') {
return Contributing
}
return FirstTime
}
}
</script>

Expand Down
23 changes: 1 addition & 22 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import hljs from 'highlight.js'
import defineApolloConfig, {
toApolloEndpoint,
} from './utils/config/defineApolloConfig'
Expand Down Expand Up @@ -269,27 +268,7 @@ export default {
// add markdown loader
config.module.rules.push({
test: /\.md$/,
loaders: [
'vue-loader',
{
loader: 'vue-md-loader',
options: {
markdown: {
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(str, { language: lang }).value
} catch (__) {
return ''
}
}

return ''
},
},
},
},
],
use: 'raw-loader',
})

config.module.rules.push({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@
"lint-staged": "^12.3.7",
"netlify-lambda": "^2.0.15",
"prettier": "2.6.0",
"raw-loader": "^4.0.2",
"sass": "^1.49.9",
"sass-loader": "^10.2",
"typescript": "^4.6.2",
"vue-debounce-decorator": "^1.0.1",
"vue-md-loader": "1.1.10",
"vue-template-compiler": "^2.6.14"
}
}
21 changes: 10 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9483,7 +9483,7 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==

highlight.js@^11.0.0, highlight.js@^11.5.0:
highlight.js@^11.5.0:
version "11.5.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.5.0.tgz#00abb7ed926491adbdabc93a4f3fd2b88b451b4a"
integrity sha512-SM6WDj5/C+VfIY8pZ6yW6Xa0Fm1tniYVYWYW1Q/DcMnISZFrC3aQAZZZFAAZtybKNrGId3p/DNbFTtcTXXgYBw==
Expand Down Expand Up @@ -11601,7 +11601,7 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

markdown-it@^12.0.0, markdown-it@^12.2.0:
markdown-it@^12.2.0:
version "12.3.2"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.3.2.tgz#bf92ac92283fe983fe4de8ff8abfb5ad72cd0c90"
integrity sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==
Expand Down Expand Up @@ -13955,6 +13955,14 @@ raw-body@2.4.3:
iconv-lite "0.4.24"
unpipe "1.0.0"

raw-loader@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.2.tgz#1aac6b7d1ad1501e66efdac1522c73e59a584eb6"
integrity sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==
dependencies:
loader-utils "^2.0.0"
schema-utils "^3.0.0"

rc9@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/rc9/-/rc9-1.2.0.tgz#ef098181fdde714efc4c426383d6e46c14b1254a"
Expand Down Expand Up @@ -16546,15 +16554,6 @@ vue-markdown-render@^1.1.3:
markdown-it "^12.2.0"
vue "^2.6.14"

vue-md-loader@1.1.10:
version "1.1.10"
resolved "https://registry.yarnpkg.com/vue-md-loader/-/vue-md-loader-1.1.10.tgz#ab9a4990568d5f346c4d4b9cd8c020f0992de82e"
integrity sha512-oID1rdyL7pvC7utPUXGkz2wjnjjrsUnyAHjoYb3qcM6VumvjkJGZG88/CcJOLpguXev5Ofhz3gph0u1v6Kp2tA==
dependencies:
highlight.js "^11.0.0"
loader-utils "^2.0.0"
markdown-it "^12.0.0"

vue-meta@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-2.4.0.tgz#a419fb4b4135ce965dab32ec641d1989c2ee4845"
Expand Down

0 comments on commit dceee3b

Please sign in to comment.