docus 2.1.0 → 3.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/README.md +6 -4
  2. package/app/router.options.ts +18 -0
  3. package/assets/css/fonts.css +84 -0
  4. package/assets/css/main.css +11 -0
  5. package/assets/css/tailwind.css +282 -0
  6. package/components/app/Container.vue +25 -0
  7. package/components/app/Footer.vue +40 -0
  8. package/components/app/Navbar.vue +26 -0
  9. package/components/app/NavbarLogo.vue +33 -0
  10. package/components/app/Page.vue +7 -0
  11. package/components/app/PoweredByDocus.vue +11 -0
  12. package/components/content/Alert.vue +124 -0
  13. package/components/content/BlockHero.vue +54 -0
  14. package/components/content/ButtonLink.vue +45 -0
  15. package/components/content/Card.vue +46 -0
  16. package/components/content/CardGrid.vue +23 -0
  17. package/components/content/CodeBlock.vue +47 -0
  18. package/components/content/CodeGroup.vue +135 -0
  19. package/components/content/CopyButton.vue +49 -0
  20. package/{dist/runtime/app/components/prose/ProseOl.vue → components/content/List.vue} +2 -2
  21. package/components/content/NeedContribution.vue +23 -0
  22. package/components/content/ReadMore.vue +25 -0
  23. package/components/content/Sandbox.vue +102 -0
  24. package/components/content/TabsHeader.vue +44 -0
  25. package/components/content/Terminal.vue +64 -0
  26. package/components/content/VideoPlayer.vue +115 -0
  27. package/components/docs/DocsAside.vue +21 -0
  28. package/components/docs/DocsAsideTree.vue +102 -0
  29. package/components/docs/DocsHero.vue +39 -0
  30. package/components/docs/DocsPage.vue +22 -0
  31. package/components/docs/DocsPageContent.vue +31 -0
  32. package/components/docs/DocsToc.vue +74 -0
  33. package/components/globals/Icon.vue +24 -0
  34. package/{dist/runtime/app/components/prose/ProseHr.vue → components/globals/Logo.vue} +1 -1
  35. package/components/globals/NuxtImg.vue +45 -0
  36. package/components/globals/SocialIcons.vue +45 -0
  37. package/components/globals/ThemeSelect.vue +35 -0
  38. package/components/icons/IconAlgolia.vue +8 -0
  39. package/components/icons/IconArrowLeft.vue +10 -0
  40. package/components/icons/IconArrowRight.vue +10 -0
  41. package/components/icons/IconBadgeCheck.vue +14 -0
  42. package/components/icons/IconCheck.vue +10 -0
  43. package/components/icons/IconCheckCircle.vue +10 -0
  44. package/components/icons/IconChevronRight.vue +12 -0
  45. package/components/icons/IconClipboardCheck.vue +14 -0
  46. package/components/icons/IconClipboardCopy.vue +14 -0
  47. package/components/icons/IconCodeSandbox.vue +8 -0
  48. package/components/icons/IconCopy.vue +17 -0
  49. package/components/icons/IconDots.vue +10 -0
  50. package/components/icons/IconEdit.vue +18 -0
  51. package/components/icons/IconExclamationCircle.vue +12 -0
  52. package/components/icons/IconExclamationTriangle.vue +10 -0
  53. package/components/icons/IconExternalLink.vue +12 -0
  54. package/components/icons/IconGit.vue +7 -0
  55. package/components/icons/IconGitHub.vue +10 -0
  56. package/components/icons/IconHeart.vue +9 -0
  57. package/components/icons/IconInformationCircle.vue +10 -0
  58. package/components/icons/IconLighthouse.vue +83 -0
  59. package/components/icons/IconLine.vue +10 -0
  60. package/components/icons/IconMarkdown.vue +13 -0
  61. package/components/icons/IconMenu.vue +12 -0
  62. package/components/icons/IconMenuAlt.vue +10 -0
  63. package/components/icons/IconMinus.vue +10 -0
  64. package/components/icons/IconMoon.vue +10 -0
  65. package/components/icons/IconNuxt.vue +14 -0
  66. package/components/icons/IconNuxtContent.vue +20 -0
  67. package/components/icons/IconNuxtLabs.vue +21 -0
  68. package/components/icons/IconPlus.vue +10 -0
  69. package/components/icons/IconPuzzle.vue +8 -0
  70. package/components/icons/IconSSG.vue +7 -0
  71. package/components/icons/IconSearch.vue +12 -0
  72. package/components/icons/IconSun.vue +10 -0
  73. package/components/icons/IconTocBack.vue +21 -0
  74. package/components/icons/IconTocCurrent.vue +21 -0
  75. package/components/icons/IconTocNext.vue +8 -0
  76. package/components/icons/IconTranslate.vue +14 -0
  77. package/components/icons/IconTwitter.vue +8 -0
  78. package/components/icons/IconVite.vue +30 -0
  79. package/components/icons/IconVue.vue +6 -0
  80. package/components/icons/IconVueTelescope.vue +11 -0
  81. package/components/icons/IconWindi.vue +17 -0
  82. package/components/icons/IconX.vue +12 -0
  83. package/components/icons/IconXCircle.vue +10 -0
  84. package/components/icons/IconZap.vue +8 -0
  85. package/components/prose/ProseA.vue +66 -0
  86. package/components/prose/ProseBlockquote.vue +21 -0
  87. package/components/prose/ProseCode.vue +68 -0
  88. package/components/prose/ProseCodeInline.vue +38 -0
  89. package/components/prose/ProseEm.vue +11 -0
  90. package/components/prose/ProseH1.vue +22 -0
  91. package/components/prose/ProseH2.vue +22 -0
  92. package/components/prose/ProseH3.vue +24 -0
  93. package/components/prose/ProseH4.vue +24 -0
  94. package/components/prose/ProseHr.vue +13 -0
  95. package/components/prose/ProseImg.vue +30 -0
  96. package/components/prose/ProseLi.vue +31 -0
  97. package/components/prose/ProseOl.vue +16 -0
  98. package/components/prose/ProseP.vue +14 -0
  99. package/components/prose/ProseStrong.vue +14 -0
  100. package/components/prose/ProseTable.vue +13 -0
  101. package/{dist/runtime/app/components → components}/prose/ProseTbody.vue +0 -0
  102. package/components/prose/ProseTd.vue +11 -0
  103. package/components/prose/ProseTh.vue +11 -0
  104. package/components/prose/ProseThead.vue +11 -0
  105. package/components/prose/ProseTr.vue +11 -0
  106. package/components/prose/ProseUl.vue +15 -0
  107. package/composables/useContent.ts +156 -0
  108. package/composables/useMenu.ts +22 -0
  109. package/composables/useScrollToHeading.ts +35 -0
  110. package/composables/useScrollspy.ts +46 -0
  111. package/composables/useTheme.ts +12 -0
  112. package/layouts/default.vue +29 -0
  113. package/layouts/page.vue +11 -0
  114. package/nuxt.config.ts +151 -0
  115. package/package.json +46 -83
  116. package/pages/[...slug].vue +26 -0
  117. package/public/android-chrome-192x192.png +0 -0
  118. package/public/android-chrome-512x512.png +0 -0
  119. package/public/apple-touch-icon.png +0 -0
  120. package/public/favicon-16x16.png +0 -0
  121. package/public/favicon-32x32.png +0 -0
  122. package/public/favicon.ico +0 -0
  123. package/public/site.webmanifest +1 -0
  124. package/LICENSE +0 -21
  125. package/dist/index.cjs +0 -549
  126. package/dist/index.d.ts +0 -25
  127. package/dist/index.mjs +0 -523
  128. package/dist/runtime/app/components/DocusContent.vue +0 -215
  129. package/dist/runtime/app/components/DocusContent.vue.d.ts +0 -25
  130. package/dist/runtime/app/components/Error.vue +0 -19
  131. package/dist/runtime/app/components/Error.vue.d.ts +0 -9
  132. package/dist/runtime/app/components/Markdown.vue +0 -56
  133. package/dist/runtime/app/components/Markdown.vue.d.ts +0 -25
  134. package/dist/runtime/app/components/Page.vue +0 -29
  135. package/dist/runtime/app/components/Page.vue.d.ts +0 -2
  136. package/dist/runtime/app/components/Props.vue +0 -130
  137. package/dist/runtime/app/components/Props.vue.d.ts +0 -80
  138. package/dist/runtime/app/components/prose/ProseA.vue +0 -41
  139. package/dist/runtime/app/components/prose/ProseA.vue.d.ts +0 -23
  140. package/dist/runtime/app/components/prose/ProseBlockquote.vue +0 -5
  141. package/dist/runtime/app/components/prose/ProseCode.vue +0 -5
  142. package/dist/runtime/app/components/prose/ProseCodeInline.vue +0 -5
  143. package/dist/runtime/app/components/prose/ProseEm.vue +0 -5
  144. package/dist/runtime/app/components/prose/ProseH1.vue +0 -3
  145. package/dist/runtime/app/components/prose/ProseH2.vue +0 -3
  146. package/dist/runtime/app/components/prose/ProseH3.vue +0 -3
  147. package/dist/runtime/app/components/prose/ProseH4.vue +0 -3
  148. package/dist/runtime/app/components/prose/ProseH5.vue +0 -3
  149. package/dist/runtime/app/components/prose/ProseH6.vue +0 -3
  150. package/dist/runtime/app/components/prose/ProseImg.vue +0 -32
  151. package/dist/runtime/app/components/prose/ProseImg.vue.d.ts +0 -21
  152. package/dist/runtime/app/components/prose/ProseLi.vue +0 -3
  153. package/dist/runtime/app/components/prose/ProseParagraph.vue +0 -3
  154. package/dist/runtime/app/components/prose/ProseStrong.vue +0 -5
  155. package/dist/runtime/app/components/prose/ProseTable.vue +0 -5
  156. package/dist/runtime/app/components/prose/ProseTd.vue +0 -5
  157. package/dist/runtime/app/components/prose/ProseTh.vue +0 -5
  158. package/dist/runtime/app/components/prose/ProseThead.vue +0 -5
  159. package/dist/runtime/app/components/prose/ProseTr.vue +0 -5
  160. package/dist/runtime/app/components/prose/ProseUl.vue +0 -5
  161. package/dist/runtime/app/composables/helpers.d.ts +0 -4
  162. package/dist/runtime/app/composables/helpers.js +0 -66
  163. package/dist/runtime/app/composables/helpers.mjs +0 -40
  164. package/dist/runtime/app/composables/index.d.ts +0 -90
  165. package/dist/runtime/app/composables/index.js +0 -108
  166. package/dist/runtime/app/composables/index.mjs +0 -63
  167. package/dist/runtime/app/composables/navigation.d.ts +0 -37
  168. package/dist/runtime/app/composables/navigation.js +0 -227
  169. package/dist/runtime/app/composables/navigation.mjs +0 -148
  170. package/dist/runtime/app/composables/store.d.ts +0 -7
  171. package/dist/runtime/app/composables/store.js +0 -52
  172. package/dist/runtime/app/composables/store.mjs +0 -35
  173. package/dist/runtime/app/composables/style.d.ts +0 -11
  174. package/dist/runtime/app/composables/style.js +0 -117
  175. package/dist/runtime/app/composables/style.mjs +0 -71
  176. package/dist/runtime/app/composables/theme-colors.d.ts +0 -30
  177. package/dist/runtime/app/composables/theme-colors.js +0 -80
  178. package/dist/runtime/app/composables/theme-colors.mjs +0 -48
  179. package/dist/runtime/app/composables/websocket.d.ts +0 -3
  180. package/dist/runtime/app/composables/websocket.js +0 -79
  181. package/dist/runtime/app/composables/websocket.mjs +0 -63
  182. package/dist/runtime/app/layouts/default.vue +0 -5
  183. package/dist/runtime/app/layouts/error.vue +0 -33
  184. package/dist/runtime/app/layouts/error.vue.d.ts +0 -21
  185. package/dist/runtime/app/pages/_.vue +0 -222
  186. package/dist/runtime/app/pages/_.vue.d.ts +0 -2
  187. package/dist/runtime/context.d.ts +0 -1
  188. package/dist/runtime/context.js +0 -17
  189. package/dist/runtime/context.mjs +0 -5
  190. package/dist/runtime/database/Query.d.ts +0 -18
  191. package/dist/runtime/database/Query.js +0 -68
  192. package/dist/runtime/database/Query.mjs +0 -49
  193. package/dist/runtime/database/index.d.ts +0 -4
  194. package/dist/runtime/database/index.js +0 -45
  195. package/dist/runtime/database/index.mjs +0 -25
  196. package/dist/runtime/database/providers/local/Query.d.ts +0 -14
  197. package/dist/runtime/database/providers/local/Query.js +0 -85
  198. package/dist/runtime/database/providers/local/Query.mjs +0 -60
  199. package/dist/runtime/database/providers/local/index.d.ts +0 -3
  200. package/dist/runtime/database/providers/local/index.js +0 -63
  201. package/dist/runtime/database/providers/local/index.mjs +0 -39
  202. package/dist/runtime/database/providers/local/operations.d.ts +0 -2
  203. package/dist/runtime/database/providers/local/operations.js +0 -83
  204. package/dist/runtime/database/providers/local/operations.mjs +0 -53
  205. package/dist/runtime/database/providers/local/utils.d.ts +0 -8
  206. package/dist/runtime/database/providers/local/utils.js +0 -28
  207. package/dist/runtime/database/providers/local/utils.mjs +0 -17
  208. package/dist/runtime/index.d.ts +0 -3
  209. package/dist/runtime/index.js +0 -44
  210. package/dist/runtime/index.mjs +0 -3
  211. package/dist/runtime/navigation.d.ts +0 -4
  212. package/dist/runtime/navigation.js +0 -176
  213. package/dist/runtime/navigation.mjs +0 -137
  214. package/dist/runtime/server/api/get.d.ts +0 -10
  215. package/dist/runtime/server/api/get.js +0 -24
  216. package/dist/runtime/server/api/get.mjs +0 -13
  217. package/dist/runtime/server/api/list.d.ts +0 -9
  218. package/dist/runtime/server/api/list.js +0 -34
  219. package/dist/runtime/server/api/list.mjs +0 -18
  220. package/dist/runtime/server/api/navigation.d.ts +0 -7
  221. package/dist/runtime/server/api/navigation.js +0 -20
  222. package/dist/runtime/server/api/navigation.mjs +0 -10
  223. package/dist/runtime/server/api/preview.d.ts +0 -3
  224. package/dist/runtime/server/api/preview.js +0 -54
  225. package/dist/runtime/server/api/preview.mjs +0 -31
  226. package/dist/runtime/server/api/reload.d.ts +0 -6
  227. package/dist/runtime/server/api/reload.js +0 -27
  228. package/dist/runtime/server/api/reload.mjs +0 -11
  229. package/dist/runtime/server/api/search.d.ts +0 -6
  230. package/dist/runtime/server/api/search.js +0 -27
  231. package/dist/runtime/server/api/search.mjs +0 -13
  232. package/dist/runtime/server/content.d.ts +0 -46
  233. package/dist/runtime/server/content.js +0 -175
  234. package/dist/runtime/server/content.mjs +0 -114
  235. package/dist/runtime/server/socket.d.ts +0 -9
  236. package/dist/runtime/server/socket.js +0 -33
  237. package/dist/runtime/server/socket.mjs +0 -20
  238. package/dist/runtime/server/utils/cache.d.ts +0 -19
  239. package/dist/runtime/server/utils/cache.js +0 -110
  240. package/dist/runtime/server/utils/cache.mjs +0 -75
  241. package/dist/runtime/server/utils/index.d.ts +0 -4
  242. package/dist/runtime/server/utils/index.js +0 -18
  243. package/dist/runtime/server/utils/index.mjs +0 -8
  244. package/dist/runtime/transformers/index.d.ts +0 -1
  245. package/dist/runtime/transformers/index.js +0 -26
  246. package/dist/runtime/transformers/index.mjs +0 -11
  247. package/dist/runtime/transformers/json.d.ts +0 -3
  248. package/dist/runtime/transformers/json.js +0 -15
  249. package/dist/runtime/transformers/json.mjs +0 -5
  250. package/dist/runtime/transformers/markdown/index.d.ts +0 -8
  251. package/dist/runtime/transformers/markdown/index.js +0 -25
  252. package/dist/runtime/transformers/markdown/index.mjs +0 -16
  253. package/dist/runtime/transformers/utils/index.d.ts +0 -1
  254. package/dist/runtime/transformers/utils/index.js +0 -18
  255. package/dist/runtime/transformers/utils/index.mjs +0 -1
  256. package/dist/runtime/transformers/utils/path.d.ts +0 -26
  257. package/dist/runtime/transformers/utils/path.js +0 -88
  258. package/dist/runtime/transformers/utils/path.mjs +0 -56
  259. package/dist/runtime/utils/index.d.ts +0 -1
  260. package/dist/runtime/utils/index.js +0 -18
  261. package/dist/runtime/utils/index.mjs +0 -1
  262. package/dist/runtime/utils/log.d.ts +0 -1
  263. package/dist/runtime/utils/log.js +0 -14
  264. package/dist/runtime/utils/log.mjs +0 -2
  265. package/dist/runtime/utils/object.d.ts +0 -9
  266. package/dist/runtime/utils/object.js +0 -22
  267. package/dist/runtime/utils/object.mjs +0 -4
  268. package/dist/templates/content.mjs +0 -50
  269. package/dist/templates/docus.mjs +0 -13
  270. package/dist/templates/hot.mjs +0 -16
  271. package/dist/templates/i18n.mjs +0 -23
  272. package/dist/templates/options.mjs +0 -46
  273. package/shims.d.ts +0 -24
  274. package/types.d.ts +0 -397
