docs: auto detect languages from demo main file

This commit is contained in:
Hans Pagel 2021-02-11 16:11:33 +01:00
parent 4ed025e210
commit 30fccac47c
4 changed files with 21 additions and 19 deletions

View File

@ -23,11 +23,6 @@ export default {
required: true,
},
mode: {
type: String,
default: 'vue',
},
inline: {
type: Boolean,
default: false,
@ -52,7 +47,7 @@ export default {
computed: {
query() {
return `mode=${this.mode}&inline=${this.inline}&highlight=${this.highlight}&showSource=${this.showSource}`
return `inline=${this.inline}&highlight=${this.highlight}&showSource=${this.showSource}`
},
},

View File

@ -7,11 +7,6 @@ export default {
required: true,
},
mode: {
type: String,
default: 'vue',
},
inline: {
type: Boolean,
default: false,
@ -41,7 +36,6 @@ export default {
props() {
return {
name: this.name,
mode: this.mode,
inline: this.inline,
highlight: this.highlight,
showSource: this.showSource,
@ -49,14 +43,27 @@ export default {
},
mainFile() {
const file = this.files
.find(item => item.path.endsWith('index.vue') || item.path.endsWith('index.jsx'))
if (!file) {
if (!this.mainFilePath) {
return false
}
return require(`~/demos/${file.path}`).default
return require(`~/demos/${this.mainFilePath}`).default
},
mainFilePath() {
const file = this.files.find(item => item.path.endsWith('index.vue') || item.path.endsWith('index.jsx'))
if (file) {
return file.path
}
},
mode() {
if (this.mainFilePath?.endsWith('.jsx')) {
return 'react'
}
return 'vue'
},
},

View File

@ -7,4 +7,4 @@ The following guide describes how to integrate tiptap with your [Next.js](https:
TODO
<demo name="React" mode="react" />
<demo name="React" />

View File

@ -7,4 +7,4 @@ The following guide describes how to integrate tiptap with your [React](https://
TODO
<demo name="React" mode="react" />
<demo name="React" />