docus 2.1.0 → 3.0.0-beta.1

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 +23 -0
  7. package/components/app/Footer.vue +38 -0
  8. package/components/app/Navbar.vue +26 -0
  9. package/components/app/NavbarLogo.vue +31 -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 +44 -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 +134 -0
  19. package/components/content/CopyButton.vue +48 -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 +24 -0
  23. package/components/content/Sandbox.vue +100 -0
  24. package/components/content/TabsHeader.vue +44 -0
  25. package/components/content/Terminal.vue +70 -0
  26. package/components/content/VideoPlayer.vue +113 -0
  27. package/components/docs/DocsAside.vue +19 -0
  28. package/components/docs/DocsAsideTree.vue +101 -0
  29. package/components/docs/DocsHero.vue +39 -0
  30. package/components/docs/DocsPage.vue +22 -0
  31. package/components/docs/DocsPageContent.vue +29 -0
  32. package/components/docs/DocsToc.vue +72 -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 +43 -0
  36. package/components/globals/SocialIcons.vue +43 -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 +32 -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 +155 -0
  108. package/composables/useMenu.ts +20 -0
  109. package/composables/useScrollToHeading.ts +35 -0
  110. package/composables/useScrollspy.ts +45 -0
  111. package/composables/useTheme.ts +10 -0
  112. package/layouts/default.vue +27 -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 +24 -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
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = transformJSON;
7
-
8
- function transformJSON(_id, input) {
9
- if (typeof input === "string") return {
10
- body: JSON.parse(input)
11
- };
12
- return {
13
- body: input
14
- };
15
- }
@@ -1,5 +0,0 @@
1
- export default function transformJSON(_id, input) {
2
- if (typeof input === "string")
3
- return { body: JSON.parse(input) };
4
- return { body: input };
5
- }
@@ -1,8 +0,0 @@
1
- export default function transformMarkdown(id: string, input: string): Promise<{
2
- body: {
3
- raw: string;
4
- ast: import("@docus/mdc").MDCRoot;
5
- toc: import("@docus/mdc").Toc;
6
- };
7
- meta: any;
8
- }>;
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = transformMarkdown;
7
-
8
- var _mdc = require("@docus/mdc");
9
-
10
- var _context = require("../../context");
11
-
12
- var _utils = require("../utils");
13
-
14
- async function transformMarkdown(id, input) {
15
- const context = (0, _context.useDocusContext)();
16
- const result = await (0, _mdc.parse)(input, context.transformers.markdown);
17
- const pathMeta = (0, _utils.getPathMeta)(id, {
18
- locales: context.locales.codes,
19
- defaultLocale: context.locales.defaultLocale
20
- });
21
- result.meta = { ...pathMeta,
22
- ...result.meta
23
- };
24
- return result;
25
- }
@@ -1,16 +0,0 @@
1
- import { parse } from "@docus/mdc";
2
- import { useDocusContext } from "../../context.mjs";
3
- import { getPathMeta } from "../utils/index.mjs";
4
- export default async function transformMarkdown(id, input) {
5
- const context = useDocusContext();
6
- const result = await parse(input, context.transformers.markdown);
7
- const pathMeta = getPathMeta(id, {
8
- locales: context.locales.codes,
9
- defaultLocale: context.locales.defaultLocale
10
- });
11
- result.meta = {
12
- ...pathMeta,
13
- ...result.meta
14
- };
15
- return result;
16
- }
@@ -1 +0,0 @@
1
- export * from './path';
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _path = require("./path");
8
-
9
- Object.keys(_path).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _path[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _path[key];
16
- }
17
- });
18
- });
@@ -1 +0,0 @@
1
- export * from "./path.mjs";
@@ -1,26 +0,0 @@
1
- export declare function generatePosition(path: string): string;
2
- /**
3
- * Clean up special keywords from path part
4
- */
5
- export declare function generateSlug(name: string): string;
6
- export declare function generateTitleFromSlug(slug: string): string;
7
- export declare function generateTo(path: string): string;
8
- export declare function isDraft(path: string): boolean;
9
- /**
10
- * Files or directories that starts with underscore `_` will mark as hidden
11
- * @param path content path
12
- * @returns true if the is part in the path that starts with `_`
13
- */
14
- export declare function isHidden(path: string): boolean;
15
- export declare function getPathMeta(id: string, { locales, defaultLocale }?: {
16
- locales?: string[];
17
- defaultLocale?: string;
18
- }): {
19
- slug: string;
20
- title: string;
21
- position: string;
22
- to: string;
23
- draft: boolean;
24
- page: boolean;
25
- language: string;
26
- };
@@ -1,88 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generatePosition = generatePosition;
7
- exports.generateSlug = generateSlug;
8
- exports.generateTitleFromSlug = generateTitleFromSlug;
9
- exports.generateTo = generateTo;
10
- exports.getPathMeta = getPathMeta;
11
- exports.isDraft = isDraft;
12
- exports.isHidden = isHidden;
13
-
14
- var _scule = require("scule");
15
-
16
- var _ufo = require("ufo");
17
-
18
- const SEMVER_REGEX = /^(\d+)(\.\d+)*(\.x)?$/;
19
-
20
- function generatePosition(path) {
21
- const position = path.split(/[/:]/).filter(Boolean).map(part => {
22
- const match = part.match(/^(\d+)\./);
23
-
24
- if (match) {
25
- return padLeft(match[1], 4);
26
- }
27
-
28
- return "9999";
29
- }).join("");
30
- return padRight(position, 12);
31
- }
32
-
33
- function generateSlug(name) {
34
- if (SEMVER_REGEX.test(name)) {
35
- return name;
36
- }
37
-
38
- return name.replace(/^_/, "").replace(/(\d+\.)?(.*)/, "$2").replace(/^index/, "").replace(/\.draft/, "");
39
- }
40
-
41
- function generateTitleFromSlug(slug) {
42
- return slug.split(/[\s-]/g).map(_scule.pascalCase).join(" ");
43
- }
44
-
45
- function generateTo(path) {
46
- return (0, _ufo.withLeadingSlash)((0, _ufo.withoutTrailingSlash)(path.split("/").map(generateSlug).join("/")));
47
- }
48
-
49
- function isDraft(path) {
50
- return !!path.match(/\.draft(\/|\.|$)/);
51
- }
52
-
53
- function isHidden(path) {
54
- return path.split("/").some(part => part.match(/^_.*/));
55
- }
56
-
57
- function padLeft(value, length) {
58
- return ("0".repeat(length) + value).substr(String(value).length);
59
- }
60
-
61
- function padRight(value, length) {
62
- return (value + "0".repeat(length)).substr(0, length);
63
- }
64
-
65
- function getPathMeta(id, {
66
- locales = ["en"],
67
- defaultLocale = "en"
68
- } = {}) {
69
- const regexp = new RegExp(`^/?(${locales.join("|")})`, "gi");
70
- const paths = id.split(".").slice(0, -1).join(".").split(/:/g).slice(1);
71
- let path = paths.join("/");
72
- const [language] = path.match(regexp) || [];
73
-
74
- if (language) {
75
- path = path.replace(regexp, "");
76
- }
77
-
78
- const slug = generateSlug(paths[paths.length - 1]);
79
- return {
80
- slug,
81
- title: generateTitleFromSlug(slug),
82
- position: generatePosition(path),
83
- to: generateTo(path),
84
- draft: isDraft(path),
85
- page: !isHidden(path),
86
- language: language || defaultLocale
87
- };
88
- }
@@ -1,56 +0,0 @@
1
- import { pascalCase } from "scule";
2
- import { withoutTrailingSlash, withLeadingSlash } from "ufo";
3
- const SEMVER_REGEX = /^(\d+)(\.\d+)*(\.x)?$/;
4
- export function generatePosition(path) {
5
- const position = path.split(/[/:]/).filter(Boolean).map((part) => {
6
- const match = part.match(/^(\d+)\./);
7
- if (match) {
8
- return padLeft(match[1], 4);
9
- }
10
- return "9999";
11
- }).join("");
12
- return padRight(position, 12);
13
- }
14
- export function generateSlug(name) {
15
- if (SEMVER_REGEX.test(name)) {
16
- return name;
17
- }
18
- return name.replace(/^_/, "").replace(/(\d+\.)?(.*)/, "$2").replace(/^index/, "").replace(/\.draft/, "");
19
- }
20
- export function generateTitleFromSlug(slug) {
21
- return slug.split(/[\s-]/g).map(pascalCase).join(" ");
22
- }
23
- export function generateTo(path) {
24
- return withLeadingSlash(withoutTrailingSlash(path.split("/").map(generateSlug).join("/")));
25
- }
26
- export function isDraft(path) {
27
- return !!path.match(/\.draft(\/|\.|$)/);
28
- }
29
- export function isHidden(path) {
30
- return path.split("/").some((part) => part.match(/^_.*/));
31
- }
32
- function padLeft(value, length) {
33
- return ("0".repeat(length) + value).substr(String(value).length);
34
- }
35
- function padRight(value, length) {
36
- return (value + "0".repeat(length)).substr(0, length);
37
- }
38
- export function getPathMeta(id, { locales = ["en"], defaultLocale = "en" } = {}) {
39
- const regexp = new RegExp(`^/?(${locales.join("|")})`, "gi");
40
- const paths = id.split(".").slice(0, -1).join(".").split(/:/g).slice(1);
41
- let path = paths.join("/");
42
- const [language] = path.match(regexp) || [];
43
- if (language) {
44
- path = path.replace(regexp, "");
45
- }
46
- const slug = generateSlug(paths[paths.length - 1]);
47
- return {
48
- slug,
49
- title: generateTitleFromSlug(slug),
50
- position: generatePosition(path),
51
- to: generateTo(path),
52
- draft: isDraft(path),
53
- page: !isHidden(path),
54
- language: language || defaultLocale
55
- };
56
- }
@@ -1 +0,0 @@
1
- export * from './log';
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _log = require("./log");
8
-
9
- Object.keys(_log).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _log[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _log[key];
16
- }
17
- });
18
- });
@@ -1 +0,0 @@
1
- export * from "./log.mjs";
@@ -1 +0,0 @@
1
- export declare const logger: import("consola").Consola;
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.logger = void 0;
7
-
8
- var _consola = _interopRequireDefault(require("consola"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const logger = _consola.default.withScope("@docus");
13
-
14
- exports.logger = logger;
@@ -1,2 +0,0 @@
1
- import consola from "consola";
2
- export const logger = consola.withScope("@docus");
@@ -1,9 +0,0 @@
1
- /**
2
- * Returns a new object with the specified keys
3
- **/
4
- export declare const pick: (keys: string[]) => (obj: any) => any;
5
- /**
6
- * Returns a new object with all the keys of the original object execept the ones specified.
7
- **/
8
- export declare const omit: (keys: string[]) => (obj: any) => any;
9
- export declare const apply: (fn: (d: any) => any) => (data: any) => any;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pick = exports.omit = exports.apply = void 0;
7
-
8
- const _pick = (obj, condition) => Object.keys(obj).filter(condition).reduce((newObj, key) => Object.assign(newObj, {
9
- [key]: obj[key]
10
- }), {});
11
-
12
- const pick = keys => obj => keys && keys.length ? _pick(obj, key => keys.includes(key)) : obj;
13
-
14
- exports.pick = pick;
15
-
16
- const omit = keys => obj => keys && keys.length ? _pick(obj, key => !keys.includes(key)) : obj;
17
-
18
- exports.omit = omit;
19
-
20
- const apply = fn => data => Array.isArray(data) ? data.map(item => fn(item)) : fn(data);
21
-
22
- exports.apply = apply;
@@ -1,4 +0,0 @@
1
- const _pick = (obj, condition) => Object.keys(obj).filter(condition).reduce((newObj, key) => Object.assign(newObj, { [key]: obj[key] }), {});
2
- export const pick = (keys) => (obj) => keys && keys.length ? _pick(obj, (key) => keys.includes(key)) : obj;
3
- export const omit = (keys) => (obj) => keys && keys.length ? _pick(obj, (key) => !keys.includes(key)) : obj;
4
- export const apply = (fn) => (data) => Array.isArray(data) ? data.map((item) => fn(item)) : fn(data);
@@ -1,50 +0,0 @@
1
- import { withoutTrailingSlash, joinURL } from "ufo";
2
- import Query from "#docus/database/Query";
3
- const createQuery = (options) => (path, opts) => {
4
- const to = typeof path === "string" ? path : "";
5
- const params = (typeof path === "object" ? path : opts) || {};
6
- return new Query(to, { ...params, ...options });
7
- };
8
- export function getContent(ctx, previewKey = "") {
9
- let { $docus } = ctx.$config ? ctx.$config : ctx.nuxtState;
10
- if (!$docus) {
11
- $docus = {
12
- apiBase: "_docus",
13
- wsUrl: "ws://localhost:4000"
14
- };
15
- }
16
- const query = previewKey ? "?preview=" + previewKey : "";
17
- const fetch = (key, opts = void 0) => globalThis.$fetch(joinURL("/api", $docus.apiBase, key) + query, opts);
18
- const get = (key) => fetch(joinURL("get", key));
19
- const search = createQuery({
20
- base: withoutTrailingSlash(joinURL("/api", $docus.apiBase, "search") + query)
21
- });
22
- if (previewKey) {
23
- return {
24
- fetch,
25
- get,
26
- search,
27
- setItem: async (key, content) => {
28
- await fetch("preview", { method: "POST", body: { key, content } });
29
- if (typeof window !== "undefined") {
30
- window.$nuxt.$emit("docus:content:preview", { key, event: "change" });
31
- }
32
- },
33
- removeItem: async (key) => {
34
- await fetch(joinURL("preview", key), { method: "DELETE" });
35
- if (typeof window !== "undefined") {
36
- window.$nuxt.$emit("docus:content:preview", { key, event: "remove" });
37
- }
38
- }
39
- };
40
- }
41
- return {
42
- fetch,
43
- get,
44
- search,
45
- preview: (previewKey2 = "memory") => getContent(ctx, previewKey2)
46
- };
47
- }
48
- export default async function(ctx, inject) {
49
- inject("content", getContent(ctx));
50
- }
@@ -1,13 +0,0 @@
1
- import { defineNuxtPlugin } from "#app";
2
- import { createDocus } from "#docus";
3
- import docusConfig from "#docus/cache/docus.config.json";
4
- import themeConfig from "#docus/cache/theme.config.json";
5
- export default defineNuxtPlugin(async (nuxt) => {
6
- const { $docus, init } = createDocus(nuxt, { docusConfig, themeConfig });
7
- nuxt.provide("docus", $docus);
8
- nuxt.provide("navigation", $docus.navigation);
9
- if (process.client) {
10
- window.$docus = $docus;
11
- }
12
- await init();
13
- });
@@ -1,16 +0,0 @@
1
- import { joinURL } from "ufo";
2
- import { useWebSocket } from "#docus/composables/websocket";
3
- export default async function(ctx) {
4
- let { $docus } = ctx.$config ? ctx.$config : ctx.nuxtState;
5
- if (!$docus) {
6
- $docus = {
7
- apiBase: "_docus",
8
- wsUrl: "ws://localhost:4000"
9
- };
10
- }
11
- if (process.client) {
12
- const protocol = location.protocol === "https:" ? "wss" : "ws";
13
- const baseUrl = joinURL($docus.wsUrl || `${protocol}://${location.hostname}:${location.port}`, $docus.apiBase);
14
- useWebSocket(baseUrl)?.connect();
15
- }
16
- }
@@ -1,23 +0,0 @@
1
- import { defineNuxtPlugin } from "#app";
2
- export default defineNuxtPlugin((nuxt) => {
3
- nuxt.provide("contentLocalePath", (path) => {
4
- const app = nuxt.vue2App;
5
- const { localeCodes, defaultLocale } = nuxt.nuxt2Context.i18n;
6
- let localePath = localeCodes.some((code) => path.startsWith(`/${code}`)) ? path : app.localePath(path);
7
- if (localePath.startsWith(`/${defaultLocale}`)) {
8
- localePath = localePath.replace(`/${defaultLocale}`, "");
9
- }
10
- if (path.endsWith("/") && !localePath.endsWith("/")) {
11
- localePath += "/";
12
- }
13
- if (!path.endsWith("/") && localePath.endsWith("/")) {
14
- localePath = localePath.replace(/\/*$/, "");
15
- }
16
- return localePath;
17
- });
18
- if (process.client) {
19
- nuxt.nuxt2Context.i18n.onLanguageSwitched = () => {
20
- window.$docus.navigation.fetchNavigation(nuxt.nuxt2Context.i18n.locale);
21
- };
22
- }
23
- });
@@ -1,46 +0,0 @@
1
- // @ts-nocheck
2
- <%
3
- const remarkPlugins = options.transformers.markdown.remarkPlugins
4
- const rehypePlugins = options.transformers.markdown.rehypePlugins
5
- const components = options.transformers.markdown.components
6
-
7
- const serializeImportName = id => '_' + id.replace(/[^a-zA-Z0-9_$]/g, '_')
8
- %>
9
- <% components.forEach(item => { %>
10
- import <%= serializeImportName(item.name) %> from '<%= item.path %>'
11
- <% }) %>
12
- <% remarkPlugins.forEach(item => { %>
13
- import <%= serializeImportName(item[0] || item.name || item) %> from '<%= item[0] || item.name || item %>'
14
- <% }) %>
15
- <% rehypePlugins.forEach(item => { %>
16
- import <%= serializeImportName(item[0] || item.name || item) %> from '<%= item[0] || item.name || item %>'
17
- <% }) %>
18
-
19
- const _context = <%= JSON.stringify(options) %>
20
-
21
- _context.transformers.markdown.components = [
22
- <% components.forEach(item => { %>{
23
- name: '<%= item.name %>',
24
- instance: <%= serializeImportName(item.name) %>,
25
- options: <%= JSON.stringify(item.options || {}) %>
26
- }, <% }) %>
27
- ]
28
-
29
- _context.transformers.markdown.remarkPlugins = [
30
- <% remarkPlugins.forEach(item => { %>{
31
- name: '<%= item[0] || item.name || item %>',
32
- instance: <%= serializeImportName(item[0] || item.name || item) %>,
33
- options: <%= JSON.stringify(item[1] || item.options || {}) %>
34
- }, <% }) %>
35
- ]
36
-
37
- _context.transformers.markdown.rehypePlugins = [
38
- <% rehypePlugins.forEach(item => { %>{
39
- name: '<%= item[0] || item.name || item %>',
40
- instance: <%= serializeImportName(item[0] || item.name || item) %>,
41
- options: <%= JSON.stringify(item[1] || item.options || {}) %>
42
- }, <% }) %>
43
- ]
44
-
45
- export const context = _context
46
- export default _context
package/shims.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import type { DocusContent } from 'types'
2
-
3
- declare global {
4
- declare namespace NodeJS {
5
- interface Process {
6
- dev: boolean
7
- client: boolean
8
- server: boolean
9
- options: any
10
- previewUrl: string
11
- }
12
- }
13
-
14
- interface Window {
15
- onNuxtReady: any
16
- $docus: DocusRuntimeInstance
17
- }
18
- }
19
-
20
- declare module '@nuxt/types' {
21
- interface Context {
22
- $content: DocusContent<any>
23
- }
24
- }