docus 1.0.7 → 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 -59
- 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/helpers.js +0 -244
- package/dist/create-docus/index.js +0 -87
- package/dist/index.js +0 -10
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<img :src="src" :alt="alt" :width="width" :height="height" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
module.exports = void 0;
|
|
12
|
+
var _default = {
|
|
13
|
+
props: {
|
|
14
|
+
src: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: ""
|
|
17
|
+
},
|
|
18
|
+
alt: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: ""
|
|
21
|
+
},
|
|
22
|
+
width: {
|
|
23
|
+
type: [String, Number],
|
|
24
|
+
default: void 0
|
|
25
|
+
},
|
|
26
|
+
height: {
|
|
27
|
+
type: [String, Number],
|
|
28
|
+
default: void 0
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
module.exports = _default;</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
props: {
|
|
3
|
+
src: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
default: string;
|
|
6
|
+
};
|
|
7
|
+
alt: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
width: {
|
|
12
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
13
|
+
default: any;
|
|
14
|
+
};
|
|
15
|
+
height: {
|
|
16
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
17
|
+
default: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizePreviewScope = exports.detectPreview = exports.clientAsyncData = void 0;
|
|
7
|
+
|
|
8
|
+
var _vue = _interopRequireDefault(require("vue"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const clientAsyncData = $nuxt => {
|
|
13
|
+
if (process.client) {
|
|
14
|
+
const loadedComponents = new Set();
|
|
15
|
+
|
|
16
|
+
const loadComponents = function (components) {
|
|
17
|
+
if (!components) return;
|
|
18
|
+
return Array.from(components).map(async function (name) {
|
|
19
|
+
const component = _vue.default.component(name);
|
|
20
|
+
|
|
21
|
+
if (!loadedComponents.has(name) && typeof component === "function" && !component.options) {
|
|
22
|
+
loadedComponents.add(name);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
await _vue.default.component(name)();
|
|
26
|
+
} catch (e) {}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
window.onNuxtReady(nuxt => {
|
|
32
|
+
$nuxt = nuxt;
|
|
33
|
+
const originalFetchPayload = $nuxt.fetchPayload;
|
|
34
|
+
|
|
35
|
+
if (originalFetchPayload) {
|
|
36
|
+
$nuxt.fetchPayload = async function (...args) {
|
|
37
|
+
const payload = await originalFetchPayload(...args);
|
|
38
|
+
loadComponents(new Set(payload.data[0]?.page?.template));
|
|
39
|
+
return payload;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
loadComponents(new Set("NuxtContent"));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.clientAsyncData = clientAsyncData;
|
|
49
|
+
|
|
50
|
+
const detectPreview = context => {
|
|
51
|
+
const {
|
|
52
|
+
route
|
|
53
|
+
} = context;
|
|
54
|
+
|
|
55
|
+
if (process.server && route.query._preview) {
|
|
56
|
+
return String(route.query._preview).replace(/\/$/, "");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.detectPreview = detectPreview;
|
|
63
|
+
|
|
64
|
+
const normalizePreviewScope = scope => scope.replace("_preview/", "");
|
|
65
|
+
|
|
66
|
+
exports.normalizePreviewScope = normalizePreviewScope;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
export const clientAsyncData = ($nuxt) => {
|
|
3
|
+
if (process.client) {
|
|
4
|
+
const loadedComponents = new Set();
|
|
5
|
+
const loadComponents = function(components) {
|
|
6
|
+
if (!components)
|
|
7
|
+
return;
|
|
8
|
+
return Array.from(components).map(async function(name) {
|
|
9
|
+
const component = Vue.component(name);
|
|
10
|
+
if (!loadedComponents.has(name) && typeof component === "function" && !component.options) {
|
|
11
|
+
loadedComponents.add(name);
|
|
12
|
+
try {
|
|
13
|
+
await Vue.component(name)();
|
|
14
|
+
} catch (e) {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
window.onNuxtReady((nuxt) => {
|
|
20
|
+
$nuxt = nuxt;
|
|
21
|
+
const originalFetchPayload = $nuxt.fetchPayload;
|
|
22
|
+
if (originalFetchPayload) {
|
|
23
|
+
$nuxt.fetchPayload = async function(...args) {
|
|
24
|
+
const payload = await originalFetchPayload(...args);
|
|
25
|
+
loadComponents(new Set(payload.data[0]?.page?.template));
|
|
26
|
+
return payload;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
loadComponents(new Set("NuxtContent"));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const detectPreview = (context) => {
|
|
34
|
+
const { route } = context;
|
|
35
|
+
if (process.server && route.query._preview) {
|
|
36
|
+
return String(route.query._preview).replace(/\/$/, "");
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
export const normalizePreviewScope = (scope) => scope.replace("_preview/", "");
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { DefaultThemeConfig, DocusConfig } from 'types';
|
|
2
|
+
export { useDocusStyles } from './style';
|
|
3
|
+
export declare enum StateTypes {
|
|
4
|
+
Config = "docus-config",
|
|
5
|
+
Theme = "docus-theme",
|
|
6
|
+
Layout = "docus-layout",
|
|
7
|
+
CurrentPage = "docus-current-page",
|
|
8
|
+
Navigation = "docus-navigation",
|
|
9
|
+
CurrentNav = "docus-current-nav",
|
|
10
|
+
CurrentPath = "docus-current-path"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create the $docus runtime injection instance.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createDocus: (nuxtApp: NuxtAppCompat, _config: {
|
|
16
|
+
docusConfig: DocusConfig;
|
|
17
|
+
themeConfig: DefaultThemeConfig;
|
|
18
|
+
}) => {
|
|
19
|
+
$docus: {
|
|
20
|
+
config: Ref<DocusConfig>;
|
|
21
|
+
content: any;
|
|
22
|
+
theme: Ref<DefaultThemeConfig>;
|
|
23
|
+
layout: Ref<DefaultThemeConfig>;
|
|
24
|
+
page: Ref<DocusDocument>;
|
|
25
|
+
navigation: {
|
|
26
|
+
state: Ref<DocusNavigationState>;
|
|
27
|
+
currentNav: Ref<DocusCurrentNav>;
|
|
28
|
+
currentPath: Ref<string>;
|
|
29
|
+
getPageTemplate: (page: DocusDocument) => string;
|
|
30
|
+
fetchNavigation: (locale?: string) => Promise<void>;
|
|
31
|
+
isLinkActive: (to: string) => boolean;
|
|
32
|
+
updateCurrentNav: () => void;
|
|
33
|
+
getPreviousAndNextLink: (page: DocusDocument) => Promise<any>;
|
|
34
|
+
get: (params: DocusNavigationGetParameters) => {
|
|
35
|
+
title: string;
|
|
36
|
+
to: string;
|
|
37
|
+
parent: any;
|
|
38
|
+
links: any;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
init: () => Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Access the Docus runtime API.
|
|
46
|
+
*/
|
|
47
|
+
export declare const useDocus: () => {
|
|
48
|
+
content: DocusContent<any>;
|
|
49
|
+
config: Ref<DocusConfig>;
|
|
50
|
+
theme: Ref<DefaultThemeConfig>;
|
|
51
|
+
layout: Ref<DefaultThemeConfig>;
|
|
52
|
+
page: Ref<DocusDocument>;
|
|
53
|
+
navigation: {
|
|
54
|
+
state: Ref<DocusNavigationState>;
|
|
55
|
+
currentNav: Ref<DocusCurrentNav>;
|
|
56
|
+
currentPath: Ref<string>;
|
|
57
|
+
getPageTemplate: (page: DocusDocument) => string;
|
|
58
|
+
fetchNavigation: (locale?: string) => Promise<void>;
|
|
59
|
+
isLinkActive: (to: string) => boolean;
|
|
60
|
+
updateCurrentNav: () => void;
|
|
61
|
+
getPreviousAndNextLink: (page: DocusDocument) => Promise<any>;
|
|
62
|
+
get: (params: DocusNavigationGetParameters) => {
|
|
63
|
+
title: string;
|
|
64
|
+
to: string;
|
|
65
|
+
parent: any;
|
|
66
|
+
links: any;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Access the content querying functions.
|
|
72
|
+
*/
|
|
73
|
+
export declare const useDocusContent: () => any;
|
|
74
|
+
/**
|
|
75
|
+
* Access the config object.
|
|
76
|
+
*/
|
|
77
|
+
export declare const useDocusConfig: () => Ref<DocusConfig>;
|
|
78
|
+
/**
|
|
79
|
+
* Access the theme config object.
|
|
80
|
+
*/
|
|
81
|
+
export declare const useDocusTheme: () => Ref<DefaultThemeConfig>;
|
|
82
|
+
/**
|
|
83
|
+
* Access the layout config object.
|
|
84
|
+
*/
|
|
85
|
+
export declare const useDocusLayout: () => Ref<DefaultThemeConfig>;
|
|
86
|
+
/**
|
|
87
|
+
* Access the current page object.
|
|
88
|
+
*/
|
|
89
|
+
export declare const useDocusPage: () => Ref<DocusDocument>;
|
|
90
|
+
export { useDocusNavigation } from './navigation';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDocusLayout = exports.useDocusContent = exports.useDocusConfig = exports.useDocus = exports.createDocus = exports.StateTypes = void 0;
|
|
7
|
+
Object.defineProperty(exports, "useDocusNavigation", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _navigation.useDocusNavigation;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.useDocusPage = void 0;
|
|
14
|
+
Object.defineProperty(exports, "useDocusStyles", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _style.useDocusStyles;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.useDocusTheme = void 0;
|
|
21
|
+
|
|
22
|
+
var _helpers = require("./helpers");
|
|
23
|
+
|
|
24
|
+
var _navigation = require("./navigation");
|
|
25
|
+
|
|
26
|
+
var _style = require("./style");
|
|
27
|
+
|
|
28
|
+
var _app = require("#app");
|
|
29
|
+
|
|
30
|
+
var StateTypes;
|
|
31
|
+
exports.StateTypes = StateTypes;
|
|
32
|
+
|
|
33
|
+
(function (StateTypes2) {
|
|
34
|
+
StateTypes2["Config"] = "docus-config";
|
|
35
|
+
StateTypes2["Theme"] = "docus-theme";
|
|
36
|
+
StateTypes2["Layout"] = "docus-layout";
|
|
37
|
+
StateTypes2["CurrentPage"] = "docus-current-page";
|
|
38
|
+
StateTypes2["Navigation"] = "docus-navigation";
|
|
39
|
+
StateTypes2["CurrentNav"] = "docus-current-nav";
|
|
40
|
+
StateTypes2["CurrentPath"] = "docus-current-path";
|
|
41
|
+
})(StateTypes || (exports.StateTypes = StateTypes = {}));
|
|
42
|
+
|
|
43
|
+
const createDocus = (nuxtApp, _config) => {
|
|
44
|
+
const $nuxt = nuxtApp.nuxt2Context.app;
|
|
45
|
+
const docusConfig = (0, _app.useState)(StateTypes.Config, () => ({ ..._config.docusConfig,
|
|
46
|
+
preview: (0, _helpers.detectPreview)($nuxt.context)
|
|
47
|
+
}));
|
|
48
|
+
if (docusConfig.value.preview) $nuxt.$content = $nuxt.$content.preview(docusConfig.value.preview);
|
|
49
|
+
const docusTheme = (0, _app.useState)(StateTypes.Theme, () => ({ ..._config.themeConfig
|
|
50
|
+
}));
|
|
51
|
+
const docusLayout = (0, _app.useState)(StateTypes.Layout, () => _config.themeConfig?.layout || {});
|
|
52
|
+
const docusCurrentPage = (0, _app.useState)(StateTypes.CurrentPage);
|
|
53
|
+
(0, _style.createDocusStyles)($nuxt.context);
|
|
54
|
+
(0, _helpers.clientAsyncData)($nuxt);
|
|
55
|
+
(0, _navigation.createDocusNavigation)($nuxt.context, docusConfig, $nuxt.$content);
|
|
56
|
+
const $docus = {
|
|
57
|
+
config: docusConfig,
|
|
58
|
+
content: $nuxt.$content,
|
|
59
|
+
theme: docusTheme,
|
|
60
|
+
layout: docusLayout,
|
|
61
|
+
page: docusCurrentPage,
|
|
62
|
+
navigation: (0, _navigation.useDocusNavigation)()
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
$docus,
|
|
66
|
+
init: async () => {
|
|
67
|
+
await $docus.navigation.fetchNavigation();
|
|
68
|
+
$docus.navigation.updateCurrentNav();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.createDocus = createDocus;
|
|
74
|
+
|
|
75
|
+
const useDocus = () => ({
|
|
76
|
+
content: (0, _app.useNuxtApp)().vue2App.$content,
|
|
77
|
+
config: (0, _app.useState)(StateTypes.Config),
|
|
78
|
+
theme: (0, _app.useState)(StateTypes.Theme),
|
|
79
|
+
layout: (0, _app.useState)(StateTypes.Layout),
|
|
80
|
+
page: (0, _app.useState)(StateTypes.CurrentPage),
|
|
81
|
+
navigation: (0, _navigation.useDocusNavigation)()
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
exports.useDocus = useDocus;
|
|
85
|
+
|
|
86
|
+
const useDocusContent = () => {
|
|
87
|
+
const $content = (0, _app.useNuxtApp)().vue2App.$content;
|
|
88
|
+
const preview = (0, _app.useState)(StateTypes.Config).value.preview || false;
|
|
89
|
+
return preview ? $content.preview((0, _helpers.normalizePreviewScope)(preview)) : $content;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.useDocusContent = useDocusContent;
|
|
93
|
+
|
|
94
|
+
const useDocusConfig = () => (0, _app.useState)(StateTypes.Config);
|
|
95
|
+
|
|
96
|
+
exports.useDocusConfig = useDocusConfig;
|
|
97
|
+
|
|
98
|
+
const useDocusTheme = () => (0, _app.useState)(StateTypes.Theme);
|
|
99
|
+
|
|
100
|
+
exports.useDocusTheme = useDocusTheme;
|
|
101
|
+
|
|
102
|
+
const useDocusLayout = () => (0, _app.useState)(StateTypes.Layout);
|
|
103
|
+
|
|
104
|
+
exports.useDocusLayout = useDocusLayout;
|
|
105
|
+
|
|
106
|
+
const useDocusPage = () => (0, _app.useState)(StateTypes.CurrentPage);
|
|
107
|
+
|
|
108
|
+
exports.useDocusPage = useDocusPage;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { clientAsyncData, detectPreview, normalizePreviewScope } from "./helpers.mjs";
|
|
2
|
+
import { createDocusNavigation, useDocusNavigation } from "./navigation.mjs";
|
|
3
|
+
import { createDocusStyles } from "./style.mjs";
|
|
4
|
+
import { useNuxtApp, useState } from "#app";
|
|
5
|
+
export { useDocusStyles } from "./style.mjs";
|
|
6
|
+
export var StateTypes;
|
|
7
|
+
(function(StateTypes2) {
|
|
8
|
+
StateTypes2["Config"] = "docus-config";
|
|
9
|
+
StateTypes2["Theme"] = "docus-theme";
|
|
10
|
+
StateTypes2["Layout"] = "docus-layout";
|
|
11
|
+
StateTypes2["CurrentPage"] = "docus-current-page";
|
|
12
|
+
StateTypes2["Navigation"] = "docus-navigation";
|
|
13
|
+
StateTypes2["CurrentNav"] = "docus-current-nav";
|
|
14
|
+
StateTypes2["CurrentPath"] = "docus-current-path";
|
|
15
|
+
})(StateTypes || (StateTypes = {}));
|
|
16
|
+
export const createDocus = (nuxtApp, _config) => {
|
|
17
|
+
const $nuxt = nuxtApp.nuxt2Context.app;
|
|
18
|
+
const docusConfig = useState(StateTypes.Config, () => ({
|
|
19
|
+
..._config.docusConfig,
|
|
20
|
+
preview: detectPreview($nuxt.context)
|
|
21
|
+
}));
|
|
22
|
+
if (docusConfig.value.preview)
|
|
23
|
+
$nuxt.$content = $nuxt.$content.preview(docusConfig.value.preview);
|
|
24
|
+
const docusTheme = useState(StateTypes.Theme, () => ({ ..._config.themeConfig }));
|
|
25
|
+
const docusLayout = useState(StateTypes.Layout, () => _config.themeConfig?.layout || {});
|
|
26
|
+
const docusCurrentPage = useState(StateTypes.CurrentPage);
|
|
27
|
+
createDocusStyles($nuxt.context);
|
|
28
|
+
clientAsyncData($nuxt);
|
|
29
|
+
createDocusNavigation($nuxt.context, docusConfig, $nuxt.$content);
|
|
30
|
+
const $docus = {
|
|
31
|
+
config: docusConfig,
|
|
32
|
+
content: $nuxt.$content,
|
|
33
|
+
theme: docusTheme,
|
|
34
|
+
layout: docusLayout,
|
|
35
|
+
page: docusCurrentPage,
|
|
36
|
+
navigation: useDocusNavigation()
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
$docus,
|
|
40
|
+
init: async () => {
|
|
41
|
+
await $docus.navigation.fetchNavigation();
|
|
42
|
+
$docus.navigation.updateCurrentNav();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const useDocus = () => ({
|
|
47
|
+
content: useNuxtApp().vue2App.$content,
|
|
48
|
+
config: useState(StateTypes.Config),
|
|
49
|
+
theme: useState(StateTypes.Theme),
|
|
50
|
+
layout: useState(StateTypes.Layout),
|
|
51
|
+
page: useState(StateTypes.CurrentPage),
|
|
52
|
+
navigation: useDocusNavigation()
|
|
53
|
+
});
|
|
54
|
+
export const useDocusContent = () => {
|
|
55
|
+
const $content = useNuxtApp().vue2App.$content;
|
|
56
|
+
const preview = useState(StateTypes.Config).value.preview || false;
|
|
57
|
+
return preview ? $content.preview(normalizePreviewScope(preview)) : $content;
|
|
58
|
+
};
|
|
59
|
+
export const useDocusConfig = () => useState(StateTypes.Config);
|
|
60
|
+
export const useDocusTheme = () => useState(StateTypes.Theme);
|
|
61
|
+
export const useDocusLayout = () => useState(StateTypes.Layout);
|
|
62
|
+
export const useDocusPage = () => useState(StateTypes.CurrentPage);
|
|
63
|
+
export { useDocusNavigation } from "./navigation.mjs";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Context } from '@nuxt/types';
|
|
2
|
+
import type { NavItem } from 'types';
|
|
3
|
+
/**
|
|
4
|
+
* Handling all the navigation querying logic.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createDocusNavigation: (context: Context, config: Ref<DocusConfig>, content: DocusContent<any>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Access the navigation state and helpers.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useDocusNavigation: () => {
|
|
11
|
+
state: Ref<DocusNavigationState>;
|
|
12
|
+
currentNav: Ref<DocusCurrentNav>;
|
|
13
|
+
currentPath: Ref<string>;
|
|
14
|
+
getPageTemplate: (page: DocusDocument) => string;
|
|
15
|
+
fetchNavigation: (locale?: string) => Promise<void>;
|
|
16
|
+
isLinkActive: (to: string) => boolean;
|
|
17
|
+
updateCurrentNav: () => void;
|
|
18
|
+
getPreviousAndNextLink: (page: DocusDocument) => Promise<any>;
|
|
19
|
+
get: (params: DocusNavigationGetParameters) => {
|
|
20
|
+
title: string | undefined;
|
|
21
|
+
to: string | undefined;
|
|
22
|
+
parent: NavItem | undefined;
|
|
23
|
+
links: any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Access the navigation state.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useDocusNavigationState: () => Ref<DocusNavigationState>;
|
|
30
|
+
/**
|
|
31
|
+
* Access the current navigation.
|
|
32
|
+
*/
|
|
33
|
+
export declare const useDocusCurrentNav: () => Ref<DocusCurrentNav>;
|
|
34
|
+
/**
|
|
35
|
+
* Access the current path.
|
|
36
|
+
*/
|
|
37
|
+
export declare const useDocusCurrentPath: () => Ref<string>;
|