mirror of
https://github.com/EvolutionAPI/evolution-manager.git
synced 2025-12-24 05:07:44 -06:00
Update doc load and add nvm doc
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</v-btn>
|
||||
</v-app-bar>
|
||||
|
||||
<v-navigation-drawer :width="200" v-model="drawer">
|
||||
<v-navigation-drawer :width="300" v-model="drawer">
|
||||
<v-select
|
||||
:value="lang"
|
||||
:items="lang_list"
|
||||
@@ -33,10 +33,10 @@
|
||||
<v-divider></v-divider>
|
||||
<v-list-item
|
||||
link
|
||||
:title="doc"
|
||||
v-for="doc in docs"
|
||||
:key="doc"
|
||||
:to="{ name: 'doc', params: { doc } }"
|
||||
:title="doc.title || doc.filename || doc.path"
|
||||
v-for="(doc, i) in docs"
|
||||
:key="i"
|
||||
:to="{ name: 'doc', params: { doc: doc.filename || doc.path } }"
|
||||
/>
|
||||
</v-navigation-drawer>
|
||||
</template>
|
||||
@@ -67,12 +67,11 @@ export default {
|
||||
return this.DocStore.lang;
|
||||
},
|
||||
docs() {
|
||||
return Object.keys(this.DocStore.docs).filter((doc) => doc !== "index");
|
||||
return Object.values(this.DocStore.docs).map((doc) => doc[this.lang]).filter((doc) => doc);
|
||||
},
|
||||
dark() {
|
||||
return this.theme.global.current.dark;
|
||||
},
|
||||
files() {},
|
||||
},
|
||||
mounted() {
|
||||
this.DocStore.loadDocs();
|
||||
|
||||
@@ -20,7 +20,7 @@ export const useDocStore = defineStore('doc', {
|
||||
try {
|
||||
const { languages, docs } = getFileTree();
|
||||
this.languages = languages;
|
||||
this.docs = docs;
|
||||
this.docs = docs;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ export const useDocStore = defineStore('doc', {
|
||||
try {
|
||||
const { language } = this;
|
||||
const doc = this.docs[path]
|
||||
const content = await doc[language]();
|
||||
const content = doc[language].content
|
||||
return {
|
||||
content,
|
||||
language,
|
||||
@@ -44,7 +44,7 @@ export const useDocStore = defineStore('doc', {
|
||||
|
||||
// Function to get the file tree from @doc
|
||||
function getFileTree() {
|
||||
const tree = import.meta.glob('@docs/**/*.{md,mdx}', { as: 'raw'})
|
||||
const tree = import.meta.glob('@docs/**/*.{md,mdx}', { as: 'raw', eager: true })
|
||||
const docsFiles = {}
|
||||
const languages = new Set()
|
||||
|
||||
@@ -54,7 +54,15 @@ function getFileTree() {
|
||||
|
||||
const filename = rest.join('/').replace(/\.mdx?$/, '')
|
||||
docsFiles[filename] = docsFiles[filename] || {}
|
||||
docsFiles[filename][lang] = imprt
|
||||
|
||||
const vars = extractVars(imprt);
|
||||
|
||||
docsFiles[filename][lang] = {
|
||||
path,
|
||||
filename,
|
||||
content: imprt,
|
||||
...vars,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -62,3 +70,19 @@ function getFileTree() {
|
||||
docs: docsFiles,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function extractVars(content) {
|
||||
const regex = /\[([a-zA-Z]+)\]: \\\\ "(.*)"/g;
|
||||
const vars = {};
|
||||
let m;
|
||||
|
||||
while ((m = regex.exec(content)) !== null) {
|
||||
if (m.index === regex.lastIndex) {
|
||||
regex.lastIndex++;
|
||||
}
|
||||
|
||||
vars[m[1]] = m[2];
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ export default {
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.markdown-body[data-theme=dark] {
|
||||
.markdown-body[data-theme="dark"] {
|
||||
background-color: #121212 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user