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.
- package/README.md +6 -4
- package/app/router.options.ts +18 -0
- package/assets/css/fonts.css +84 -0
- package/assets/css/main.css +11 -0
- package/assets/css/tailwind.css +282 -0
- package/components/app/Container.vue +25 -0
- package/components/app/Footer.vue +40 -0
- package/components/app/Navbar.vue +26 -0
- package/components/app/NavbarLogo.vue +33 -0
- package/components/app/Page.vue +7 -0
- package/components/app/PoweredByDocus.vue +11 -0
- package/components/content/Alert.vue +124 -0
- package/components/content/BlockHero.vue +54 -0
- package/components/content/ButtonLink.vue +45 -0
- package/components/content/Card.vue +46 -0
- package/components/content/CardGrid.vue +23 -0
- package/components/content/CodeBlock.vue +47 -0
- package/components/content/CodeGroup.vue +135 -0
- package/components/content/CopyButton.vue +49 -0
- package/{dist/runtime/app/components/prose/ProseOl.vue → components/content/List.vue} +2 -2
- package/components/content/NeedContribution.vue +23 -0
- package/components/content/ReadMore.vue +25 -0
- package/components/content/Sandbox.vue +102 -0
- package/components/content/TabsHeader.vue +44 -0
- package/components/content/Terminal.vue +64 -0
- package/components/content/VideoPlayer.vue +115 -0
- package/components/docs/DocsAside.vue +21 -0
- package/components/docs/DocsAsideTree.vue +102 -0
- package/components/docs/DocsHero.vue +39 -0
- package/components/docs/DocsPage.vue +22 -0
- package/components/docs/DocsPageContent.vue +31 -0
- package/components/docs/DocsToc.vue +74 -0
- package/components/globals/Icon.vue +24 -0
- package/{dist/runtime/app/components/prose/ProseHr.vue → components/globals/Logo.vue} +1 -1
- package/components/globals/NuxtImg.vue +45 -0
- package/components/globals/SocialIcons.vue +45 -0
- package/components/globals/ThemeSelect.vue +35 -0
- package/components/icons/IconAlgolia.vue +8 -0
- package/components/icons/IconArrowLeft.vue +10 -0
- package/components/icons/IconArrowRight.vue +10 -0
- package/components/icons/IconBadgeCheck.vue +14 -0
- package/components/icons/IconCheck.vue +10 -0
- package/components/icons/IconCheckCircle.vue +10 -0
- package/components/icons/IconChevronRight.vue +12 -0
- package/components/icons/IconClipboardCheck.vue +14 -0
- package/components/icons/IconClipboardCopy.vue +14 -0
- package/components/icons/IconCodeSandbox.vue +8 -0
- package/components/icons/IconCopy.vue +17 -0
- package/components/icons/IconDots.vue +10 -0
- package/components/icons/IconEdit.vue +18 -0
- package/components/icons/IconExclamationCircle.vue +12 -0
- package/components/icons/IconExclamationTriangle.vue +10 -0
- package/components/icons/IconExternalLink.vue +12 -0
- package/components/icons/IconGit.vue +7 -0
- package/components/icons/IconGitHub.vue +10 -0
- package/components/icons/IconHeart.vue +9 -0
- package/components/icons/IconInformationCircle.vue +10 -0
- package/components/icons/IconLighthouse.vue +83 -0
- package/components/icons/IconLine.vue +10 -0
- package/components/icons/IconMarkdown.vue +13 -0
- package/components/icons/IconMenu.vue +12 -0
- package/components/icons/IconMenuAlt.vue +10 -0
- package/components/icons/IconMinus.vue +10 -0
- package/components/icons/IconMoon.vue +10 -0
- package/components/icons/IconNuxt.vue +14 -0
- package/components/icons/IconNuxtContent.vue +20 -0
- package/components/icons/IconNuxtLabs.vue +21 -0
- package/components/icons/IconPlus.vue +10 -0
- package/components/icons/IconPuzzle.vue +8 -0
- package/components/icons/IconSSG.vue +7 -0
- package/components/icons/IconSearch.vue +12 -0
- package/components/icons/IconSun.vue +10 -0
- package/components/icons/IconTocBack.vue +21 -0
- package/components/icons/IconTocCurrent.vue +21 -0
- package/components/icons/IconTocNext.vue +8 -0
- package/components/icons/IconTranslate.vue +14 -0
- package/components/icons/IconTwitter.vue +8 -0
- package/components/icons/IconVite.vue +30 -0
- package/components/icons/IconVue.vue +6 -0
- package/components/icons/IconVueTelescope.vue +11 -0
- package/components/icons/IconWindi.vue +17 -0
- package/components/icons/IconX.vue +12 -0
- package/components/icons/IconXCircle.vue +10 -0
- package/components/icons/IconZap.vue +8 -0
- package/components/prose/ProseA.vue +66 -0
- package/components/prose/ProseBlockquote.vue +21 -0
- package/components/prose/ProseCode.vue +68 -0
- package/components/prose/ProseCodeInline.vue +38 -0
- package/components/prose/ProseEm.vue +11 -0
- package/components/prose/ProseH1.vue +22 -0
- package/components/prose/ProseH2.vue +22 -0
- package/components/prose/ProseH3.vue +24 -0
- package/components/prose/ProseH4.vue +24 -0
- package/components/prose/ProseHr.vue +13 -0
- package/components/prose/ProseImg.vue +30 -0
- package/components/prose/ProseLi.vue +31 -0
- package/components/prose/ProseOl.vue +16 -0
- package/components/prose/ProseP.vue +14 -0
- package/components/prose/ProseStrong.vue +14 -0
- package/components/prose/ProseTable.vue +13 -0
- package/{dist/runtime/app/components → components}/prose/ProseTbody.vue +0 -0
- package/components/prose/ProseTd.vue +11 -0
- package/components/prose/ProseTh.vue +11 -0
- package/components/prose/ProseThead.vue +11 -0
- package/components/prose/ProseTr.vue +11 -0
- package/components/prose/ProseUl.vue +15 -0
- package/composables/useContent.ts +156 -0
- package/composables/useMenu.ts +22 -0
- package/composables/useScrollToHeading.ts +35 -0
- package/composables/useScrollspy.ts +46 -0
- package/composables/useTheme.ts +12 -0
- package/layouts/default.vue +29 -0
- package/layouts/page.vue +11 -0
- package/nuxt.config.ts +151 -0
- package/package.json +46 -83
- package/pages/[...slug].vue +26 -0
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/site.webmanifest +1 -0
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -549
- package/dist/index.d.ts +0 -25
- package/dist/index.mjs +0 -523
- package/dist/runtime/app/components/DocusContent.vue +0 -215
- package/dist/runtime/app/components/DocusContent.vue.d.ts +0 -25
- package/dist/runtime/app/components/Error.vue +0 -19
- package/dist/runtime/app/components/Error.vue.d.ts +0 -9
- package/dist/runtime/app/components/Markdown.vue +0 -56
- package/dist/runtime/app/components/Markdown.vue.d.ts +0 -25
- package/dist/runtime/app/components/Page.vue +0 -29
- package/dist/runtime/app/components/Page.vue.d.ts +0 -2
- package/dist/runtime/app/components/Props.vue +0 -130
- package/dist/runtime/app/components/Props.vue.d.ts +0 -80
- package/dist/runtime/app/components/prose/ProseA.vue +0 -41
- package/dist/runtime/app/components/prose/ProseA.vue.d.ts +0 -23
- package/dist/runtime/app/components/prose/ProseBlockquote.vue +0 -5
- package/dist/runtime/app/components/prose/ProseCode.vue +0 -5
- package/dist/runtime/app/components/prose/ProseCodeInline.vue +0 -5
- package/dist/runtime/app/components/prose/ProseEm.vue +0 -5
- package/dist/runtime/app/components/prose/ProseH1.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH2.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH3.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH4.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH5.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH6.vue +0 -3
- package/dist/runtime/app/components/prose/ProseImg.vue +0 -32
- package/dist/runtime/app/components/prose/ProseImg.vue.d.ts +0 -21
- package/dist/runtime/app/components/prose/ProseLi.vue +0 -3
- package/dist/runtime/app/components/prose/ProseParagraph.vue +0 -3
- package/dist/runtime/app/components/prose/ProseStrong.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTable.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTd.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTh.vue +0 -5
- package/dist/runtime/app/components/prose/ProseThead.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTr.vue +0 -5
- package/dist/runtime/app/components/prose/ProseUl.vue +0 -5
- package/dist/runtime/app/composables/helpers.d.ts +0 -4
- package/dist/runtime/app/composables/helpers.js +0 -66
- package/dist/runtime/app/composables/helpers.mjs +0 -40
- package/dist/runtime/app/composables/index.d.ts +0 -90
- package/dist/runtime/app/composables/index.js +0 -108
- package/dist/runtime/app/composables/index.mjs +0 -63
- package/dist/runtime/app/composables/navigation.d.ts +0 -37
- package/dist/runtime/app/composables/navigation.js +0 -227
- package/dist/runtime/app/composables/navigation.mjs +0 -148
- package/dist/runtime/app/composables/store.d.ts +0 -7
- package/dist/runtime/app/composables/store.js +0 -52
- package/dist/runtime/app/composables/store.mjs +0 -35
- package/dist/runtime/app/composables/style.d.ts +0 -11
- package/dist/runtime/app/composables/style.js +0 -117
- package/dist/runtime/app/composables/style.mjs +0 -71
- package/dist/runtime/app/composables/theme-colors.d.ts +0 -30
- package/dist/runtime/app/composables/theme-colors.js +0 -80
- package/dist/runtime/app/composables/theme-colors.mjs +0 -48
- package/dist/runtime/app/composables/websocket.d.ts +0 -3
- package/dist/runtime/app/composables/websocket.js +0 -79
- package/dist/runtime/app/composables/websocket.mjs +0 -63
- package/dist/runtime/app/layouts/default.vue +0 -5
- package/dist/runtime/app/layouts/error.vue +0 -33
- package/dist/runtime/app/layouts/error.vue.d.ts +0 -21
- package/dist/runtime/app/pages/_.vue +0 -222
- package/dist/runtime/app/pages/_.vue.d.ts +0 -2
- package/dist/runtime/context.d.ts +0 -1
- package/dist/runtime/context.js +0 -17
- package/dist/runtime/context.mjs +0 -5
- package/dist/runtime/database/Query.d.ts +0 -18
- package/dist/runtime/database/Query.js +0 -68
- package/dist/runtime/database/Query.mjs +0 -49
- package/dist/runtime/database/index.d.ts +0 -4
- package/dist/runtime/database/index.js +0 -45
- package/dist/runtime/database/index.mjs +0 -25
- package/dist/runtime/database/providers/local/Query.d.ts +0 -14
- package/dist/runtime/database/providers/local/Query.js +0 -85
- package/dist/runtime/database/providers/local/Query.mjs +0 -60
- package/dist/runtime/database/providers/local/index.d.ts +0 -3
- package/dist/runtime/database/providers/local/index.js +0 -63
- package/dist/runtime/database/providers/local/index.mjs +0 -39
- package/dist/runtime/database/providers/local/operations.d.ts +0 -2
- package/dist/runtime/database/providers/local/operations.js +0 -83
- package/dist/runtime/database/providers/local/operations.mjs +0 -53
- package/dist/runtime/database/providers/local/utils.d.ts +0 -8
- package/dist/runtime/database/providers/local/utils.js +0 -28
- package/dist/runtime/database/providers/local/utils.mjs +0 -17
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.js +0 -44
- package/dist/runtime/index.mjs +0 -3
- package/dist/runtime/navigation.d.ts +0 -4
- package/dist/runtime/navigation.js +0 -176
- package/dist/runtime/navigation.mjs +0 -137
- package/dist/runtime/server/api/get.d.ts +0 -10
- package/dist/runtime/server/api/get.js +0 -24
- package/dist/runtime/server/api/get.mjs +0 -13
- package/dist/runtime/server/api/list.d.ts +0 -9
- package/dist/runtime/server/api/list.js +0 -34
- package/dist/runtime/server/api/list.mjs +0 -18
- package/dist/runtime/server/api/navigation.d.ts +0 -7
- package/dist/runtime/server/api/navigation.js +0 -20
- package/dist/runtime/server/api/navigation.mjs +0 -10
- package/dist/runtime/server/api/preview.d.ts +0 -3
- package/dist/runtime/server/api/preview.js +0 -54
- package/dist/runtime/server/api/preview.mjs +0 -31
- package/dist/runtime/server/api/reload.d.ts +0 -6
- package/dist/runtime/server/api/reload.js +0 -27
- package/dist/runtime/server/api/reload.mjs +0 -11
- package/dist/runtime/server/api/search.d.ts +0 -6
- package/dist/runtime/server/api/search.js +0 -27
- package/dist/runtime/server/api/search.mjs +0 -13
- package/dist/runtime/server/content.d.ts +0 -46
- package/dist/runtime/server/content.js +0 -175
- package/dist/runtime/server/content.mjs +0 -114
- package/dist/runtime/server/socket.d.ts +0 -9
- package/dist/runtime/server/socket.js +0 -33
- package/dist/runtime/server/socket.mjs +0 -20
- package/dist/runtime/server/utils/cache.d.ts +0 -19
- package/dist/runtime/server/utils/cache.js +0 -110
- package/dist/runtime/server/utils/cache.mjs +0 -75
- package/dist/runtime/server/utils/index.d.ts +0 -4
- package/dist/runtime/server/utils/index.js +0 -18
- package/dist/runtime/server/utils/index.mjs +0 -8
- package/dist/runtime/transformers/index.d.ts +0 -1
- package/dist/runtime/transformers/index.js +0 -26
- package/dist/runtime/transformers/index.mjs +0 -11
- package/dist/runtime/transformers/json.d.ts +0 -3
- package/dist/runtime/transformers/json.js +0 -15
- package/dist/runtime/transformers/json.mjs +0 -5
- package/dist/runtime/transformers/markdown/index.d.ts +0 -8
- package/dist/runtime/transformers/markdown/index.js +0 -25
- package/dist/runtime/transformers/markdown/index.mjs +0 -16
- package/dist/runtime/transformers/utils/index.d.ts +0 -1
- package/dist/runtime/transformers/utils/index.js +0 -18
- package/dist/runtime/transformers/utils/index.mjs +0 -1
- package/dist/runtime/transformers/utils/path.d.ts +0 -26
- package/dist/runtime/transformers/utils/path.js +0 -88
- package/dist/runtime/transformers/utils/path.mjs +0 -56
- package/dist/runtime/utils/index.d.ts +0 -1
- package/dist/runtime/utils/index.js +0 -18
- package/dist/runtime/utils/index.mjs +0 -1
- package/dist/runtime/utils/log.d.ts +0 -1
- package/dist/runtime/utils/log.js +0 -14
- package/dist/runtime/utils/log.mjs +0 -2
- package/dist/runtime/utils/object.d.ts +0 -9
- package/dist/runtime/utils/object.js +0 -22
- package/dist/runtime/utils/object.mjs +0 -4
- package/dist/templates/content.mjs +0 -50
- package/dist/templates/docus.mjs +0 -13
- package/dist/templates/hot.mjs +0 -16
- package/dist/templates/i18n.mjs +0 -23
- package/dist/templates/options.mjs +0 -46
- package/shims.d.ts +0 -24
- package/types.d.ts +0 -397
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateNavigation = generateNavigation;
|
|
7
|
-
|
|
8
|
-
var _scule = require("scule");
|
|
9
|
-
|
|
10
|
-
var _ufo = require("ufo");
|
|
11
|
-
|
|
12
|
-
var _defu = _interopRequireDefault(require("defu"));
|
|
13
|
-
|
|
14
|
-
var _object = require("./utils/object");
|
|
15
|
-
|
|
16
|
-
var _context = require("./context");
|
|
17
|
-
|
|
18
|
-
var _utils = require("./transformers/utils");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
const isIndex = path => path.endsWith("index.md");
|
|
23
|
-
|
|
24
|
-
function sortItems(keys) {
|
|
25
|
-
return [...keys].sort((a, b) => a.id.localeCompare(b.id)).sort((a, b) => {
|
|
26
|
-
const isA = isIndex(a.id);
|
|
27
|
-
const isB = isIndex(b.id);
|
|
28
|
-
if (isA && isB) return a.id.length - b.id.length;
|
|
29
|
-
if (isB) return 1;
|
|
30
|
-
if (isA) return -1;
|
|
31
|
-
return 0;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const findLink = (links, to) => links.find(link => link.to === to);
|
|
36
|
-
|
|
37
|
-
const slugToTitle = title => title && title.replace(/-/g, " ").split(" ").map(_scule.pascalCase).join(" ");
|
|
38
|
-
|
|
39
|
-
const getPageLink = page => {
|
|
40
|
-
const id = page.id;
|
|
41
|
-
const slug = (page.slug || page.to).split("/").pop();
|
|
42
|
-
const to = (0, _ufo.withoutTrailingSlash)(page.to || `/${slug}`);
|
|
43
|
-
const template = typeof page.template === "string" ? {
|
|
44
|
-
self: page.template,
|
|
45
|
-
nested: `${page.template}-post`
|
|
46
|
-
} : page.template;
|
|
47
|
-
const item = { ...page,
|
|
48
|
-
...page.navigation,
|
|
49
|
-
id,
|
|
50
|
-
draft: page.draft,
|
|
51
|
-
language: page.language,
|
|
52
|
-
slug: page.slug,
|
|
53
|
-
to,
|
|
54
|
-
page: typeof page.page !== "undefined" ? page.page : !(page.slug === "" && page.empty && !page.navigation?.redirect),
|
|
55
|
-
children: [],
|
|
56
|
-
title: page.title || slugToTitle(to.split("/").pop() || "")
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (page.draft) {
|
|
60
|
-
item.draft = true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (page.icon) {
|
|
64
|
-
item.icon = page.icon;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (template) {
|
|
68
|
-
item.template = template.nested;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (page.navigation === false) {
|
|
72
|
-
item.hidden = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return item;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
async function generateNavigation(contents) {
|
|
79
|
-
const defaultLocale = "en";
|
|
80
|
-
|
|
81
|
-
if (!contents) {
|
|
82
|
-
contents = await globalThis.$fetch("/api/_docus/list").then(({
|
|
83
|
-
items
|
|
84
|
-
}) => items);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
contents = sortItems(contents || []);
|
|
88
|
-
const languages = contents.reduce((map, page) => {
|
|
89
|
-
const language = page.language || defaultLocale;
|
|
90
|
-
map[language] = map[language] || [];
|
|
91
|
-
map[language].push(page);
|
|
92
|
-
return map;
|
|
93
|
-
}, {});
|
|
94
|
-
const navigationArray = Object.entries(languages).map(([language, pages]) => {
|
|
95
|
-
const body = createNav(pages);
|
|
96
|
-
return [language, body];
|
|
97
|
-
});
|
|
98
|
-
const navigation = Object.fromEntries(navigationArray);
|
|
99
|
-
return navigation;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function sortWithPosition(links, map) {
|
|
103
|
-
links.forEach(link => sortWithPosition(link.children || [], map));
|
|
104
|
-
|
|
105
|
-
const pos = a => map[a.id] || "999999999999";
|
|
106
|
-
|
|
107
|
-
return links.sort((a, b) => pos(a).localeCompare(pos(b)));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function createNav(pages) {
|
|
111
|
-
const {
|
|
112
|
-
search: {
|
|
113
|
-
inheritanceFields
|
|
114
|
-
}
|
|
115
|
-
} = (0, _context.useDocusContext)();
|
|
116
|
-
const pickInheritanceFields = (0, _object.pick)(inheritanceFields);
|
|
117
|
-
const links = [];
|
|
118
|
-
const sortMap = {};
|
|
119
|
-
pages.forEach(_page => {
|
|
120
|
-
sortMap[_page.id] = String(_page.position);
|
|
121
|
-
const $page = getPageLink(_page);
|
|
122
|
-
|
|
123
|
-
if ($page.slug.startsWith("_")) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const dirs = $page.to.split("/").filter(_ => _);
|
|
128
|
-
const idParts = $page.id.split(/[:/]/);
|
|
129
|
-
|
|
130
|
-
if (!dirs.length) {
|
|
131
|
-
return links.push($page);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
let currentLinks = links;
|
|
135
|
-
let lastLink;
|
|
136
|
-
const parents = [];
|
|
137
|
-
const root = findLink(currentLinks, "/");
|
|
138
|
-
if (root) parents.push(root);
|
|
139
|
-
dirs.forEach((dir, index) => {
|
|
140
|
-
const to = "/" + dirs.slice(0, index + 1).join("/");
|
|
141
|
-
if (!currentLinks) return;
|
|
142
|
-
let link = findLink(currentLinks, to);
|
|
143
|
-
|
|
144
|
-
if (!link) {
|
|
145
|
-
link = getPageLink({
|
|
146
|
-
id: idParts.slice(0, index + 2).join(":"),
|
|
147
|
-
slug: dir,
|
|
148
|
-
to,
|
|
149
|
-
page: false,
|
|
150
|
-
position: (0, _utils.generatePosition)(idParts.slice(1, index + 2).join(":"))
|
|
151
|
-
});
|
|
152
|
-
sortMap[link.id] = link.position;
|
|
153
|
-
currentLinks.push(link);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
currentLinks = link.children;
|
|
157
|
-
lastLink = link;
|
|
158
|
-
parents.unshift(link);
|
|
159
|
-
});
|
|
160
|
-
Object.assign($page, (0, _defu.default)(pickInheritanceFields($page), ...parents.map(pickInheritanceFields)));
|
|
161
|
-
if (!currentLinks) return;
|
|
162
|
-
|
|
163
|
-
if (lastLink?.to === $page.to) {
|
|
164
|
-
mergeLinks(lastLink, $page);
|
|
165
|
-
} else {
|
|
166
|
-
currentLinks.push($page);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
return sortWithPosition(links, sortMap);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function mergeLinks(to, from) {
|
|
173
|
-
Object.assign(to, from, {
|
|
174
|
-
children: [...to.children, ...from.children]
|
|
175
|
-
});
|
|
176
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { pascalCase } from "scule";
|
|
2
|
-
import { withoutTrailingSlash } from "ufo";
|
|
3
|
-
import defu from "defu";
|
|
4
|
-
import { pick } from "./utils/object.mjs";
|
|
5
|
-
import { useDocusContext } from "./context.mjs";
|
|
6
|
-
import { generatePosition } from "./transformers/utils/index.mjs";
|
|
7
|
-
const isIndex = (path) => path.endsWith("index.md");
|
|
8
|
-
function sortItems(keys) {
|
|
9
|
-
return [...keys].sort((a, b) => a.id.localeCompare(b.id)).sort((a, b) => {
|
|
10
|
-
const isA = isIndex(a.id);
|
|
11
|
-
const isB = isIndex(b.id);
|
|
12
|
-
if (isA && isB)
|
|
13
|
-
return a.id.length - b.id.length;
|
|
14
|
-
if (isB)
|
|
15
|
-
return 1;
|
|
16
|
-
if (isA)
|
|
17
|
-
return -1;
|
|
18
|
-
return 0;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
const findLink = (links, to) => links.find((link) => link.to === to);
|
|
22
|
-
const slugToTitle = (title) => title && title.replace(/-/g, " ").split(" ").map(pascalCase).join(" ");
|
|
23
|
-
const getPageLink = (page) => {
|
|
24
|
-
const id = page.id;
|
|
25
|
-
const slug = (page.slug || page.to).split("/").pop();
|
|
26
|
-
const to = withoutTrailingSlash(page.to || `/${slug}`);
|
|
27
|
-
const template = typeof page.template === "string" ? { self: page.template, nested: `${page.template}-post` } : page.template;
|
|
28
|
-
const item = {
|
|
29
|
-
...page,
|
|
30
|
-
...page.navigation,
|
|
31
|
-
id,
|
|
32
|
-
draft: page.draft,
|
|
33
|
-
language: page.language,
|
|
34
|
-
slug: page.slug,
|
|
35
|
-
to,
|
|
36
|
-
page: typeof page.page !== "undefined" ? page.page : !(page.slug === "" && page.empty && !page.navigation?.redirect),
|
|
37
|
-
children: [],
|
|
38
|
-
title: page.title || slugToTitle(to.split("/").pop() || "")
|
|
39
|
-
};
|
|
40
|
-
if (page.draft) {
|
|
41
|
-
item.draft = true;
|
|
42
|
-
}
|
|
43
|
-
if (page.icon) {
|
|
44
|
-
item.icon = page.icon;
|
|
45
|
-
}
|
|
46
|
-
if (template) {
|
|
47
|
-
item.template = template.nested;
|
|
48
|
-
}
|
|
49
|
-
if (page.navigation === false) {
|
|
50
|
-
item.hidden = true;
|
|
51
|
-
}
|
|
52
|
-
return item;
|
|
53
|
-
};
|
|
54
|
-
export async function generateNavigation(contents) {
|
|
55
|
-
const defaultLocale = "en";
|
|
56
|
-
if (!contents) {
|
|
57
|
-
contents = await globalThis.$fetch("/api/_docus/list").then(({ items }) => items);
|
|
58
|
-
}
|
|
59
|
-
contents = sortItems(contents || []);
|
|
60
|
-
const languages = contents.reduce((map, page) => {
|
|
61
|
-
const language = page.language || defaultLocale;
|
|
62
|
-
map[language] = map[language] || [];
|
|
63
|
-
map[language].push(page);
|
|
64
|
-
return map;
|
|
65
|
-
}, {});
|
|
66
|
-
const navigationArray = Object.entries(languages).map(([language, pages]) => {
|
|
67
|
-
const body = createNav(pages);
|
|
68
|
-
return [language, body];
|
|
69
|
-
});
|
|
70
|
-
const navigation = Object.fromEntries(navigationArray);
|
|
71
|
-
return navigation;
|
|
72
|
-
}
|
|
73
|
-
function sortWithPosition(links, map) {
|
|
74
|
-
links.forEach((link) => sortWithPosition(link.children || [], map));
|
|
75
|
-
const pos = (a) => map[a.id] || "999999999999";
|
|
76
|
-
return links.sort((a, b) => pos(a).localeCompare(pos(b)));
|
|
77
|
-
}
|
|
78
|
-
function createNav(pages) {
|
|
79
|
-
const {
|
|
80
|
-
search: { inheritanceFields }
|
|
81
|
-
} = useDocusContext();
|
|
82
|
-
const pickInheritanceFields = pick(inheritanceFields);
|
|
83
|
-
const links = [];
|
|
84
|
-
const sortMap = {};
|
|
85
|
-
pages.forEach((_page) => {
|
|
86
|
-
sortMap[_page.id] = String(_page.position);
|
|
87
|
-
const $page = getPageLink(_page);
|
|
88
|
-
if ($page.slug.startsWith("_")) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const dirs = $page.to.split("/").filter((_) => _);
|
|
92
|
-
const idParts = $page.id.split(/[:/]/);
|
|
93
|
-
if (!dirs.length) {
|
|
94
|
-
return links.push($page);
|
|
95
|
-
}
|
|
96
|
-
let currentLinks = links;
|
|
97
|
-
let lastLink;
|
|
98
|
-
const parents = [];
|
|
99
|
-
const root = findLink(currentLinks, "/");
|
|
100
|
-
if (root)
|
|
101
|
-
parents.push(root);
|
|
102
|
-
dirs.forEach((dir, index) => {
|
|
103
|
-
const to = "/" + dirs.slice(0, index + 1).join("/");
|
|
104
|
-
if (!currentLinks)
|
|
105
|
-
return;
|
|
106
|
-
let link = findLink(currentLinks, to);
|
|
107
|
-
if (!link) {
|
|
108
|
-
link = getPageLink({
|
|
109
|
-
id: idParts.slice(0, index + 2).join(":"),
|
|
110
|
-
slug: dir,
|
|
111
|
-
to,
|
|
112
|
-
page: false,
|
|
113
|
-
position: generatePosition(idParts.slice(1, index + 2).join(":"))
|
|
114
|
-
});
|
|
115
|
-
sortMap[link.id] = link.position;
|
|
116
|
-
currentLinks.push(link);
|
|
117
|
-
}
|
|
118
|
-
currentLinks = link.children;
|
|
119
|
-
lastLink = link;
|
|
120
|
-
parents.unshift(link);
|
|
121
|
-
});
|
|
122
|
-
Object.assign($page, defu(pickInheritanceFields($page), ...parents.map(pickInheritanceFields)));
|
|
123
|
-
if (!currentLinks)
|
|
124
|
-
return;
|
|
125
|
-
if (lastLink?.to === $page.to) {
|
|
126
|
-
mergeLinks(lastLink, $page);
|
|
127
|
-
} else {
|
|
128
|
-
currentLinks.push($page);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
return sortWithPosition(links, sortMap);
|
|
132
|
-
}
|
|
133
|
-
function mergeLinks(to, from) {
|
|
134
|
-
Object.assign(to, from, {
|
|
135
|
-
children: [...to.children, ...from.children]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _content = require("../content");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
|
|
12
|
-
var _default = async req => {
|
|
13
|
-
const key = (0, _utils.useKey)(req);
|
|
14
|
-
const previewKey = (0, _utils.usePreview)(req);
|
|
15
|
-
const content = await (0, _content.getContent)(key, previewKey);
|
|
16
|
-
return {
|
|
17
|
-
key,
|
|
18
|
-
generatedAt: new Date(),
|
|
19
|
-
...content.meta,
|
|
20
|
-
body: content.body
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
module.exports = _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getContent } from "../content.mjs";
|
|
2
|
-
import { useKey, usePreview } from "../utils/index.mjs";
|
|
3
|
-
export default async (req) => {
|
|
4
|
-
const key = useKey(req);
|
|
5
|
-
const previewKey = usePreview(req);
|
|
6
|
-
const content = await getContent(key, previewKey);
|
|
7
|
-
return {
|
|
8
|
-
key,
|
|
9
|
-
generatedAt: new Date(),
|
|
10
|
-
...content.meta,
|
|
11
|
-
body: content.body
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _h = require("h3");
|
|
9
|
-
|
|
10
|
-
var _content = require("../content");
|
|
11
|
-
|
|
12
|
-
var _utils = require("../utils");
|
|
13
|
-
|
|
14
|
-
var _default = async req => {
|
|
15
|
-
const key = (0, _utils.useKey)(req);
|
|
16
|
-
const previewKey = (0, _utils.usePreview)(req);
|
|
17
|
-
let items = await (0, _content.getList)(key, previewKey);
|
|
18
|
-
const {
|
|
19
|
-
q
|
|
20
|
-
} = (0, _h.useQuery)(req);
|
|
21
|
-
|
|
22
|
-
if (q) {
|
|
23
|
-
items = items.filter(item => {
|
|
24
|
-
return item.id.includes(String(q)) || (item.meta.title || "").includes(q);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
generatedAt: new Date(),
|
|
30
|
-
items
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
module.exports = _default;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "h3";
|
|
2
|
-
import { getList } from "../content.mjs";
|
|
3
|
-
import { useKey, usePreview } from "../utils/index.mjs";
|
|
4
|
-
export default async (req) => {
|
|
5
|
-
const key = useKey(req);
|
|
6
|
-
const previewKey = usePreview(req);
|
|
7
|
-
let items = await getList(key, previewKey);
|
|
8
|
-
const { q } = useQuery(req);
|
|
9
|
-
if (q) {
|
|
10
|
-
items = items.filter((item) => {
|
|
11
|
-
return item.id.includes(String(q)) || (item.meta.title || "").includes(q);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
generatedAt: new Date(),
|
|
16
|
-
items
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _content = require("../content");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
|
|
12
|
-
var _default = async req => {
|
|
13
|
-
const key = (0, _utils.useKey)(req);
|
|
14
|
-
const previewKey = (0, _utils.usePreview)(req);
|
|
15
|
-
const result = await (0, _content.getNavigation)(previewKey);
|
|
16
|
-
if (result[key]) return result[key];
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getNavigation } from "../content.mjs";
|
|
2
|
-
import { useKey, usePreview } from "../utils/index.mjs";
|
|
3
|
-
export default async (req) => {
|
|
4
|
-
const key = useKey(req);
|
|
5
|
-
const previewKey = usePreview(req);
|
|
6
|
-
const result = await getNavigation(previewKey);
|
|
7
|
-
if (result[key])
|
|
8
|
-
return result[key];
|
|
9
|
-
return result;
|
|
10
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _h = require("h3");
|
|
9
|
-
|
|
10
|
-
var _content = require("../content");
|
|
11
|
-
|
|
12
|
-
var _utils = require("../utils");
|
|
13
|
-
|
|
14
|
-
var _default = async req => {
|
|
15
|
-
const preview = (0, _utils.usePreview)(req);
|
|
16
|
-
const key = (preview ? preview + ":" : "") + (0, _utils.useKey)(req);
|
|
17
|
-
|
|
18
|
-
switch (req.method) {
|
|
19
|
-
case "DELETE":
|
|
20
|
-
if (key) {
|
|
21
|
-
await _content.previewStorage.removeItem(key);
|
|
22
|
-
} else {
|
|
23
|
-
await _content.previewStorage.clear();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
break;
|
|
27
|
-
|
|
28
|
-
case "POST":
|
|
29
|
-
{
|
|
30
|
-
let body = req.body || (await (0, _h.useBody)(req));
|
|
31
|
-
|
|
32
|
-
if (typeof body === "string") {
|
|
33
|
-
body = JSON.parse(body);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
await _content.previewStorage.setItem((preview ? preview + ":" : "") + body.key, body.content);
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
case "GET":
|
|
41
|
-
if (key) {
|
|
42
|
-
return await _content.previewStorage.getKeys();
|
|
43
|
-
} else {
|
|
44
|
-
return await _content.previewStorage.getItem(key);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
success: 1
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
module.exports = _default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useBody } from "h3";
|
|
2
|
-
import { previewStorage } from "../content.mjs";
|
|
3
|
-
import { useKey, usePreview } from "../utils/index.mjs";
|
|
4
|
-
export default async (req) => {
|
|
5
|
-
const preview = usePreview(req);
|
|
6
|
-
const key = (preview ? preview + ":" : "") + useKey(req);
|
|
7
|
-
switch (req.method) {
|
|
8
|
-
case "DELETE":
|
|
9
|
-
if (key) {
|
|
10
|
-
await previewStorage.removeItem(key);
|
|
11
|
-
} else {
|
|
12
|
-
await previewStorage.clear();
|
|
13
|
-
}
|
|
14
|
-
break;
|
|
15
|
-
case "POST": {
|
|
16
|
-
let body = req.body || await useBody(req);
|
|
17
|
-
if (typeof body === "string") {
|
|
18
|
-
body = JSON.parse(body);
|
|
19
|
-
}
|
|
20
|
-
await previewStorage.setItem((preview ? preview + ":" : "") + body.key, body.content);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
case "GET":
|
|
24
|
-
if (key) {
|
|
25
|
-
return await previewStorage.getKeys();
|
|
26
|
-
} else {
|
|
27
|
-
return await previewStorage.getItem(key);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return { success: 1 };
|
|
31
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _h = require("h3");
|
|
9
|
-
|
|
10
|
-
var _content = require("../content");
|
|
11
|
-
|
|
12
|
-
var _default = async req => {
|
|
13
|
-
const {
|
|
14
|
-
key,
|
|
15
|
-
event
|
|
16
|
-
} = await (0, _h.useBody)(req);
|
|
17
|
-
|
|
18
|
-
if (event === "remove") {
|
|
19
|
-
_content.buildStorage.removeItem(key);
|
|
20
|
-
} else if (await _content.buildStorage.hasItem(key)) {
|
|
21
|
-
await (0, _content.buildContent)(key);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
module.exports = _default;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useBody } from "h3";
|
|
2
|
-
import { buildContent, buildStorage } from "../content.mjs";
|
|
3
|
-
export default async (req) => {
|
|
4
|
-
const { key, event } = await useBody(req);
|
|
5
|
-
if (event === "remove") {
|
|
6
|
-
buildStorage.removeItem(key);
|
|
7
|
-
} else if (await buildStorage.hasItem(key)) {
|
|
8
|
-
await buildContent(key);
|
|
9
|
-
}
|
|
10
|
-
return true;
|
|
11
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _h = require("h3");
|
|
9
|
-
|
|
10
|
-
var _content = require("../content");
|
|
11
|
-
|
|
12
|
-
var _utils = require("../utils");
|
|
13
|
-
|
|
14
|
-
var _default = async req => {
|
|
15
|
-
const key = (0, _utils.useKey)(req);
|
|
16
|
-
const previewKey = (0, _utils.usePreview)(req);
|
|
17
|
-
let body = req.body || (await (0, _h.useBody)(req));
|
|
18
|
-
|
|
19
|
-
if (typeof body === "string") {
|
|
20
|
-
body = JSON.parse(body);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const result = await (0, _content.searchContent)(key, body || {}, previewKey);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
module.exports = _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useBody } from "h3";
|
|
2
|
-
import { searchContent } from "../content.mjs";
|
|
3
|
-
import { useKey, usePreview } from "../utils/index.mjs";
|
|
4
|
-
export default async (req) => {
|
|
5
|
-
const key = useKey(req);
|
|
6
|
-
const previewKey = usePreview(req);
|
|
7
|
-
let body = req.body || await useBody(req);
|
|
8
|
-
if (typeof body === "string") {
|
|
9
|
-
body = JSON.parse(body);
|
|
10
|
-
}
|
|
11
|
-
const result = await searchContent(key, body || {}, previewKey);
|
|
12
|
-
return result;
|
|
13
|
-
};
|