docus 2.1.0 → 3.0.0-beta.11

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 (282) hide show
  1. package/README.md +6 -4
  2. package/package.json +39 -83
  3. package/theme/app/router.options.ts +18 -0
  4. package/theme/assets/css/fonts.css +84 -0
  5. package/theme/assets/css/main.css +104 -0
  6. package/theme/components/app/Container.vue +25 -0
  7. package/theme/components/app/Footer.vue +40 -0
  8. package/theme/components/app/MobileNav.vue +85 -0
  9. package/theme/components/app/Navbar.vue +37 -0
  10. package/theme/components/app/NavbarLogo.vue +33 -0
  11. package/theme/components/app/Page.vue +7 -0
  12. package/theme/components/app/PoweredByDocus.vue +11 -0
  13. package/theme/components/content/Alert.vue +124 -0
  14. package/theme/components/content/BlockHero.vue +54 -0
  15. package/theme/components/content/ButtonLink.vue +45 -0
  16. package/theme/components/content/Card.vue +46 -0
  17. package/theme/components/content/CardGrid.vue +23 -0
  18. package/theme/components/content/CodeBlock.vue +47 -0
  19. package/theme/components/content/CodeGroup.vue +135 -0
  20. package/theme/components/content/CopyButton.vue +49 -0
  21. package/{dist/runtime/app/components/prose/ProseOl.vue → theme/components/content/List.vue} +2 -2
  22. package/theme/components/content/NeedContribution.vue +23 -0
  23. package/theme/components/content/ReadMore.vue +25 -0
  24. package/theme/components/content/Sandbox.vue +102 -0
  25. package/theme/components/content/TabsHeader.vue +44 -0
  26. package/theme/components/content/Terminal.vue +64 -0
  27. package/theme/components/content/VideoPlayer.vue +115 -0
  28. package/theme/components/dev/Debug.vue +65 -0
  29. package/theme/components/docs/DocsAside.vue +21 -0
  30. package/theme/components/docs/DocsAsideTree.vue +104 -0
  31. package/theme/components/docs/DocsHero.vue +39 -0
  32. package/theme/components/docs/DocsPage.vue +21 -0
  33. package/theme/components/docs/DocsPageContent.vue +32 -0
  34. package/theme/components/docs/DocsToc.vue +77 -0
  35. package/theme/components/globals/Icon.vue +24 -0
  36. package/{dist/runtime/app/components/prose/ProseHr.vue → theme/components/globals/Logo.vue} +1 -1
  37. package/theme/components/globals/NuxtImg.vue +45 -0
  38. package/theme/components/globals/SocialIcons.vue +45 -0
  39. package/theme/components/globals/ThemeSelect.vue +35 -0
  40. package/theme/components/icons/IconAlgolia.vue +8 -0
  41. package/theme/components/icons/IconArrowLeft.vue +10 -0
  42. package/theme/components/icons/IconArrowRight.vue +10 -0
  43. package/theme/components/icons/IconBadgeCheck.vue +14 -0
  44. package/theme/components/icons/IconCheck.vue +10 -0
  45. package/theme/components/icons/IconCheckCircle.vue +10 -0
  46. package/theme/components/icons/IconChevronRight.vue +12 -0
  47. package/theme/components/icons/IconClipboardCheck.vue +14 -0
  48. package/theme/components/icons/IconClipboardCopy.vue +14 -0
  49. package/theme/components/icons/IconCodeSandbox.vue +8 -0
  50. package/theme/components/icons/IconCopy.vue +17 -0
  51. package/theme/components/icons/IconDots.vue +10 -0
  52. package/theme/components/icons/IconEdit.vue +18 -0
  53. package/theme/components/icons/IconExclamationCircle.vue +12 -0
  54. package/theme/components/icons/IconExclamationTriangle.vue +10 -0
  55. package/theme/components/icons/IconExternalLink.vue +12 -0
  56. package/theme/components/icons/IconGit.vue +7 -0
  57. package/theme/components/icons/IconGitHub.vue +10 -0
  58. package/theme/components/icons/IconHeart.vue +9 -0
  59. package/theme/components/icons/IconInformationCircle.vue +10 -0
  60. package/theme/components/icons/IconLighthouse.vue +83 -0
  61. package/theme/components/icons/IconLine.vue +10 -0
  62. package/theme/components/icons/IconMarkdown.vue +13 -0
  63. package/theme/components/icons/IconMenu.vue +12 -0
  64. package/theme/components/icons/IconMenuAlt.vue +10 -0
  65. package/theme/components/icons/IconMinus.vue +10 -0
  66. package/theme/components/icons/IconMoon.vue +10 -0
  67. package/theme/components/icons/IconNuxt.vue +14 -0
  68. package/theme/components/icons/IconNuxtContent.vue +20 -0
  69. package/theme/components/icons/IconNuxtLabs.vue +21 -0
  70. package/theme/components/icons/IconPlus.vue +10 -0
  71. package/theme/components/icons/IconPuzzle.vue +8 -0
  72. package/theme/components/icons/IconSSG.vue +7 -0
  73. package/theme/components/icons/IconSearch.vue +12 -0
  74. package/theme/components/icons/IconSun.vue +10 -0
  75. package/theme/components/icons/IconTailwind.vue +3 -0
  76. package/theme/components/icons/IconTocBack.vue +21 -0
  77. package/theme/components/icons/IconTocCurrent.vue +21 -0
  78. package/theme/components/icons/IconTocNext.vue +8 -0
  79. package/theme/components/icons/IconTranslate.vue +14 -0
  80. package/theme/components/icons/IconTwitter.vue +8 -0
  81. package/theme/components/icons/IconVite.vue +30 -0
  82. package/theme/components/icons/IconVue.vue +6 -0
  83. package/theme/components/icons/IconVueTelescope.vue +11 -0
  84. package/theme/components/icons/IconWindi.vue +17 -0
  85. package/theme/components/icons/IconX.vue +12 -0
  86. package/theme/components/icons/IconXCircle.vue +10 -0
  87. package/theme/components/icons/IconZap.vue +8 -0
  88. package/theme/components/prose/ProseA.vue +66 -0
  89. package/theme/components/prose/ProseBlockquote.vue +21 -0
  90. package/theme/components/prose/ProseCode.vue +67 -0
  91. package/theme/components/prose/ProseCodeInline.vue +38 -0
  92. package/theme/components/prose/ProseEm.vue +11 -0
  93. package/theme/components/prose/ProseH1.vue +22 -0
  94. package/theme/components/prose/ProseH2.vue +22 -0
  95. package/theme/components/prose/ProseH3.vue +24 -0
  96. package/theme/components/prose/ProseH4.vue +24 -0
  97. package/theme/components/prose/ProseHr.vue +13 -0
  98. package/theme/components/prose/ProseImg.vue +30 -0
  99. package/theme/components/prose/ProseLi.vue +31 -0
  100. package/theme/components/prose/ProseOl.vue +16 -0
  101. package/theme/components/prose/ProseP.vue +14 -0
  102. package/theme/components/prose/ProseStrong.vue +14 -0
  103. package/theme/components/prose/ProseTable.vue +13 -0
  104. package/{dist/runtime/app → theme}/components/prose/ProseTbody.vue +0 -0
  105. package/theme/components/prose/ProseTd.vue +11 -0
  106. package/theme/components/prose/ProseTh.vue +11 -0
  107. package/theme/components/prose/ProseThead.vue +11 -0
  108. package/theme/components/prose/ProseTr.vue +11 -0
  109. package/theme/components/prose/ProseUl.vue +15 -0
  110. package/theme/composables/useDocus.ts +43 -0
  111. package/theme/composables/useMenu.ts +7 -0
  112. package/theme/composables/useScrollToHeading.ts +35 -0
  113. package/theme/composables/useScrollspy.ts +46 -0
  114. package/theme/composables/useUserAgent.ts +7 -0
  115. package/theme/composables/utils.ts +4 -0
  116. package/theme/layouts/default.vue +29 -0
  117. package/theme/layouts/page.vue +19 -0
  118. package/theme/middleware/components.ts +26 -0
  119. package/theme/middleware/navigation.global.ts +12 -0
  120. package/theme/middleware/page.ts +8 -0
  121. package/theme/middleware/theme.global.ts +12 -0
  122. package/theme/nuxt.config.ts +171 -0
  123. package/theme/pages/[...slug].vue +64 -0
  124. package/theme/plugins/menu.ts +67 -0
  125. package/theme/plugins/user-agent.ts +27 -0
  126. package/theme/utils/components.ts +25 -0
  127. package/theme/utils/navigation.ts +49 -0
  128. package/theme/utils/plugin.ts +21 -0
  129. package/theme/utils/queries.ts +68 -0
  130. package/theme/utils/state.ts +33 -0
  131. package/theme/utils/theme.ts +66 -0
  132. package/LICENSE +0 -21
  133. package/dist/index.cjs +0 -549
  134. package/dist/index.d.ts +0 -25
  135. package/dist/index.mjs +0 -523
  136. package/dist/runtime/app/components/DocusContent.vue +0 -215
  137. package/dist/runtime/app/components/DocusContent.vue.d.ts +0 -25
  138. package/dist/runtime/app/components/Error.vue +0 -19
  139. package/dist/runtime/app/components/Error.vue.d.ts +0 -9
  140. package/dist/runtime/app/components/Markdown.vue +0 -56
  141. package/dist/runtime/app/components/Markdown.vue.d.ts +0 -25
  142. package/dist/runtime/app/components/Page.vue +0 -29
  143. package/dist/runtime/app/components/Page.vue.d.ts +0 -2
  144. package/dist/runtime/app/components/Props.vue +0 -130
  145. package/dist/runtime/app/components/Props.vue.d.ts +0 -80
  146. package/dist/runtime/app/components/prose/ProseA.vue +0 -41
  147. package/dist/runtime/app/components/prose/ProseA.vue.d.ts +0 -23
  148. package/dist/runtime/app/components/prose/ProseBlockquote.vue +0 -5
  149. package/dist/runtime/app/components/prose/ProseCode.vue +0 -5
  150. package/dist/runtime/app/components/prose/ProseCodeInline.vue +0 -5
  151. package/dist/runtime/app/components/prose/ProseEm.vue +0 -5
  152. package/dist/runtime/app/components/prose/ProseH1.vue +0 -3
  153. package/dist/runtime/app/components/prose/ProseH2.vue +0 -3
  154. package/dist/runtime/app/components/prose/ProseH3.vue +0 -3
  155. package/dist/runtime/app/components/prose/ProseH4.vue +0 -3
  156. package/dist/runtime/app/components/prose/ProseH5.vue +0 -3
  157. package/dist/runtime/app/components/prose/ProseH6.vue +0 -3
  158. package/dist/runtime/app/components/prose/ProseImg.vue +0 -32
  159. package/dist/runtime/app/components/prose/ProseImg.vue.d.ts +0 -21
  160. package/dist/runtime/app/components/prose/ProseLi.vue +0 -3
  161. package/dist/runtime/app/components/prose/ProseParagraph.vue +0 -3
  162. package/dist/runtime/app/components/prose/ProseStrong.vue +0 -5
  163. package/dist/runtime/app/components/prose/ProseTable.vue +0 -5
  164. package/dist/runtime/app/components/prose/ProseTd.vue +0 -5
  165. package/dist/runtime/app/components/prose/ProseTh.vue +0 -5
  166. package/dist/runtime/app/components/prose/ProseThead.vue +0 -5
  167. package/dist/runtime/app/components/prose/ProseTr.vue +0 -5
  168. package/dist/runtime/app/components/prose/ProseUl.vue +0 -5
  169. package/dist/runtime/app/composables/helpers.d.ts +0 -4
  170. package/dist/runtime/app/composables/helpers.js +0 -66
  171. package/dist/runtime/app/composables/helpers.mjs +0 -40
  172. package/dist/runtime/app/composables/index.d.ts +0 -90
  173. package/dist/runtime/app/composables/index.js +0 -108
  174. package/dist/runtime/app/composables/index.mjs +0 -63
  175. package/dist/runtime/app/composables/navigation.d.ts +0 -37
  176. package/dist/runtime/app/composables/navigation.js +0 -227
  177. package/dist/runtime/app/composables/navigation.mjs +0 -148
  178. package/dist/runtime/app/composables/store.d.ts +0 -7
  179. package/dist/runtime/app/composables/store.js +0 -52
  180. package/dist/runtime/app/composables/store.mjs +0 -35
  181. package/dist/runtime/app/composables/style.d.ts +0 -11
  182. package/dist/runtime/app/composables/style.js +0 -117
  183. package/dist/runtime/app/composables/style.mjs +0 -71
  184. package/dist/runtime/app/composables/theme-colors.d.ts +0 -30
  185. package/dist/runtime/app/composables/theme-colors.js +0 -80
  186. package/dist/runtime/app/composables/theme-colors.mjs +0 -48
  187. package/dist/runtime/app/composables/websocket.d.ts +0 -3
  188. package/dist/runtime/app/composables/websocket.js +0 -79
  189. package/dist/runtime/app/composables/websocket.mjs +0 -63
  190. package/dist/runtime/app/layouts/default.vue +0 -5
  191. package/dist/runtime/app/layouts/error.vue +0 -33
  192. package/dist/runtime/app/layouts/error.vue.d.ts +0 -21
  193. package/dist/runtime/app/pages/_.vue +0 -222
  194. package/dist/runtime/app/pages/_.vue.d.ts +0 -2
  195. package/dist/runtime/context.d.ts +0 -1
  196. package/dist/runtime/context.js +0 -17
  197. package/dist/runtime/context.mjs +0 -5
  198. package/dist/runtime/database/Query.d.ts +0 -18
  199. package/dist/runtime/database/Query.js +0 -68
  200. package/dist/runtime/database/Query.mjs +0 -49
  201. package/dist/runtime/database/index.d.ts +0 -4
  202. package/dist/runtime/database/index.js +0 -45
  203. package/dist/runtime/database/index.mjs +0 -25
  204. package/dist/runtime/database/providers/local/Query.d.ts +0 -14
  205. package/dist/runtime/database/providers/local/Query.js +0 -85
  206. package/dist/runtime/database/providers/local/Query.mjs +0 -60
  207. package/dist/runtime/database/providers/local/index.d.ts +0 -3
  208. package/dist/runtime/database/providers/local/index.js +0 -63
  209. package/dist/runtime/database/providers/local/index.mjs +0 -39
  210. package/dist/runtime/database/providers/local/operations.d.ts +0 -2
  211. package/dist/runtime/database/providers/local/operations.js +0 -83
  212. package/dist/runtime/database/providers/local/operations.mjs +0 -53
  213. package/dist/runtime/database/providers/local/utils.d.ts +0 -8
  214. package/dist/runtime/database/providers/local/utils.js +0 -28
  215. package/dist/runtime/database/providers/local/utils.mjs +0 -17
  216. package/dist/runtime/index.d.ts +0 -3
  217. package/dist/runtime/index.js +0 -44
  218. package/dist/runtime/index.mjs +0 -3
  219. package/dist/runtime/navigation.d.ts +0 -4
  220. package/dist/runtime/navigation.js +0 -176
  221. package/dist/runtime/navigation.mjs +0 -137
  222. package/dist/runtime/server/api/get.d.ts +0 -10
  223. package/dist/runtime/server/api/get.js +0 -24
  224. package/dist/runtime/server/api/get.mjs +0 -13
  225. package/dist/runtime/server/api/list.d.ts +0 -9
  226. package/dist/runtime/server/api/list.js +0 -34
  227. package/dist/runtime/server/api/list.mjs +0 -18
  228. package/dist/runtime/server/api/navigation.d.ts +0 -7
  229. package/dist/runtime/server/api/navigation.js +0 -20
  230. package/dist/runtime/server/api/navigation.mjs +0 -10
  231. package/dist/runtime/server/api/preview.d.ts +0 -3
  232. package/dist/runtime/server/api/preview.js +0 -54
  233. package/dist/runtime/server/api/preview.mjs +0 -31
  234. package/dist/runtime/server/api/reload.d.ts +0 -6
  235. package/dist/runtime/server/api/reload.js +0 -27
  236. package/dist/runtime/server/api/reload.mjs +0 -11
  237. package/dist/runtime/server/api/search.d.ts +0 -6
  238. package/dist/runtime/server/api/search.js +0 -27
  239. package/dist/runtime/server/api/search.mjs +0 -13
  240. package/dist/runtime/server/content.d.ts +0 -46
  241. package/dist/runtime/server/content.js +0 -175
  242. package/dist/runtime/server/content.mjs +0 -114
  243. package/dist/runtime/server/socket.d.ts +0 -9
  244. package/dist/runtime/server/socket.js +0 -33
  245. package/dist/runtime/server/socket.mjs +0 -20
  246. package/dist/runtime/server/utils/cache.d.ts +0 -19
  247. package/dist/runtime/server/utils/cache.js +0 -110
  248. package/dist/runtime/server/utils/cache.mjs +0 -75
  249. package/dist/runtime/server/utils/index.d.ts +0 -4
  250. package/dist/runtime/server/utils/index.js +0 -18
  251. package/dist/runtime/server/utils/index.mjs +0 -8
  252. package/dist/runtime/transformers/index.d.ts +0 -1
  253. package/dist/runtime/transformers/index.js +0 -26
  254. package/dist/runtime/transformers/index.mjs +0 -11
  255. package/dist/runtime/transformers/json.d.ts +0 -3
  256. package/dist/runtime/transformers/json.js +0 -15
  257. package/dist/runtime/transformers/json.mjs +0 -5
  258. package/dist/runtime/transformers/markdown/index.d.ts +0 -8
  259. package/dist/runtime/transformers/markdown/index.js +0 -25
  260. package/dist/runtime/transformers/markdown/index.mjs +0 -16
  261. package/dist/runtime/transformers/utils/index.d.ts +0 -1
  262. package/dist/runtime/transformers/utils/index.js +0 -18
  263. package/dist/runtime/transformers/utils/index.mjs +0 -1
  264. package/dist/runtime/transformers/utils/path.d.ts +0 -26
  265. package/dist/runtime/transformers/utils/path.js +0 -88
  266. package/dist/runtime/transformers/utils/path.mjs +0 -56
  267. package/dist/runtime/utils/index.d.ts +0 -1
  268. package/dist/runtime/utils/index.js +0 -18
  269. package/dist/runtime/utils/index.mjs +0 -1
  270. package/dist/runtime/utils/log.d.ts +0 -1
  271. package/dist/runtime/utils/log.js +0 -14
  272. package/dist/runtime/utils/log.mjs +0 -2
  273. package/dist/runtime/utils/object.d.ts +0 -9
  274. package/dist/runtime/utils/object.js +0 -22
  275. package/dist/runtime/utils/object.mjs +0 -4
  276. package/dist/templates/content.mjs +0 -50
  277. package/dist/templates/docus.mjs +0 -13
  278. package/dist/templates/hot.mjs +0 -16
  279. package/dist/templates/i18n.mjs +0 -23
  280. package/dist/templates/options.mjs +0 -46
  281. package/shims.d.ts +0 -24
  282. package/types.d.ts +0 -397
