|
| 1 | +import fs from "node:fs"; |
| 2 | +import path from "node:path"; |
1 | 3 | import { defineConfig } from "vitepress"; |
2 | 4 |
|
| 5 | +function getApiPages() { |
| 6 | + const apiDir = path.resolve("./api"); |
| 7 | + |
| 8 | + if (!fs.existsSync(apiDir)) { |
| 9 | + return []; |
| 10 | + } |
| 11 | + |
| 12 | + return fs |
| 13 | + .readdirSync(apiDir, { withFileTypes: true }) |
| 14 | + .filter( |
| 15 | + (entry) => |
| 16 | + entry.isFile() && |
| 17 | + entry.name.endsWith(".md") |
| 18 | + ) |
| 19 | + .map((entry) => { |
| 20 | + const name = entry.name.replace( |
| 21 | + /\.md$/, |
| 22 | + "" |
| 23 | + ); |
| 24 | + |
| 25 | + return { |
| 26 | + text: |
| 27 | + name.charAt(0).toUpperCase() + |
| 28 | + name.slice(1), |
| 29 | + |
| 30 | + link: `/api/${name}`, |
| 31 | + }; |
| 32 | + }) |
| 33 | + .sort((a, b) => |
| 34 | + a.text.localeCompare(b.text) |
| 35 | + ); |
| 36 | +} |
| 37 | + |
3 | 38 | export default defineConfig({ |
4 | 39 | title: "Berryaudio", |
5 | 40 | description: "Installation, getting started & development docs", |
| 41 | + |
6 | 42 | themeConfig: { |
7 | 43 | nav: [ |
8 | 44 | { text: "Home", link: "/" }, |
9 | | - { text: "Getting Started", link: "/getting-started/introduction" }, |
10 | | - { text: "Development", link: "/development/architecture" }, |
11 | | - { text: "Community", link: "https://community.berryaudio.org" }, |
| 45 | + { |
| 46 | + text: "Getting Started", |
| 47 | + link: "/getting-started/introduction", |
| 48 | + }, |
| 49 | + { |
| 50 | + text: "Development", |
| 51 | + link: "/development/architecture", |
| 52 | + }, |
| 53 | + { |
| 54 | + text: "Community", |
| 55 | + link: "https://community.berryaudio.org", |
| 56 | + }, |
12 | 57 | ], |
13 | 58 |
|
14 | 59 | sidebar: [ |
15 | 60 | { |
16 | 61 | text: "Getting started", |
17 | 62 | items: [ |
18 | | - { text: "Introduction", link: "/getting-started/introduction" }, |
19 | | - { text: "Installation & Setup", link: "/getting-started/installation" }, |
20 | | - { text: "Supported Hardware", link: "/getting-started/supported-hardware" }, |
| 63 | + { |
| 64 | + text: "Introduction", |
| 65 | + link: "/getting-started/introduction", |
| 66 | + }, |
| 67 | + { |
| 68 | + text: "Installation & Setup", |
| 69 | + link: "/getting-started/installation", |
| 70 | + }, |
| 71 | + { |
| 72 | + text: "Supported Hardware", |
| 73 | + link: "/getting-started/supported-hardware", |
| 74 | + }, |
21 | 75 | ], |
22 | 76 | }, |
23 | 77 |
|
24 | 78 | { |
25 | 79 | text: "Development", |
26 | 80 | items: [ |
27 | | - { text: "Architecture", link: "/development/architecture" }, |
28 | | - { text: "Environment", link: "/development/environment" }, |
29 | | - { text: "Extensions", link: "/development/extensions" }, |
| 81 | + { |
| 82 | + text: "Architecture", |
| 83 | + link: "/development/architecture", |
| 84 | + }, |
| 85 | + { |
| 86 | + text: "Environment", |
| 87 | + link: "/development/environment", |
| 88 | + }, |
| 89 | + { |
| 90 | + text: "Extensions", |
| 91 | + link: "/development/extensions", |
| 92 | + }, |
30 | 93 | ], |
31 | 94 | }, |
| 95 | + |
32 | 96 | { |
33 | 97 | text: "Display", |
34 | 98 | items: [ |
35 | | - { text: "Generic HDMI", link: "/display/generic-hdmi" }, |
36 | | - { text: "SSD1322 OLED (256×64)", link: "/display/ssd1322-oled" }, |
37 | | - { text: "SSD1306 OLED (128×64)", link: "/display/ssd1306-oled" }, |
38 | | - { text: 'Waveshare 2.8" DSI LCD (480×640)', link: "/display/waveshare-28-dsi-lcd" }, |
| 99 | + { |
| 100 | + text: "Generic HDMI", |
| 101 | + link: "/display/generic-hdmi", |
| 102 | + }, |
| 103 | + { |
| 104 | + text: "SSD1322 OLED (256×64)", |
| 105 | + link: "/display/ssd1322-oled", |
| 106 | + }, |
| 107 | + { |
| 108 | + text: "SSD1306 OLED (128×64)", |
| 109 | + link: "/display/ssd1306-oled", |
| 110 | + }, |
| 111 | + { |
| 112 | + text: 'Waveshare 2.8" DSI LCD (480×640)', |
| 113 | + link: "/display/waveshare-28-dsi-lcd", |
| 114 | + }, |
39 | 115 | ], |
40 | 116 | }, |
41 | 117 |
|
42 | 118 | { |
43 | | - text: "Extensions", |
44 | | - items: [ |
45 | | - { text: "Bluetooth", link: "/extensions/bluetooth" }, |
46 | | - { text: "Mixer", link: "/extensions/mixer" }, |
47 | | - { text: "Playback", link: "/extensions/playback" }, |
48 | | - { text: "System", link: "/extensions/system" }, |
49 | | - { text: "Spotify", link: "/extensions/spotify" }, |
50 | | - { text: "Airplay", link: "/extensions/airplay" }, |
51 | | - { text: "Snapcast", link: "/extensions/snapcast" }, |
52 | | - { text: "Radio", link: "/extensions/radio" }, |
53 | | - { text: "Network", link: "/extensions/network" }, |
54 | | - { text: "Tracklist", link: "/extensions/tracklist" }, |
55 | | - { text: "Library", link: "/extensions/library" }, |
56 | | - { text: "Storage", link: "/extensions/storage" }, |
57 | | - ], |
| 119 | + text: "API", |
| 120 | + items: getApiPages(), |
58 | 121 | }, |
59 | 122 |
|
60 | 123 | { |
61 | 124 | text: "Community", |
62 | | - items: [{ text: "Forums", link: "https://www.berryaudio.org" }], |
| 125 | + items: [ |
| 126 | + { |
| 127 | + text: "Forums", |
| 128 | + link: "https://www.berryaudio.org", |
| 129 | + }, |
| 130 | + ], |
63 | 131 | }, |
64 | 132 | ], |
65 | 133 |
|
66 | | - socialLinks: [{ icon: "github", link: "https://github.com/berry-audio" }], |
| 134 | + socialLinks: [ |
| 135 | + { |
| 136 | + icon: "github", |
| 137 | + link: "https://github.com/berry-audio", |
| 138 | + }, |
| 139 | + ], |
67 | 140 | }, |
68 | 141 | }); |
0 commit comments