docus 1.0.4 → 2.1.0
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/LICENSE +21 -0
- package/README.md +9 -24
- package/dist/index.cjs +549 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.mjs +523 -0
- package/dist/runtime/app/components/DocusContent.vue +215 -0
- package/dist/runtime/app/components/DocusContent.vue.d.ts +25 -0
- package/dist/runtime/app/components/Error.vue +19 -0
- package/dist/runtime/app/components/Error.vue.d.ts +9 -0
- package/dist/runtime/app/components/Markdown.vue +56 -0
- package/dist/runtime/app/components/Markdown.vue.d.ts +25 -0
- package/dist/runtime/app/components/Page.vue +29 -0
- package/dist/runtime/app/components/Page.vue.d.ts +2 -0
- package/dist/runtime/app/components/Props.vue +130 -0
- package/dist/runtime/app/components/Props.vue.d.ts +80 -0
- package/dist/runtime/app/components/prose/ProseA.vue +41 -0
- package/dist/runtime/app/components/prose/ProseA.vue.d.ts +23 -0
- package/dist/runtime/app/components/prose/ProseBlockquote.vue +5 -0
- package/dist/runtime/app/components/prose/ProseCode.vue +5 -0
- package/dist/runtime/app/components/prose/ProseCodeInline.vue +5 -0
- package/dist/runtime/app/components/prose/ProseEm.vue +5 -0
- package/dist/runtime/app/components/prose/ProseH1.vue +3 -0
- package/dist/runtime/app/components/prose/ProseH2.vue +3 -0
- package/dist/runtime/app/components/prose/ProseH3.vue +3 -0
- package/dist/runtime/app/components/prose/ProseH4.vue +3 -0
- package/dist/runtime/app/components/prose/ProseH5.vue +3 -0
- package/dist/runtime/app/components/prose/ProseH6.vue +3 -0
- package/dist/runtime/app/components/prose/ProseHr.vue +3 -0
- package/dist/runtime/app/components/prose/ProseImg.vue +32 -0
- package/dist/runtime/app/components/prose/ProseImg.vue.d.ts +21 -0
- package/dist/runtime/app/components/prose/ProseLi.vue +3 -0
- package/dist/runtime/app/components/prose/ProseOl.vue +5 -0
- package/dist/runtime/app/components/prose/ProseParagraph.vue +3 -0
- package/dist/runtime/app/components/prose/ProseStrong.vue +5 -0
- package/dist/runtime/app/components/prose/ProseTable.vue +5 -0
- package/dist/runtime/app/components/prose/ProseTbody.vue +5 -0
- package/dist/runtime/app/components/prose/ProseTd.vue +5 -0
- package/dist/runtime/app/components/prose/ProseTh.vue +5 -0
- package/dist/runtime/app/components/prose/ProseThead.vue +5 -0
- package/dist/runtime/app/components/prose/ProseTr.vue +5 -0
- package/dist/runtime/app/components/prose/ProseUl.vue +5 -0
- package/dist/runtime/app/composables/helpers.d.ts +4 -0
- package/dist/runtime/app/composables/helpers.js +66 -0
- package/dist/runtime/app/composables/helpers.mjs +40 -0
- package/dist/runtime/app/composables/index.d.ts +90 -0
- package/dist/runtime/app/composables/index.js +108 -0
- package/dist/runtime/app/composables/index.mjs +63 -0
- package/dist/runtime/app/composables/navigation.d.ts +37 -0
- package/dist/runtime/app/composables/navigation.js +227 -0
- package/dist/runtime/app/composables/navigation.mjs +148 -0
- package/dist/runtime/app/composables/store.d.ts +7 -0
- package/dist/runtime/app/composables/store.js +52 -0
- package/dist/runtime/app/composables/store.mjs +35 -0
- package/dist/runtime/app/composables/style.d.ts +11 -0
- package/dist/runtime/app/composables/style.js +117 -0
- package/dist/runtime/app/composables/style.mjs +71 -0
- package/dist/runtime/app/composables/theme-colors.d.ts +30 -0
- package/dist/runtime/app/composables/theme-colors.js +80 -0
- package/dist/runtime/app/composables/theme-colors.mjs +48 -0
- package/dist/runtime/app/composables/websocket.d.ts +3 -0
- package/dist/runtime/app/composables/websocket.js +79 -0
- package/dist/runtime/app/composables/websocket.mjs +63 -0
- package/dist/runtime/app/layouts/default.vue +5 -0
- package/dist/runtime/app/layouts/error.vue +33 -0
- package/dist/runtime/app/layouts/error.vue.d.ts +21 -0
- package/dist/runtime/app/pages/_.vue +222 -0
- package/dist/runtime/app/pages/_.vue.d.ts +2 -0
- package/dist/runtime/context.d.ts +1 -0
- package/dist/runtime/context.js +17 -0
- package/dist/runtime/context.mjs +5 -0
- package/dist/runtime/database/Query.d.ts +18 -0
- package/dist/runtime/database/Query.js +68 -0
- package/dist/runtime/database/Query.mjs +49 -0
- package/dist/runtime/database/index.d.ts +4 -0
- package/dist/runtime/database/index.js +45 -0
- package/dist/runtime/database/index.mjs +25 -0
- package/dist/runtime/database/providers/local/Query.d.ts +14 -0
- package/dist/runtime/database/providers/local/Query.js +85 -0
- package/dist/runtime/database/providers/local/Query.mjs +60 -0
- package/dist/runtime/database/providers/local/index.d.ts +3 -0
- package/dist/runtime/database/providers/local/index.js +63 -0
- package/dist/runtime/database/providers/local/index.mjs +39 -0
- package/dist/runtime/database/providers/local/operations.d.ts +2 -0
- package/dist/runtime/database/providers/local/operations.js +83 -0
- package/dist/runtime/database/providers/local/operations.mjs +53 -0
- package/dist/runtime/database/providers/local/utils.d.ts +8 -0
- package/dist/runtime/database/providers/local/utils.js +28 -0
- package/dist/runtime/database/providers/local/utils.mjs +17 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +44 -0
- package/dist/runtime/index.mjs +3 -0
- package/dist/runtime/navigation.d.ts +4 -0
- package/dist/runtime/navigation.js +176 -0
- package/dist/runtime/navigation.mjs +137 -0
- package/dist/runtime/server/api/get.d.ts +10 -0
- package/dist/runtime/server/api/get.js +24 -0
- package/dist/runtime/server/api/get.mjs +13 -0
- package/dist/runtime/server/api/list.d.ts +9 -0
- package/dist/runtime/server/api/list.js +34 -0
- package/dist/runtime/server/api/list.mjs +18 -0
- package/dist/runtime/server/api/navigation.d.ts +7 -0
- package/dist/runtime/server/api/navigation.js +20 -0
- package/dist/runtime/server/api/navigation.mjs +10 -0
- package/dist/runtime/server/api/preview.d.ts +3 -0
- package/dist/runtime/server/api/preview.js +54 -0
- package/dist/runtime/server/api/preview.mjs +31 -0
- package/dist/runtime/server/api/reload.d.ts +6 -0
- package/dist/runtime/server/api/reload.js +27 -0
- package/dist/runtime/server/api/reload.mjs +11 -0
- package/dist/runtime/server/api/search.d.ts +6 -0
- package/dist/runtime/server/api/search.js +27 -0
- package/dist/runtime/server/api/search.mjs +13 -0
- package/dist/runtime/server/content.d.ts +46 -0
- package/dist/runtime/server/content.js +175 -0
- package/dist/runtime/server/content.mjs +114 -0
- package/dist/runtime/server/socket.d.ts +9 -0
- package/dist/runtime/server/socket.js +33 -0
- package/dist/runtime/server/socket.mjs +20 -0
- package/dist/runtime/server/utils/cache.d.ts +19 -0
- package/dist/runtime/server/utils/cache.js +110 -0
- package/dist/runtime/server/utils/cache.mjs +75 -0
- package/dist/runtime/server/utils/index.d.ts +4 -0
- package/dist/runtime/server/utils/index.js +18 -0
- package/dist/runtime/server/utils/index.mjs +8 -0
- package/dist/runtime/transformers/index.d.ts +1 -0
- package/dist/runtime/transformers/index.js +26 -0
- package/dist/runtime/transformers/index.mjs +11 -0
- package/dist/runtime/transformers/json.d.ts +3 -0
- package/dist/runtime/transformers/json.js +15 -0
- package/dist/runtime/transformers/json.mjs +5 -0
- package/dist/runtime/transformers/markdown/index.d.ts +8 -0
- package/dist/runtime/transformers/markdown/index.js +25 -0
- package/dist/runtime/transformers/markdown/index.mjs +16 -0
- package/dist/runtime/transformers/utils/index.d.ts +1 -0
- package/dist/runtime/transformers/utils/index.js +18 -0
- package/dist/runtime/transformers/utils/index.mjs +1 -0
- package/dist/runtime/transformers/utils/path.d.ts +26 -0
- package/dist/runtime/transformers/utils/path.js +88 -0
- package/dist/runtime/transformers/utils/path.mjs +56 -0
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +18 -0
- package/dist/runtime/utils/index.mjs +1 -0
- package/dist/runtime/utils/log.d.ts +1 -0
- package/dist/runtime/utils/log.js +14 -0
- package/dist/runtime/utils/log.mjs +2 -0
- package/dist/runtime/utils/object.d.ts +9 -0
- package/dist/runtime/utils/object.js +22 -0
- package/dist/runtime/utils/object.mjs +4 -0
- package/dist/templates/content.mjs +50 -0
- package/dist/templates/docus.mjs +13 -0
- package/dist/templates/hot.mjs +16 -0
- package/dist/templates/i18n.mjs +23 -0
- package/dist/templates/options.mjs +46 -0
- package/package.json +78 -58
- package/shims.d.ts +24 -0
- package/types.d.ts +397 -0
- package/dist/create-docus/create-docus.js +0 -7
- package/dist/create-docus/index.js +0 -122
- package/dist/helpers.js +0 -154
- package/dist/index.js +0 -10
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './path';
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./path.mjs";
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './log';
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./log.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logger: import("consola").Consola;
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
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);
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|