Skip to content

Commit

Permalink
chore(docs): convert to es module
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Nov 30, 2022
1 parent a877a19 commit bb5ebd5
Show file tree
Hide file tree
Showing 13 changed files with 2,771 additions and 1,942 deletions.
17 changes: 8 additions & 9 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const defaultTheme = require('./theme')
import extendsMarkdown from './configs/extends-markdown'
import head from './configs/head'
import markdown from './configs/markdown'
import navbar from './configs/navbar'
import plugins from './configs/plugins'
import sidebar from './configs/sidebar'
import defaultTheme from './theme'

const head = require('./configs/head')
const extendsMarkdown = require('./configs/extends-markdown')
const markdown = require('./configs/markdown')
const navbar = require('./configs/navbar')
const sidebar = require('./configs/sidebar')
const plugins = require('./configs/plugins')

module.exports = {
export default {
lang: 'en-US',
title: 'discue',
description: 'Developer documentation for the secure and reliable messaging and queueing service.',
Expand Down
7 changes: 4 additions & 3 deletions docs/.vuepress/configs/extends-markdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const anchorPlugin = require('markdown-it-anchor')
import anchorPlugin from 'markdown-it-anchor'
import markdownItArrs from 'markdown-it-attrs'

// eslint-disable-next-line no-control-regex
const rControl = /[\u0000-\u001f]/g
Expand All @@ -24,8 +25,8 @@ const slugify = (str) => {
.toLowerCase()
}

module.exports = (md) => {
md.use(require('markdown-it-attrs'), {
export default (md) => {
md.use(markdownItArrs, {
allowedAttributes: ['id'],
leftDelimiter: '[',
rightDelimiter: ']',
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/head.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
['link', { rel: 'icon', type: "image/png", sizes: "16x16", href: "/icons-fire-all-black/web/favicon.ico" }],
['link', { rel: 'icon', type: "image/png", sizes: "32x32", href: "/icons-fire-all-black/web/favicon.ico" }],
['link', { rel: "apple-touch-icon", sizes: "152x152", href: "/icons-fire-all-black/web/apple-touch-icon-152x152.png" }]
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/markdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
extractHeaders: { level: [2, 3, 4, 5, 6] },
anchor: false
}
6 changes: 4 additions & 2 deletions docs/.vuepress/configs/navbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { version } = require('../../../package.json')
import fs from 'node:fs'

module.exports = [{
const { version } = JSON.parse(fs.readFileSync('package.json'))

export default [{
text: 'Getting Started',
link: '/getting-started/',
}, {
Expand Down
8 changes: 4 additions & 4 deletions docs/.vuepress/configs/plugins.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { shikiPlugin } = require('@vuepress/plugin-shiki')
const { sitemapPlugin } = require('vuepress-plugin-sitemap2')
const { 'default': prismPlugin } = require('@vuepress/plugin-prismjs')
import prismPlugin from '@vuepress/plugin-prismjs'
import { shikiPlugin } from '@vuepress/plugin-shiki'
import { sitemapPlugin } from 'vuepress-plugin-sitemap2'

module.exports = [
export default [
prismPlugin(false),
sitemapPlugin({
hostname: 'https://docs.discue.io',
Expand Down
13 changes: 6 additions & 7 deletions docs/.vuepress/configs/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const fs = require("fs")
const { join } = require("path")

const { pascalCase } = require('pascal-case');
const yaml = require('yaml')
import fs from "node:fs"
import { join } from "node:path"
import { pascalCase } from 'pascal-case'
import yaml from 'yaml'

const getAllFiles = function (dirPath, arrayOfFiles) {
files = fs.readdirSync(dirPath)
const files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []

files.forEach(function (file) {
Expand Down Expand Up @@ -78,7 +77,7 @@ const filesAndFolders = getAllFolders(join('docs', 'api-reference')).reduce((con
return context
}, [])

module.exports = [{
export default [{
text: 'Introduction',
link: '/introduction/',
}, {
Expand Down
31 changes: 12 additions & 19 deletions docs/.vuepress/theme/components/PageMeta.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<script setup lang="ts">
import AutoLink from '@theme/AutoLink.vue'
import {
usePageData,
usePageFrontmatter,
useSiteLocaleData,
} from '@vuepress/client'
import { computed } from 'vue'
import type { ComputedRef } from 'vue'
import { usePageData, usePageFrontmatter } from '@vuepress/client'
import { useThemeLocaleData } from '@vuepress/theme-default/lib/client/composables/index.js'
import { resolveEditLink } from '@vuepress/theme-default/lib/client/utils/index.js'
import type {
DefaultThemeNormalPageFrontmatter,
DefaultThemePageData,
NavLink,
} from '@vuepress/theme-default/lib/shared'
import { useThemeLocaleData } from '@vuepress/theme-default/lib/client/composables'
import { resolveEditLink } from '@vuepress/theme-default/lib/client/utils'
DefaultThemeNormalPageFrontmatter,
DefaultThemePageData,
NavLink
} from '@vuepress/theme-default/lib/shared/index.js'
import type { ComputedRef } from 'vue'
import { computed } from 'vue'
const useEditNavLink = (): ComputedRef<null | NavLink> => {
const themeLocale = useThemeLocaleData()
Expand Down Expand Up @@ -98,7 +94,7 @@ const contributors = useContributors()
</script>

<template>
<div class="page-meta text-right">
<div class="page-meta">
<div v-if="editNavLink" class="meta-item edit-link">
<AutoLink class="meta-item-label" :item="editNavLink" />
</div>
Expand All @@ -110,10 +106,7 @@ const contributors = useContributors()
</ClientOnly>
</div>

<div
v-if="contributors && contributors.length"
class="meta-item contributors"
>
<div v-if="contributors && contributors.length" class="meta-item contributors">
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
<span class="meta-item-info">
<template v-for="(contributor, index) in contributors" :key="index">
Expand All @@ -125,4 +118,4 @@ const contributors = useContributors()
</span>
</div>
</div>
</template>
</template>
11 changes: 6 additions & 5 deletions docs/.vuepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { path } = require('@vuepress/utils')
const { defaultTheme } = require('@vuepress/theme-default')
import { defaultTheme } from '@vuepress/theme-default';
import { path } from '@vuepress/utils';

module.exports = options => {
return {
export default options => {

return Object.assign({}, defaultTheme(options), {
name: 'vuepress-theme-local',
extends: defaultTheme(options),
layouts: {
Expand All @@ -13,5 +14,5 @@ module.exports = options => {
'@theme/HomeFooter.vue': path.resolve(__dirname, './layouts/HomeFooter.vue'),
'@theme/PageMeta.vue': path.resolve(__dirname, './components/PageMeta.vue')
}
}
})
}
Loading

0 comments on commit bb5ebd5

Please sign in to comment.