package/dist/index.cjs DELETED
@@ -1,549 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const kit = require('@nuxt/kit');
6
- const pathe = require('pathe');
7
- const fetch = require('node-fetch');
8
- const ufo = require('ufo');
9
- const debounce = require('debounce');
10
- const unstorage = require('unstorage');
11
- const fsDriver = require('unstorage/drivers/fs');
12
- const ws = require('ws');
13
- const consola = require('consola');
14
- const url = require('url');
15
- const fs$1 = require('fs/promises');
16
- const fs = require('fs');
17
- const jiti = require('jiti');
18
- const clearModule = require('clear-module');
19
- const _glob = require('glob');
20
- const defu = require('defu');
21
- const chalk = require('chalk');
22
- const unctx = require('unctx');
23
- const iso639 = require('iso-639-1');
24
-
25
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
26
-
27
- const fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
28
- const fsDriver__default = /*#__PURE__*/_interopDefaultLegacy(fsDriver);
29
- const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
30
- const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
31
- const fs__default$1 = /*#__PURE__*/_interopDefaultLegacy(fs);
32
- const jiti__default = /*#__PURE__*/_interopDefaultLegacy(jiti);
33
- const clearModule__default = /*#__PURE__*/_interopDefaultLegacy(clearModule);
34
- const _glob__default = /*#__PURE__*/_interopDefaultLegacy(_glob);
35
- const defu__default = /*#__PURE__*/_interopDefaultLegacy(defu);
36
- const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
37
- const iso639__default = /*#__PURE__*/_interopDefaultLegacy(iso639);
38
-
39
- const useDefaultOptions = (nuxt) => ({
40
- apiBase: "_docus",
41
- dirs: ["content"],
42
- watch: nuxt.options.dev,
43
- locales: {
44
- codes: ["en"],
45
- defaultLocale: "en"
46
- },
47
- database: {
48
- provider: "local",
49
- options: {}
50
- },
51
- ignoreList: [],
52
- search: {
53
- inheritanceFields: ["layout"]
54
- },
55
- transformers: {
56
- markdown: {
57
- components: [],
58
- rehypePlugins: [],
59
- remarkPlugins: [],
60
- tagMap: {
61
- a: "prose-a",
62
- blockquote: "prose-blockquote",
63
- "code-inline": "prose-code-inline",
64
- code: "prose-code",
65
- em: "prose-em",
66
- h1: "prose-h1",
67
- h2: "prose-h2",
68
- h3: "prose-h3",
69
- h4: "prose-h4",
70
- h5: "prose-h5",
71
- h6: "prose-h6",
72
- hr: "prose-hr",
73
- img: "prose-img",
74
- li: "prose-li",
75
- ol: "prose-ol",
76
- p: "prose-paragraph",
77
- strong: "prose-strong",
78
- table: "prose-table",
79
- tbody: "prose-tbody",
80
- td: "prose-td",
81
- th: "prose-th",
82
- thead: "prose-thead",
83
- tr: "prose-tr",
84
- ul: "prose-ul"
85
- }
86
- }
87
- }
88
- });
89
-
90
- let wss;
91
- function useWebSocket() {
92
- if (!wss)
93
- wss = new ws.Server({ noServer: true });
94
- const serve = (req, socket = req.socket, head = "") => wss.handleUpgrade(req, socket, head, (client) => wss.emit("connection", client, req));
95
- const broadcast = (data) => {
96
- data = JSON.stringify(data);
97
- for (const client of wss.clients) {
98
- try {
99
- client.send(data);
100
- } catch (err) {
101
- }
102
- }
103
- };
104
- return {
105
- serve,
106
- broadcast
107
- };
108
- }
109
-
110
- const logger = consola__default.withScope("@docus");
111
-
112
- const distDir = pathe.resolve(typeof __dirname === "undefined" ? pathe.dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)))) : __dirname);
113
- const _makeResolve = (base) => {
114
- return (...p) => pathe.resolve(base, ...p);
115
- };
116
- const runtimeDir = pathe.resolve(distDir, "runtime");
117
- const resolveRuntimeDir = _makeResolve(runtimeDir);
118
- const templateDir = pathe.resolve(distDir, "templates");
119
- const appDir = pathe.resolve(runtimeDir, "app");
120
- const resolveAppDir = _makeResolve(appDir);
121
- pathe.resolve(appDir, "components");
122
-
123
- const THEME_CONFIG_FILE = "theme.config";
124
- const DOCUS_CONFIG_FILE = "docus.config";
125
-
126
- const defineThemeConfig = (config) => config;
127
- const defineDocusConfig = (config) => config;
128
- const loadConfig = (file, rootDir) => {
129
- const data = {
130
- configFile: false,
131
- configPath: pathe.resolve(rootDir, file)
132
- };
133
- if (fs.existsSync(data.configPath + ".js"))
134
- data.configPath += ".js";
135
- else if (fs.existsSync(data.configPath + ".ts"))
136
- data.configPath += ".ts";
137
- else
138
- return data;
139
- clearModule__default(data.configPath);
140
- try {
141
- data.configFile = jiti__default(distDir)(data.configPath);
142
- data.configFile = data.configFile?.default || data.configFile;
143
- } catch (err) {
144
- throw new Error(`Could not find ${file}, this file is needed for Docus.`);
145
- }
146
- return data;
147
- };
148
- const writeConfig = async (file, cacheDir, content) => {
149
- const jsonPath = pathe.join(cacheDir, `${file}.json`);
150
- if (!fs.existsSync(cacheDir))
151
- await fs__default.mkdir(cacheDir, { recursive: true });
152
- if (fs.existsSync(jsonPath))
153
- await fs__default.rm(jsonPath);
154
- await fs__default.writeFile(jsonPath, JSON.stringify(content.default || content), { encoding: "utf8" });
155
- };
156
- const loadTheme = (path, rootDir) => {
157
- let themeConfig = {};
158
- let themeConfigPath = kit.resolveModule(pathe.join(path, THEME_CONFIG_FILE), { paths: rootDir });
159
- try {
160
- themeConfigPath = jiti__default(rootDir).resolve(themeConfigPath);
161
- } catch (err) {
162
- return themeConfig;
163
- }
164
- try {
165
- themeConfig = jiti__default(rootDir)(themeConfigPath);
166
- } catch (err) {
167
- logger.warn(`Could not load theme config: ${themeConfigPath}`, err);
168
- }
169
- themeConfig = themeConfig.default || themeConfig;
170
- return themeConfig;
171
- };
172
- const buildExternals = ["@nuxt/bridge", "@nuxt/kit", "#app", "@vue/composition-api"];
173
- const resolveApiRoute = (route) => {
174
- const nuxt = kit.useNuxt();
175
- const apiBase = nuxt.options.content?.apiBase || useDefaultOptions(nuxt).apiBase;
176
- return ufo.joinURL("/api", apiBase, route);
177
- };
178
- async function loadNuxtIgnoreList(nuxt) {
179
- const ignore = ["**/-*.*", "**/node_modules/**", "**/.git/**", "**/.**"];
180
- const ignoreFile = pathe.resolve(nuxt.options.rootDir, ".nuxtignore");
181
- const ignoreContent = await fs__default.readFile(ignoreFile, { encoding: "utf-8" }).catch(() => "");
182
- if (ignoreContent) {
183
- ignore.push(...ignoreContent.split("\n").filter(Boolean));
184
- }
185
- const refinedList = ignore.map((pattern) => {
186
- if (typeof pattern === "string") {
187
- return pattern.replace(/\//g, ":");
188
- }
189
- return pattern;
190
- });
191
- return refinedList;
192
- }
193
-
194
- function setupDevTarget(options, nuxt) {
195
- const ws = useWebSocket();
196
- if (options.watch) {
197
- kit.addServerMiddleware({
198
- route: resolveApiRoute("reload"),
199
- handle: kit.resolveModule("./server/api/reload", { paths: runtimeDir }).replace(/\.js$/, ".mjs")
200
- });
201
- kit.addPlugin(kit.resolveModule("./hot", { paths: templateDir }));
202
- const storage = unstorage.createStorage();
203
- loadNuxtIgnoreList(nuxt).then((ignoreList) => {
204
- options.dirs.forEach((dir) => {
205
- const [path, key] = Array.isArray(dir) ? dir : [dir, dir];
206
- storage.mount(key, fsDriver__default({
207
- base: pathe.resolve(nuxt.options.rootDir, path),
208
- ignore: ignoreList
209
- }));
210
- });
211
- });
212
- nuxt.server.listen(0).then(({ url, server }) => {
213
- nuxt.options.publicRuntimeConfig.$docus.wsUrl = url.replace("http", "ws");
214
- server.on("upgrade", (req, socket, head) => ws.serve(req, socket, head));
215
- storage.watch(createDebounceContentWatcher(async (event, key) => {
216
- await fetch__default(ufo.joinURL(url, "api", options.apiBase, "reload"), {
217
- method: "POST",
218
- body: JSON.stringify({ event, key })
219
- });
220
- ws.broadcast({ event, key });
221
- }));
222
- });
223
- }
224
- }
225
- function createDebounceContentWatcher(callback) {
226
- const handleEvent = debounce.debounce(callback, 200);
227
- return (event, key) => {
228
- if (key.endsWith(".md")) {
229
- handleEvent(event, key);
230
- switch (event) {
231
- case "remove":
232
- logger.info(`You removed ${key}`);
233
- return;
234
- case "update":
235
- logger.info(`You updated ${key}`);
236
- return;
237
- default:
238
- logger.info(`You updated ${key}`);
239
- }
240
- }
241
- };
242
- }
243
-
244
- const glob = (pattern, options = {}) => new Promise((resolve2, reject) => _glob__default(pattern, options, (err, matches) => {
245
- if (err)
246
- return reject(err);
247
- resolve2(matches);
248
- }));
249
- const setupAppModule = (nuxt, options) => {
250
- loadNuxtIgnoreList(nuxt).then((ignoreList) => options.ignoreList = ignoreList);
251
- nuxt.options.alias["#docus$"] = runtimeDir;
252
- nuxt.options.alias["#docus/composables"] = resolveAppDir("composables");
253
- nuxt.options.alias["#docus/database"] = resolveRuntimeDir("database/providers", options.database.provider);
254
- nuxt.options.alias["#docus/cache"] = pathe.join(nuxt.options.rootDir, "node_modules/.cache/docus");
255
- nuxt.options.meta = nuxt.options.meta || {};
256
- nuxt.options.head = nuxt.options.head || {};
257
- nuxt.options.head.meta = nuxt.options.head.meta || [];
258
- nuxt.options.head.meta.push({ charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" });
259
- nuxt.options.bridge = nuxt.options.bridge || {};
260
- nuxt.options.bridge.autoImports = false;
261
- nuxt.options.bridge.postcss8 = true;
262
- nuxt.options.components = Array.isArray(nuxt.options.components) ? nuxt.options.components : [];
263
- nuxt.options.components.push({
264
- path: resolveAppDir("components"),
265
- isAsync: false,
266
- prefix: "",
267
- level: 999
268
- });
269
- nuxt.options.colorMode = nuxt.options.colorMode || {};
270
- nuxt.options.colorMode.classSuffix = "";
271
- nuxt.options.image = nuxt.options.image || {};
272
- nuxt.options.image.domains = nuxt.options.image.domains || [];
273
- nuxt.options.image.domains.push("https://i3.ytimg.com");
274
- nuxt.options.target = "server";
275
- nuxt.options.server = nuxt.options.server || {};
276
- nuxt.options.server.port = parseInt(process.env.PORT || "4000", 10);
277
- nuxt.options.generate = nuxt.options.generate || {};
278
- nuxt.options.generate.routes = nuxt.options.generate.routes || [];
279
- nuxt.options.generate.fallback = "404.html";
280
- nuxt.options.generate.routes.push("/");
281
- nuxt.options.nitro = nuxt.options.nitro || {};
282
- nuxt.options.nitro.experiments = nuxt.options.nitro.experiments || {};
283
- nuxt.options.nitro.experiments.wasm = true;
284
- nuxt.options.nitro.inlineDynamicImports = true;
285
- nuxt.options.nitro.externals = process.env.NITRO_PRESET === "cloudflare" ? false : {
286
- inline: ["docus", "ohmyfetch", "property-information", "@docus/mdc"],
287
- external: [
288
- "vue-docgen-api",
289
- "@nuxt/kit",
290
- "@nuxt/image",
291
- "@nuxtjs/i18n",
292
- "vue-meta",
293
- "vue-router",
294
- "vue-i18n",
295
- "ufo",
296
- "vue-client-only",
297
- "vue-no-ssr",
298
- "ohmyfetch"
299
- ]
300
- };
301
- nuxt.options.build = nuxt.options.build || {};
302
- nuxt.options.build.transpile = nuxt.options.build.transpile || [];
303
- nuxt.options.build.transpile.push("@docus/", "ohmyfetch", "property-information", "nuxt-component-meta", "@nuxt/bridge");
304
- nuxt.options.layouts.default = resolveAppDir("layouts/default.vue");
305
- nuxt.hook("build:extendRoutes", (routes) => {
306
- const hasRoute = (name) => routes.some((route) => route.name === name);
307
- if (!hasRoute("all")) {
308
- routes.push({
309
- path: "/*",
310
- name: "all",
311
- component: resolveAppDir("pages/_.vue")
312
- });
313
- }
314
- });
315
- nuxt.hook("build:before", async () => {
316
- const errorPagePath = pathe.resolve(nuxt.options.srcDir, nuxt.options.dir.layouts, "error.vue");
317
- const errorPageExists = await fs__default.stat(errorPagePath).catch(() => false);
318
- if (!errorPageExists)
319
- nuxt.options.ErrorPage = nuxt.options.ErrorPage || resolveAppDir("layouts/error.vue");
320
- const pagesDirPath = pathe.resolve(nuxt.options.srcDir, nuxt.options.dir.pages);
321
- const pagesDirExists = await fs__default.stat(pagesDirPath).catch(() => false);
322
- if (!pagesDirExists) {
323
- nuxt.options.build.createRoutes = () => [];
324
- nuxt.options.watch.push(pagesDirPath);
325
- }
326
- });
327
- nuxt.hook("components:dirs", async (dirs) => {
328
- const componentsDirPath = pathe.resolve(nuxt.options.rootDir, "components");
329
- const componentsDirStat = await fs__default.stat(componentsDirPath).catch(() => null);
330
- if (componentsDirStat && componentsDirStat.isDirectory()) {
331
- dirs.push({
332
- path: componentsDirPath,
333
- isAsync: false
334
- });
335
- const subDirs = await glob(componentsDirPath + "/**/");
336
- subDirs.forEach((path) => dirs.push({ path, isAsync: false }));
337
- } else {
338
- nuxt.options.watch.push(componentsDirPath);
339
- }
340
- });
341
- kit.addTemplate({
342
- src: kit.resolveModule("./options", { paths: templateDir }),
343
- filename: "docus/options.mjs",
344
- options
345
- });
346
- kit.addPluginTemplate({
347
- src: kit.resolveModule("./docus", { paths: templateDir })
348
- }, {
349
- append: true
350
- });
351
- nuxt.hook("modules:done", () => nuxt.callHook("docus:options", options));
352
- };
353
-
354
- const version = "2.1.0";
355
-
356
- const themeContext = unctx.getContext("docus:theme");
357
- const setThemeConfig = themeContext.set;
358
- themeContext.use;
359
- const configContext = unctx.getContext("docus:config");
360
- const setDocusConfig = configContext.set;
361
- const useDocusConfig = configContext.use;
362
-
363
- const setupThemeModule = (nuxt) => {
364
- const cacheDir = nuxt.options.alias["#docus/cache"];
365
- const docusConfig = useDocusConfig();
366
- let themeConfig = {};
367
- if (docusConfig?.theme) {
368
- const themePath = kit.resolveAlias(docusConfig?.theme, nuxt.options.alias);
369
- themeConfig = loadTheme(themePath, nuxt.options.rootDir);
370
- }
371
- const { configFile, configPath } = loadConfig(THEME_CONFIG_FILE, nuxt.options.rootDir);
372
- themeConfig = defu__default(configFile || {}, themeConfig);
373
- setThemeConfig(themeConfig, true);
374
- nuxt.hook("modules:done", async () => await writeConfig(THEME_CONFIG_FILE, cacheDir, themeConfig));
375
- nuxt.options.cli.badgeMessages.push("", chalk__default.bold("\u{1F484} Theme: ") + chalk__default.underline.yellow(themeConfig?.name || "Blank"));
376
- nuxt.options.watch.push(configPath);
377
- };
378
-
379
- const defaultConfig = defineDocusConfig({
380
- title: "Docus",
381
- contentDir: "content",
382
- url: "http://localhost:3000",
383
- description: "A website built with Docus.",
384
- template: "page"
385
- });
386
- const setupConfigModule = (nuxt) => {
387
- const cacheDir = nuxt.options.alias["#docus/cache"];
388
- const { configFile: docusConfig, configPath } = loadConfig(DOCUS_CONFIG_FILE, nuxt.options.rootDir);
389
- const config = defu__default(docusConfig || {}, defaultConfig);
390
- nuxt.options.cli.badgeMessages.push(chalk__default.bold("\u{1F4DD} Docus: ") + chalk__default.underline.yellow(`v${version}`));
391
- setDocusConfig(config, true);
392
- setupThemeModule(nuxt);
393
- nuxt.options.meta.name = config.title;
394
- nuxt.options.meta.description = config.description;
395
- nuxt.hook("modules:done", async () => await writeConfig(DOCUS_CONFIG_FILE, cacheDir, config));
396
- nuxt.options.watch.push(configPath);
397
- };
398
-
399
- const defaultI18nConfig = {
400
- baseUrl: (nuxt) => nuxt.app?.$docus?.config?.value?.url || "",
401
- locales: [],
402
- defaultLocale: "en",
403
- parsePages: false,
404
- vuex: false,
405
- vueI18n: {
406
- fallbackLocale: "en",
407
- dateTimeFormats: {
408
- en: {
409
- long: {
410
- year: "numeric",
411
- month: "short",
412
- day: "numeric",
413
- weekday: "short"
414
- }
415
- },
416
- fr: {
417
- long: {
418
- year: "numeric",
419
- month: "long",
420
- day: "numeric",
421
- weekday: "short"
422
- }
423
- }
424
- }
425
- }
426
- };
427
- const setupI18nModule = async (nuxt) => {
428
- const config = useDocusConfig();
429
- nuxt.options.i18n = defu__default(nuxt.options.i18n, defaultI18nConfig);
430
- const i18nConfig = nuxt.options.i18n;
431
- try {
432
- if (!nuxt.options.i18n?.locales?.length) {
433
- const contentDir = pathe.resolve(nuxt.options.srcDir, config?.contentDir || "content");
434
- const contentDirectories = fs__default$1.readdirSync(contentDir);
435
- i18nConfig.locales = contentDirectories.filter((lang) => !!iso639__default.getName(lang)).map((code) => ({ code, iso: code, name: iso639__default.getName(code) }));
436
- if (!i18nConfig.locales.length)
437
- throw new Error("No locales detected from `contentDir`! Using fallback.");
438
- }
439
- } catch (e) {
440
- const defaultLocale = i18nConfig.defaultLocale || "en";
441
- i18nConfig.locales = [
442
- {
443
- code: defaultLocale,
444
- iso: defaultLocale,
445
- name: iso639__default.getName(defaultLocale) || defaultLocale
446
- }
447
- ];
448
- }
449
- kit.addPlugin(kit.resolveModule("./i18n", { paths: templateDir }));
450
- const localesList = i18nConfig.locales?.map(({ code }) => code).join(", ") || "en";
451
- nuxt.options.cli.badgeMessages.push("", chalk__default.bold("\u{1F4D9} Languages: ") + chalk__default.underline.yellow(localesList));
452
- await kit.installModule(nuxt, "@nuxtjs/i18n");
453
- nuxt.hook("docus:context", (docusContext) => {
454
- const codes = nuxt.options.i18n?.locales.map((locale) => locale.code || locale);
455
- docusContext.locales.codes = codes || docusContext.locales.codes;
456
- docusContext.locales.defaultLocale = nuxt.options.i18n?.defaultLocale || docusContext.locales.defaultLocale;
457
- });
458
- nuxt.hook("build:extendRoutes", (routes) => {
459
- const index = routes.findIndex((route) => route.path === "/*");
460
- const [all] = routes.splice(index, 1);
461
- routes.push(all);
462
- });
463
- };
464
-
465
- async function setupComponentMetaModule(nuxt) {
466
- const markdownTemplateHanlder = (documentation, ast) => {
467
- if (ast.tag === "Markdown") {
468
- const useValue = ast.props?.find((prop) => prop.name === "use")?.value;
469
- const slotName = (typeof useValue === "object" ? useValue.content : useValue) ?? "default";
470
- documentation.getSlotDescriptor(slotName);
471
- }
472
- };
473
- await kit.installModule(nuxt, {
474
- src: "nuxt-component-meta/module",
475
- options: {
476
- parserOptions: {
477
- addTemplateHandlers: [markdownTemplateHanlder]
478
- }
479
- }
480
- });
481
- }
482
-
483
- const setupContentModule = (nuxt, options) => {
484
- nuxt.hook("nitro:context", (ctx) => {
485
- if (ctx.preset === "dev") {
486
- for (const dir of options.dirs) {
487
- const [path, key] = Array.isArray(dir) ? dir : [dir, dir.replace(/[/:]/g, "_")];
488
- ctx.storage.mounts[`docus:source:${key}`] = {
489
- driver: "fs",
490
- driverOptions: {
491
- base: pathe.resolve(nuxt.options.rootDir, path)
492
- }
493
- };
494
- }
495
- ctx.storage.mounts["assets:docus:build"] = {
496
- driver: "fs",
497
- driverOptions: {
498
- base: pathe.resolve(nuxt.options.buildDir, "docus/build")
499
- }
500
- };
501
- } else {
502
- ctx.assets.dirs["docus:build"] = {
503
- dir: pathe.resolve(nuxt.options.buildDir, "docus/build"),
504
- meta: true
505
- };
506
- }
507
- if (!ctx.storage.mounts["docus:preview"]) {
508
- ctx.storage.mounts["docus:preview"] = {
509
- driver: "memory"
510
- };
511
- }
512
- });
513
- for (const api of ["get", "list", "search", "navigation", "preview"]) {
514
- kit.addServerMiddleware({
515
- route: resolveApiRoute(api),
516
- handle: kit.resolveModule(`./server/api/${api}`, { paths: runtimeDir }).replace(/\.js$/, ".mjs")
517
- });
518
- }
519
- nuxt.options.publicRuntimeConfig.$docus = {
520
- apiBase: options.apiBase,
521
- tagMap: options.transformers.markdown.tagMap
522
- };
523
- kit.addPlugin(kit.resolveModule("./content", { paths: templateDir }));
524
- };
525
-
526
- const index = kit.defineNuxtModule((nuxt) => ({
527
- configKey: "content",
528
- defaults: useDefaultOptions(nuxt),
529
- async setup(options, nuxt2) {
530
- if (nuxt2.options.dev)
531
- setupDevTarget(options, nuxt2);
532
- setupAppModule(nuxt2, options);
533
- setupContentModule(nuxt2, options);
534
- setupConfigModule(nuxt2);
535
- await setupI18nModule(nuxt2);
536
- await setupComponentMetaModule(nuxt2);
537
- await kit.installModule(nuxt2, "@nuxt/image");
538
- }
539
- }));
540
-
541
- exports.buildExternals = buildExternals;
542
- exports["default"] = index;
543
- exports.defineDocusConfig = defineDocusConfig;
544
- exports.defineThemeConfig = defineThemeConfig;
545
- exports.loadConfig = loadConfig;
546
- exports.loadNuxtIgnoreList = loadNuxtIgnoreList;
547
- exports.loadTheme = loadTheme;
548
- exports.resolveApiRoute = resolveApiRoute;
549
- exports.writeConfig = writeConfig;
package/dist/index.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { Nuxt } from '@nuxt/schema';
3
- import { ThemeConfig, DocusConfig } from 'types';
4
-
5
- declare const _default: _nuxt_schema.LegacyNuxtModule;
6
-
7
- /**
8
- * Define the the theme configuration object.
9
- */
10
- declare const defineThemeConfig: <T = ThemeConfig>(config: Partial<T>) => Partial<T>;
11
- /**
12
- * Define the Docus configuration object.
13
- */
14
- declare const defineDocusConfig: (config: DocusConfig) => DocusConfig;
15
- declare const loadConfig: <T = any>(file: string, rootDir: string) => {
16
- configFile: false | T;
17
- configPath: string;
18
- };
19
- declare const writeConfig: (file: string, cacheDir: string, content: any) => Promise<void>;
20
- declare const loadTheme: (path: string, rootDir: string) => ThemeConfig;
21
- declare const buildExternals: string[];
22
- declare const resolveApiRoute: (route: string) => string;
23
- declare function loadNuxtIgnoreList(nuxt: Nuxt): Promise<string[]>;
24
-
25
- export { buildExternals, _default as default, defineDocusConfig, defineThemeConfig, loadConfig, loadNuxtIgnoreList, loadTheme, resolveApiRoute, writeConfig };