@@ -1,227 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDocusNavigationState = exports.useDocusNavigation = exports.useDocusCurrentPath = exports.useDocusCurrentNav = exports.createDocusNavigation = void 0;
7
-
8
- var _ufo = require("ufo");
9
-
10
- var _vue = _interopRequireDefault(require("vue"));
11
-
12
- var _scule = require("scule");
13
-
14
- var _ = require(".");
15
-
16
- var _app = require("#app");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- let _get;
21
-
22
- let _fetchNavigation;
23
-
24
- let _filterLinks;
25
-
26
- let _isLinkActive;
27
-
28
- let _getPageTemplate;
29
-
30
- let _getPreviousAndNextLink;
31
-
32
- let _updateCurrentNav;
33
-
34
- let _refresh;
35
-
36
- const createDocusNavigation = (context, config, content) => {
37
- const _contentLocalePath = context.$contentLocalePath;
38
- const {
39
- route
40
- } = context;
41
-
42
- const _route = (0, _app.unref)(route);
43
-
44
- const docusNavigation = (0, _app.useState)(_.StateTypes.Navigation, () => ({}));
45
- const docusCurrentPath = (0, _app.useState)(_.StateTypes.CurrentPath, () => `/${_route.params.pathMatch}`);
46
-
47
- _fetchNavigation = async locale => {
48
- const __locale = locale || context.i18n.locale;
49
-
50
- const data = await content.fetch("navigation/" + __locale);
51
- docusNavigation.value[__locale] = data;
52
- };
53
-
54
- _get = ({
55
- depth,
56
- locale = context.i18n.locale,
57
- from,
58
- all
59
- } = {}) => {
60
- const nav = docusNavigation.value[locale] || [];
61
- let items = nav;
62
- let match;
63
- let exclusiveContent;
64
- let parent;
65
-
66
- if (from) {
67
- let lastMatch;
68
- const paths = from.split("/");
69
- items = paths.reduce((links, path, index) => {
70
- if (!path) return links;
71
-
72
- if (match && match.page) {
73
- lastMatch = match;
74
- }
75
-
76
- match = links.find(item => item.to.split("/")[index] === path);
77
-
78
- if (match) {
79
- if (match && match.exclusive) {
80
- parent = lastMatch || parent;
81
- exclusiveContent = match;
82
- }
83
-
84
- return match.children;
85
- }
86
-
87
- return links;
88
- }, items);
89
-
90
- if (exclusiveContent) {
91
- items = exclusiveContent.children;
92
- } else {
93
- items = nav;
94
- }
95
- }
96
-
97
- return {
98
- title: exclusiveContent && exclusiveContent.title,
99
- to: exclusiveContent && exclusiveContent.to,
100
- parent,
101
- links: all ? items : _filterLinks(items, depth || 1, 1)
102
- };
103
- };
104
-
105
- _filterLinks = (nodes, maxDepth, currentDepth) => {
106
- return nodes.filter(node => {
107
- if (node.hidden) return false;
108
- if (node.draft === true) return false;
109
- if (currentDepth && maxDepth > currentDepth) return false;
110
- if (node.nested === false) node.children = [];
111
- node.children = node.children && node.children.length > 0 ? _filterLinks(node.children, maxDepth, currentDepth + 1) : [];
112
- return node;
113
- });
114
- };
115
-
116
- _isLinkActive = to => {
117
- return (0, _ufo.withTrailingSlash)(docusCurrentPath.value) === (0, _ufo.withTrailingSlash)(_contentLocalePath(to));
118
- };
119
-
120
- _getPageTemplate = page => {
121
- let template = typeof page.template === "string" ? page.template : page.template?.self;
122
-
123
- if (!template) {
124
- const slugs = page.to.split("/").filter(Boolean).slice(0, -1);
125
- let {
126
- links
127
- } = docusCurrentNav.value || {};
128
- slugs.forEach((_slug, index) => {
129
- const to = "/" + slugs.slice(0, index + 1).join("/");
130
- const link = links.find(link2 => link2.to === to);
131
-
132
- if (link?.template) {
133
- template = link.template || template;
134
- }
135
-
136
- if (!link?.children) return;
137
- links = link.children;
138
- });
139
- }
140
-
141
- if (!template) template = config.value?.template || "Page";
142
- template = (0, _scule.pascalCase)(template);
143
-
144
- if (!_vue.default.component(template)) {
145
- console.error(`Template ${template} does not exists, fallback to Page template.`);
146
- template = "Page";
147
- }
148
-
149
- return template;
150
- };
151
-
152
- _getPreviousAndNextLink = page => {
153
- return content.search({
154
- deep: true
155
- }).where({
156
- language: context.i18n.locale,
157
- parent: page.parent,
158
- page: {
159
- $ne: false
160
- },
161
- hidden: {
162
- $ne: true
163
- },
164
- redirect: {
165
- $type: "undefined"
166
- }
167
- }).only(["title", "slug", "to"]).sortBy("position", "asc").surround(page.to, {
168
- before: 1,
169
- after: 1
170
- }).fetch();
171
- };
172
-
173
- _updateCurrentNav = () => {
174
- docusCurrentNav.value = _get({
175
- from: docusCurrentPath.value
176
- });
177
- };
178
-
179
- _refresh = async locale => {
180
- await _fetchNavigation(locale);
181
-
182
- _updateCurrentNav();
183
- };
184
-
185
- const docusCurrentNav = (0, _app.useState)(_.StateTypes.CurrentNav, () => {
186
- return _get({
187
- from: `/${_route.params.pathMatch}`
188
- });
189
- });
190
-
191
- if (process.client) {
192
- window.onNuxtReady(() => {
193
- window.$nuxt.$on("docus:content:preview", () => _refresh(context.i18n.locale));
194
- window.$nuxt.$on("content:update", () => _refresh(context.i18n.locale));
195
- });
196
- }
197
- };
198
-
199
- exports.createDocusNavigation = createDocusNavigation;
200
-
201
- const useDocusNavigation = () => {
202
- return {
203
- state: useDocusNavigationState(),
204
- currentNav: useDocusCurrentNav(),
205
- currentPath: useDocusCurrentPath(),
206
- getPageTemplate: _getPageTemplate,
207
- fetchNavigation: _fetchNavigation,
208
- isLinkActive: _isLinkActive,
209
- updateCurrentNav: _updateCurrentNav,
210
- getPreviousAndNextLink: _getPreviousAndNextLink,
211
- get: _get
212
- };
213
- };
214
-
215
- exports.useDocusNavigation = useDocusNavigation;
216
-
217
- const useDocusNavigationState = () => (0, _app.useState)(_.StateTypes.Navigation);
218
-
219
- exports.useDocusNavigationState = useDocusNavigationState;
220
-
221
- const useDocusCurrentNav = () => (0, _app.useState)(_.StateTypes.CurrentNav);
222
-
223
- exports.useDocusCurrentNav = useDocusCurrentNav;
224
-
225
- const useDocusCurrentPath = () => (0, _app.useState)(_.StateTypes.CurrentPath);
226
-
227
- exports.useDocusCurrentPath = useDocusCurrentPath;
@@ -1,148 +0,0 @@
1
- import { withTrailingSlash } from "ufo";
2
- import Vue from "vue";
3
- import { pascalCase } from "scule";
4
- import { StateTypes } from "./index.mjs";
5
- import { unref, useState } from "#app";
6
- let _get;
7
- let _fetchNavigation;
8
- let _filterLinks;
9
- let _isLinkActive;
10
- let _getPageTemplate;
11
- let _getPreviousAndNextLink;
12
- let _updateCurrentNav;
13
- let _refresh;
14
- export const createDocusNavigation = (context, config, content) => {
15
- const _contentLocalePath = context.$contentLocalePath;
16
- const { route } = context;
17
- const _route = unref(route);
18
- const docusNavigation = useState(StateTypes.Navigation, () => ({}));
19
- const docusCurrentPath = useState(StateTypes.CurrentPath, () => `/${_route.params.pathMatch}`);
20
- _fetchNavigation = async (locale) => {
21
- const __locale = locale || context.i18n.locale;
22
- const data = await content.fetch("navigation/" + __locale);
23
- docusNavigation.value[__locale] = data;
24
- };
25
- _get = ({ depth, locale = context.i18n.locale, from, all } = {}) => {
26
- const nav = docusNavigation.value[locale] || [];
27
- let items = nav;
28
- let match;
29
- let exclusiveContent;
30
- let parent;
31
- if (from) {
32
- let lastMatch;
33
- const paths = from.split("/");
34
- items = paths.reduce((links, path, index) => {
35
- if (!path)
36
- return links;
37
- if (match && match.page) {
38
- lastMatch = match;
39
- }
40
- match = links.find((item) => item.to.split("/")[index] === path);
41
- if (match) {
42
- if (match && match.exclusive) {
43
- parent = lastMatch || parent;
44
- exclusiveContent = match;
45
- }
46
- return match.children;
47
- }
48
- return links;
49
- }, items);
50
- if (exclusiveContent) {
51
- items = exclusiveContent.children;
52
- } else {
53
- items = nav;
54
- }
55
- }
56
- return {
57
- title: exclusiveContent && exclusiveContent.title,
58
- to: exclusiveContent && exclusiveContent.to,
59
- parent,
60
- links: all ? items : _filterLinks(items, depth || 1, 1)
61
- };
62
- };
63
- _filterLinks = (nodes, maxDepth, currentDepth) => {
64
- return nodes.filter((node) => {
65
- if (node.hidden)
66
- return false;
67
- if (node.draft === true)
68
- return false;
69
- if (currentDepth && maxDepth > currentDepth)
70
- return false;
71
- if (node.nested === false)
72
- node.children = [];
73
- node.children = node.children && node.children.length > 0 ? _filterLinks(node.children, maxDepth, currentDepth + 1) : [];
74
- return node;
75
- });
76
- };
77
- _isLinkActive = (to) => {
78
- return withTrailingSlash(docusCurrentPath.value) === withTrailingSlash(_contentLocalePath(to));
79
- };
80
- _getPageTemplate = (page) => {
81
- let template = typeof page.template === "string" ? page.template : page.template?.self;
82
- if (!template) {
83
- const slugs = page.to.split("/").filter(Boolean).slice(0, -1);
84
- let { links } = docusCurrentNav.value || {};
85
- slugs.forEach((_slug, index) => {
86
- const to = "/" + slugs.slice(0, index + 1).join("/");
87
- const link = links.find((link2) => link2.to === to);
88
- if (link?.template) {
89
- template = link.template || template;
90
- }
91
- if (!link?.children)
92
- return;
93
- links = link.children;
94
- });
95
- }
96
- if (!template)
97
- template = config.value?.template || "Page";
98
- template = pascalCase(template);
99
- if (!Vue.component(template)) {
100
- console.error(`Template ${template} does not exists, fallback to Page template.`);
101
- template = "Page";
102
- }
103
- return template;
104
- };
105
- _getPreviousAndNextLink = (page) => {
106
- return content.search({ deep: true }).where({
107
- language: context.i18n.locale,
108
- parent: page.parent,
109
- page: { $ne: false },
110
- hidden: { $ne: true },
111
- redirect: { $type: "undefined" }
112
- }).only(["title", "slug", "to"]).sortBy("position", "asc").surround(page.to, { before: 1, after: 1 }).fetch();
113
- };
114
- _updateCurrentNav = () => {
115
- docusCurrentNav.value = _get({
116
- from: docusCurrentPath.value
117
- });
118
- };
119
- _refresh = async (locale) => {
120
- await _fetchNavigation(locale);
121
- _updateCurrentNav();
122
- };
123
- const docusCurrentNav = useState(StateTypes.CurrentNav, () => {
124
- return _get({ from: `/${_route.params.pathMatch}` });
125
- });
126
- if (process.client) {
127
- window.onNuxtReady(() => {
128
- window.$nuxt.$on("docus:content:preview", () => _refresh(context.i18n.locale));
129
- window.$nuxt.$on("content:update", () => _refresh(context.i18n.locale));
130
- });
131
- }
132
- };
133
- export const useDocusNavigation = () => {
134
- return {
135
- state: useDocusNavigationState(),
136
- currentNav: useDocusCurrentNav(),
137
- currentPath: useDocusCurrentPath(),
138
- getPageTemplate: _getPageTemplate,
139
- fetchNavigation: _fetchNavigation,
140
- isLinkActive: _isLinkActive,
141
- updateCurrentNav: _updateCurrentNav,
142
- getPreviousAndNextLink: _getPreviousAndNextLink,
143
- get: _get
144
- };
145
- };
146
- export const useDocusNavigationState = () => useState(StateTypes.Navigation);
147
- export const useDocusCurrentNav = () => useState(StateTypes.CurrentNav);
148
- export const useDocusCurrentPath = () => useState(StateTypes.CurrentPath);
@@ -1,7 +0,0 @@
1
- import Vue from 'vue';
2
- import type { CombinedVueInstance } from 'vue/types/vue';
3
- import { Context } from '@nuxt/types';
4
- export declare function createStore<T>(key: string, defaultValue: T): {
5
- plugin: ({ ssrContext, nuxtState }: Context) => void;
6
- useStore: (context?: CombinedVueInstance<Vue, object, object, object, Record<never, any>> | Context) => Ref<T>;
7
- };
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createStore = createStore;
7
-
8
- var _app = require("#app");
9
-
10
- const createPlugin = (key, defaultValue) => {
11
- const store = (0, _app.ref)(defaultValue || {});
12
- return ({
13
- ssrContext,
14
- nuxtState
15
- }) => {
16
- const state = process.server ? ssrContext.nuxt : nuxtState;
17
- state.stores = state.stores || {};
18
-
19
- if (process.server) {
20
- state.stores[key] = store;
21
- } else {
22
- Object.assign(store, state.stores?.[key] || {});
23
- }
24
- };
25
- };
26
-
27
- function createStore(key, defaultValue) {
28
- const plugin = createPlugin(key, defaultValue);
29
-
30
- function useStore(context) {
31
- if (!context) {
32
- const vm = (0, _app.getCurrentInstance)();
33
- if (!vm) throw new Error("useStore must be called in setup() or a context provided");
34
- context = vm.proxy;
35
- }
36
-
37
- let state;
38
-
39
- if (process.server) {
40
- state = "$ssrContext" in context ? context.$ssrContext.nuxt : context.ssrContext?.nuxt;
41
- } else {
42
- state = window.__NUXT__;
43
- }
44
-
45
- return state.stores[key];
46
- }
47
-
48
- return {
49
- plugin,
50
- useStore
51
- };
52
- }
@@ -1,35 +0,0 @@
1
- import { getCurrentInstance, ref } from "#app";
2
- const createPlugin = (key, defaultValue) => {
3
- const store = ref(defaultValue || {});
4
- return ({ ssrContext, nuxtState }) => {
5
- const state = process.server ? ssrContext.nuxt : nuxtState;
6
- state.stores = state.stores || {};
7
- if (process.server) {
8
- state.stores[key] = store;
9
- } else {
10
- Object.assign(store, state.stores?.[key] || {});
11
- }
12
- };
13
- };
14
- export function createStore(key, defaultValue) {
15
- const plugin = createPlugin(key, defaultValue);
16
- function useStore(context) {
17
- if (!context) {
18
- const vm = getCurrentInstance();
19
- if (!vm)
20
- throw new Error("useStore must be called in setup() or a context provided");
21
- context = vm.proxy;
22
- }
23
- let state;
24
- if (process.server) {
25
- state = "$ssrContext" in context ? context.$ssrContext.nuxt : context.ssrContext?.nuxt;
26
- } else {
27
- state = window.__NUXT__;
28
- }
29
- return state.stores[key];
30
- }
31
- return {
32
- plugin,
33
- useStore
34
- };
35
- }
@@ -1,11 +0,0 @@
1
- import type { Context } from '@nuxt/types';
2
- declare function updateHead(): void;
3
- export declare const createDocusStyles: (context: Context) => void;
4
- /**
5
- * Access the styling state and helpers.
6
- */
7
- export declare const useDocusStyles: () => {
8
- styles: any;
9
- updateHead: typeof updateHead;
10
- };
11
- export {};
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDocusStyles = exports.createDocusStyles = void 0;
7
-
8
- var _themeColors = require("./theme-colors");
9
-
10
- var _ = require("./");
11
-
12
- var _app = require("#app");
13
-
14
- let _head;
15
-
16
- function useColors(colors) {
17
- try {
18
- return Object.entries(colors).map(([key, color]) => [key, typeof color === "string" ? (0, _themeColors.getColors)(color) : color]);
19
- } catch (e) {
20
- console.warn("Could not parse custom colors:", e && e.message ? e.message : e);
21
- return [];
22
- }
23
- }
24
-
25
- function useCssVariableStore(scopes = ["dark"]) {
26
- scopes = ["default", ...scopes];
27
-
28
- const _store = scopes.reduce((obj, scope) => ({
29
- [scope]: {},
30
- ...obj
31
- }), {});
32
-
33
- const getScope = scope => _store[scope] || null;
34
-
35
- const putSingle = key => value => {
36
- const _arr = value.split(":");
37
-
38
- const _value = _arr.pop();
39
-
40
- const _scope = getScope(_arr.pop() || "default");
41
-
42
- if (_scope) {
43
- _scope[key] = _value;
44
- }
45
- };
46
-
47
- const put = (key, value) => {
48
- value.split(" ").map(putSingle(key));
49
- };
50
-
51
- const generateVar = ([key, value]) => `--${key}: ${value}`;
52
-
53
- const generateScope = scope => {
54
- const vars = Object.entries(getScope(scope)).map(generateVar).join(";");
55
- return scope === "default" ? `html:root {${vars}}` : `html.${scope} {${vars}}`;
56
- };
57
-
58
- const generate = () => scopes.map(generateScope).join(" ");
59
-
60
- return {
61
- put,
62
- generate
63
- };
64
- }
65
-
66
- function useCSSVariables(colors) {
67
- const {
68
- put,
69
- generate
70
- } = useCssVariableStore(["dark"]);
71
- const colorsList = useColors(colors);
72
- colorsList.forEach(([color, map]) => Object.entries(map).forEach(([variant, value]) => put(`${color}-${variant}`, value)));
73
- return generate();
74
- }
75
-
76
- function updateHead() {
77
- const head = typeof _head === "function" ? _head() : _head;
78
-
79
- if (!Array.isArray(head.style)) {
80
- head.style = [];
81
- }
82
-
83
- if (!Array.isArray(head.meta)) {
84
- head.meta = [];
85
- }
86
-
87
- head.style.push({
88
- hid: "docus-theme",
89
- cssText: styles.value,
90
- type: "text/css"
91
- });
92
- head.meta = head.meta.filter(s => s.hid !== "theme-color");
93
- }
94
-
95
- const styles = (0, _app.computed)(() => {
96
- const theme = (0, _.useDocusTheme)();
97
- return useCSSVariables(theme.value?.colors ? theme.value.colors : {});
98
- });
99
-
100
- const createDocusStyles = context => {
101
- const {
102
- app
103
- } = context;
104
- _head = app.head;
105
- updateHead();
106
- };
107
-
108
- exports.createDocusStyles = createDocusStyles;
109
-
110
- const useDocusStyles = () => {
111
- return {
112
- styles,
113
- updateHead
114
- };
115
- };
116
-
117
- exports.useDocusStyles = useDocusStyles;
@@ -1,71 +0,0 @@
1
- import { getColors } from "./theme-colors.mjs";
2
- import { useDocusTheme } from ".//index.mjs";
3
- import { computed } from "#app";
4
- let _head;
5
- function useColors(colors) {
6
- try {
7
- return Object.entries(colors).map(([key, color]) => [key, typeof color === "string" ? getColors(color) : color]);
8
- } catch (e) {
9
- console.warn("Could not parse custom colors:", e && e.message ? e.message : e);
10
- return [];
11
- }
12
- }
13
- function useCssVariableStore(scopes = ["dark"]) {
14
- scopes = ["default", ...scopes];
15
- const _store = scopes.reduce((obj, scope) => ({ [scope]: {}, ...obj }), {});
16
- const getScope = (scope) => _store[scope] || null;
17
- const putSingle = (key) => (value) => {
18
- const _arr = value.split(":");
19
- const _value = _arr.pop();
20
- const _scope = getScope(_arr.pop() || "default");
21
- if (_scope) {
22
- _scope[key] = _value;
23
- }
24
- };
25
- const put = (key, value) => {
26
- value.split(" ").map(putSingle(key));
27
- };
28
- const generateVar = ([key, value]) => `--${key}: ${value}`;
29
- const generateScope = (scope) => {
30
- const vars = Object.entries(getScope(scope)).map(generateVar).join(";");
31
- return scope === "default" ? `html:root {${vars}}` : `html.${scope} {${vars}}`;
32
- };
33
- const generate = () => scopes.map(generateScope).join(" ");
34
- return { put, generate };
35
- }
36
- function useCSSVariables(colors) {
37
- const { put, generate } = useCssVariableStore(["dark"]);
38
- const colorsList = useColors(colors);
39
- colorsList.forEach(([color, map]) => Object.entries(map).forEach(([variant, value]) => put(`${color}-${variant}`, value)));
40
- return generate();
41
- }
42
- function updateHead() {
43
- const head = typeof _head === "function" ? _head() : _head;
44
- if (!Array.isArray(head.style)) {
45
- head.style = [];
46
- }
47
- if (!Array.isArray(head.meta)) {
48
- head.meta = [];
49
- }
50
- head.style.push({
51
- hid: "docus-theme",
52
- cssText: styles.value,
53
- type: "text/css"
54
- });
55
- head.meta = head.meta.filter((s) => s.hid !== "theme-color");
56
- }
57
- const styles = computed(() => {
58
- const theme = useDocusTheme();
59
- return useCSSVariables(theme.value?.colors ? theme.value.colors : {});
60
- });
61
- export const createDocusStyles = (context) => {
62
- const { app } = context;
63
- _head = app.head;
64
- updateHead();
65
- };
66
- export const useDocusStyles = () => {
67
- return {
68
- styles,
69
- updateHead
70
- };
71
- };
@@ -1,30 +0,0 @@
1
- export declare function parseColor(color?: string): number[];
2
- export declare function hexValue(components: any): string;
3
- export declare function tint(components: any, intensity: any): any;
4
- export declare function shade(components: any, intensity: any): any;
5
- export declare const withTint: (intensity: any) => (hex: any) => any;
6
- export declare const withShade: (intensity: any) => (hex: any) => any;
7
- export declare const _variants: {
8
- 50: (hex: any) => any;
9
- 100: (hex: any) => any;
10
- 200: (hex: any) => any;
11
- 300: (hex: any) => any;
12
- 400: (hex: any) => any;
13
- 500: (c: any) => any;
14
- 600: (hex: any) => any;
15
- 700: (hex: any) => any;
16
- 800: (hex: any) => any;
17
- 900: (hex: any) => any;
18
- };
19
- export declare function getColors(color: any, variants?: {
20
- 50: (hex: any) => any;
21
- 100: (hex: any) => any;
22
- 200: (hex: any) => any;
23
- 300: (hex: any) => any;
24
- 400: (hex: any) => any;
25
- 500: (c: any) => any;
26
- 600: (hex: any) => any;
27
- 700: (hex: any) => any;
28
- 800: (hex: any) => any;
29
- 900: (hex: any) => any;
30
- }): {};