|
| 1 | +import fs from 'fs' |
| 2 | +import path from 'path' |
| 3 | +import dotenv from 'dotenv' |
| 4 | + |
| 5 | +import { defaultTheme, viteBundler } from 'vuepress' |
| 6 | + |
| 7 | +dotenv.config() |
| 8 | + |
| 9 | +const hostname = 'actions.dragon-code.pro' |
| 10 | + |
| 11 | +module.exports = { |
| 12 | + lang: 'en-US', |
| 13 | + title: 'Dragon Code: Actions', |
| 14 | + description: 'Performing actions with saving the list of called files', |
| 15 | + |
| 16 | + head: [ |
| 17 | + ['link', { rel: 'icon', href: `https://${ hostname }/images/logo.svg` }], |
| 18 | + ['meta', { name: 'twitter:image', content: `https://${ hostname }/images/logo.svg` }] |
| 19 | + ], |
| 20 | + |
| 21 | + bundler: viteBundler(), |
| 22 | + |
| 23 | + theme: defaultTheme({ |
| 24 | + hostname, |
| 25 | + base: '/', |
| 26 | + |
| 27 | + logo: `https://${ hostname }/images/logo.svg`, |
| 28 | + |
| 29 | + repo: 'https://github.com/TheDragonCode/laravel-migration-actions', |
| 30 | + repoLabel: 'GitHub', |
| 31 | + docsRepo: 'https://github.com/TheDragonCode/laravel-migration-actions', |
| 32 | + docsBranch: 'main', |
| 33 | + docsDir: 'docs', |
| 34 | + |
| 35 | + contributors: false, |
| 36 | + editLink: true, |
| 37 | + |
| 38 | + navbar: [ |
| 39 | + { text: '3.x', link: '/prologue/changelog/index.md' } |
| 40 | + ], |
| 41 | + |
| 42 | + sidebarDepth: 1, |
| 43 | + |
| 44 | + sidebar: [ |
| 45 | + { |
| 46 | + text: 'Prologue', |
| 47 | + collapsible: true, |
| 48 | + children: [ |
| 49 | + { |
| 50 | + text: 'Upgrade Guide', |
| 51 | + link: '/prologue/upgrade.md' |
| 52 | + }, |
| 53 | + { |
| 54 | + text: 'License', |
| 55 | + link: '/prologue/license.md' |
| 56 | + }, |
| 57 | + { |
| 58 | + text: 'Changelog', |
| 59 | + link: '/prologue/changelog/index.md', |
| 60 | + collapsible: true, |
| 61 | + children: getChildren('prologue/changelog', 'desc') |
| 62 | + } |
| 63 | + ] |
| 64 | + }, |
| 65 | + |
| 66 | + { |
| 67 | + text: 'Getting Started', |
| 68 | + collapsible: true, |
| 69 | + children: [ |
| 70 | + { |
| 71 | + text: 'Installation', |
| 72 | + link: '/getting-started/installation/index.md' |
| 73 | + } |
| 74 | + ] |
| 75 | + }, |
| 76 | + |
| 77 | + { |
| 78 | + text: 'How To Use', |
| 79 | + collapsible: true, |
| 80 | + children: getChildren('how-to-use') |
| 81 | + }, |
| 82 | + |
| 83 | + { |
| 84 | + text: 'Helpers', |
| 85 | + collapsible: true, |
| 86 | + children: getChildren('helpers') |
| 87 | + } |
| 88 | + ] |
| 89 | + }) |
| 90 | +} |
| 91 | + |
| 92 | +function getChildren(folder, sort = 'asc') { |
| 93 | + const extension = ['.md'] |
| 94 | + const names = ['index.md', 'readme.md'] |
| 95 | + |
| 96 | + const dir = `${ __dirname }/../${ folder }` |
| 97 | + |
| 98 | + return fs |
| 99 | + .readdirSync(path.join(dir)) |
| 100 | + .filter(item => |
| 101 | + fs.statSync(path.join(dir, item)).isFile() && |
| 102 | + ! names.includes(item.toLowerCase()) && |
| 103 | + extension.includes(path.extname(item)) |
| 104 | + ) |
| 105 | + .sort((a, b) => { |
| 106 | + a = resolveNumeric(a) |
| 107 | + b = resolveNumeric(b) |
| 108 | + |
| 109 | + if (a < b) return sort === 'asc' ? -1 : 1 |
| 110 | + if (a > b) return sort === 'asc' ? 1 : -1 |
| 111 | + |
| 112 | + return 0 |
| 113 | + }).map(item => `/${ folder }/${ item }`) |
| 114 | +} |
| 115 | + |
| 116 | +function resolveNumeric(value) { |
| 117 | + const sub = value.substring(0, value.indexOf('.')) |
| 118 | + |
| 119 | + const num = Number(sub) |
| 120 | + |
| 121 | + return isNaN(num) ? value : num |
| 122 | +} |
0 commit comments