docus 2.1.0 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +23 -0
- package/components/app/Footer.vue +38 -0
- package/components/app/Navbar.vue +26 -0
- package/components/app/NavbarLogo.vue +31 -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 +44 -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 +134 -0
- package/components/content/CopyButton.vue +48 -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 +24 -0
- package/components/content/Sandbox.vue +100 -0
- package/components/content/TabsHeader.vue +44 -0
- package/components/content/Terminal.vue +70 -0
- package/components/content/VideoPlayer.vue +113 -0
- package/components/docs/DocsAside.vue +19 -0
- package/components/docs/DocsAsideTree.vue +101 -0
- package/components/docs/DocsHero.vue +39 -0
- package/components/docs/DocsPage.vue +22 -0
- package/components/docs/DocsPageContent.vue +29 -0
- package/components/docs/DocsToc.vue +72 -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 +43 -0
- package/components/globals/SocialIcons.vue +43 -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 +32 -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 +155 -0
- package/composables/useMenu.ts +20 -0
- package/composables/useScrollToHeading.ts +35 -0
- package/composables/useScrollspy.ts +45 -0
- package/composables/useTheme.ts +10 -0
- package/layouts/default.vue +27 -0
- package/layouts/page.vue +11 -0
- package/nuxt.config.ts +151 -0
- package/package.json +46 -83
- package/pages/[...slug].vue +24 -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,46 +0,0 @@
|
|
|
1
|
-
import type { Storage } from 'unstorage';
|
|
2
|
-
import type { MDCRoot } from 'types';
|
|
3
|
-
interface DocusContent {
|
|
4
|
-
body: MDCRoot;
|
|
5
|
-
meta: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
export declare const contentStorage: Storage;
|
|
8
|
-
export declare const buildStorage: Storage;
|
|
9
|
-
export declare const previewStorage: Storage;
|
|
10
|
-
/**
|
|
11
|
-
* Read content form source file, generate and cache the content
|
|
12
|
-
*
|
|
13
|
-
* @param id Content ID
|
|
14
|
-
* @param previewKey Preview id
|
|
15
|
-
* @returns Transformed content
|
|
16
|
-
*/
|
|
17
|
-
export declare function buildContent(id: string, previewKey?: string): Promise<DocusContent>;
|
|
18
|
-
/**
|
|
19
|
-
* Return transformed conntent if it exists in cache or build it on demand
|
|
20
|
-
*
|
|
21
|
-
* @param id Content ID
|
|
22
|
-
* @param previewKey Preview ID
|
|
23
|
-
* @returns Transformed content
|
|
24
|
-
*/
|
|
25
|
-
export declare function getContent(id: string, previewKey?: string): Promise<DocusContent>;
|
|
26
|
-
/**
|
|
27
|
-
* Find list of contents
|
|
28
|
-
*
|
|
29
|
-
* @param id Base if for lookup
|
|
30
|
-
* @param previewKey Preview ID
|
|
31
|
-
* @returns List of content in given base path
|
|
32
|
-
*/
|
|
33
|
-
export declare function getList(id?: string, previewKey?: string): Promise<{
|
|
34
|
-
id: string;
|
|
35
|
-
}[]>;
|
|
36
|
-
/**
|
|
37
|
-
* Search content database for a given query
|
|
38
|
-
*
|
|
39
|
-
* @param to Base path for search
|
|
40
|
-
* @param body Search options
|
|
41
|
-
* @param previewKey Preview ID
|
|
42
|
-
* @returns Single content of list of contents that matchs the search
|
|
43
|
-
*/
|
|
44
|
-
export declare function searchContent(to: string, body: any, previewKey?: string): Promise<any>;
|
|
45
|
-
export declare const getNavigation: (previewKey?: string) => Promise<any>;
|
|
46
|
-
export {};
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.buildContent = buildContent;
|
|
7
|
-
exports.contentStorage = exports.buildStorage = void 0;
|
|
8
|
-
exports.getContent = getContent;
|
|
9
|
-
exports.getList = getList;
|
|
10
|
-
exports.previewStorage = exports.getNavigation = void 0;
|
|
11
|
-
exports.searchContent = searchContent;
|
|
12
|
-
|
|
13
|
-
var _unstorage = require("unstorage");
|
|
14
|
-
|
|
15
|
-
var _micromatch = _interopRequireDefault(require("micromatch"));
|
|
16
|
-
|
|
17
|
-
var _transformers = require("../transformers");
|
|
18
|
-
|
|
19
|
-
var _database = require("../database");
|
|
20
|
-
|
|
21
|
-
var _navigation = require("../navigation");
|
|
22
|
-
|
|
23
|
-
var _context = require("../context");
|
|
24
|
-
|
|
25
|
-
var _cache = require("./utils/cache");
|
|
26
|
-
|
|
27
|
-
var _storage = require("#storage");
|
|
28
|
-
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
|
|
31
|
-
function prefixStorage(storage2, base) {
|
|
32
|
-
const nsStorage = (0, _unstorage.prefixStorage)(storage2, base);
|
|
33
|
-
const prefixRegex = new RegExp(`^${base}:`);
|
|
34
|
-
|
|
35
|
-
nsStorage.getKeys = (id = "") => {
|
|
36
|
-
return storage2.getKeys(base + ":" + id).then(keys => keys.map(key => key.replace(prefixRegex, "")));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return nsStorage;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const contentStorage = prefixStorage(_storage.storage, "docus:source");
|
|
43
|
-
exports.contentStorage = contentStorage;
|
|
44
|
-
const buildStorage = prefixStorage(_storage.storage, "assets:docus:build");
|
|
45
|
-
exports.buildStorage = buildStorage;
|
|
46
|
-
const previewStorage = prefixStorage(_storage.storage, "docus:preview");
|
|
47
|
-
exports.previewStorage = previewStorage;
|
|
48
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
49
|
-
|
|
50
|
-
const withCache = (name, fn) => isProduction ? (0, _cache.cachify)(fn, {
|
|
51
|
-
name,
|
|
52
|
-
swr: true,
|
|
53
|
-
ttl: 6e4,
|
|
54
|
-
integrity: "docus"
|
|
55
|
-
}) : fn;
|
|
56
|
-
|
|
57
|
-
async function getData(id, previewKey) {
|
|
58
|
-
let body;
|
|
59
|
-
let meta;
|
|
60
|
-
|
|
61
|
-
if (previewKey) {
|
|
62
|
-
body = await previewStorage.getItem(`${previewKey}:${id}`);
|
|
63
|
-
meta = await previewStorage.getMeta(`${previewKey}:${id}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!body) {
|
|
67
|
-
body = await contentStorage.getItem(id);
|
|
68
|
-
meta = await contentStorage.getMeta(id);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (body && typeof body === "object") {
|
|
72
|
-
body = JSON.stringify(typeof body.default !== "undefined" ? body.default : body);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (typeof body !== "string") {
|
|
76
|
-
body = body + "";
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
body,
|
|
81
|
-
meta
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const getContentKeys = async id => {
|
|
86
|
-
let keys = await buildStorage.getKeys(id);
|
|
87
|
-
|
|
88
|
-
if (keys.length === 0) {
|
|
89
|
-
keys = await contentStorage.getKeys(id);
|
|
90
|
-
const context = (0, _context.useDocusContext)();
|
|
91
|
-
keys = _micromatch.default.not(keys, context?.ignoreList || []);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return keys;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const getPreviewKeys = async (id, previewKey) => {
|
|
98
|
-
let keys = (await previewStorage.getKeys(id ? `${previewKey}:${id}` : previewKey)).map(key => key.replace(`${previewKey}:`, ""));
|
|
99
|
-
const context = (0, _context.useDocusContext)();
|
|
100
|
-
keys = _micromatch.default.not(keys, context?.ignoreList || []);
|
|
101
|
-
return keys;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
async function getKeys(id, previewKey) {
|
|
105
|
-
let keys = await getContentKeys(id);
|
|
106
|
-
|
|
107
|
-
if (previewKey) {
|
|
108
|
-
const previewKeys = await getPreviewKeys(id, previewKey);
|
|
109
|
-
keys = keys.filter(key => !previewKeys.includes(key));
|
|
110
|
-
keys.push(...previewKeys);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return keys;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function buildContent(id, previewKey) {
|
|
117
|
-
const data = await getData(id, previewKey);
|
|
118
|
-
|
|
119
|
-
if (typeof data.body === "undefined" || data.body === null) {
|
|
120
|
-
throw new Error(`Content not found: ${id}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const transformResult = await (0, _transformers.getTransformer)(id)(id, data.body);
|
|
124
|
-
const content = {
|
|
125
|
-
meta: { ...data.meta,
|
|
126
|
-
...transformResult.meta
|
|
127
|
-
},
|
|
128
|
-
body: transformResult.body
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
if (!previewKey) {
|
|
132
|
-
await buildStorage.setItem(id, content);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return content;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function getContent(id, previewKey) {
|
|
139
|
-
let content = !previewKey && (await buildStorage.getItem(id));
|
|
140
|
-
|
|
141
|
-
if (!content) {
|
|
142
|
-
content = await buildContent(id, previewKey);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return content;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function getList(id, previewKey) {
|
|
149
|
-
const keys = await getKeys(id, previewKey);
|
|
150
|
-
return Promise.all(keys.map(async key => {
|
|
151
|
-
const content = await getContent(key, previewKey);
|
|
152
|
-
return {
|
|
153
|
-
id: key,
|
|
154
|
-
...content.meta
|
|
155
|
-
};
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async function searchContent(to, body, previewKey) {
|
|
160
|
-
const navigation = await getNavigation(previewKey);
|
|
161
|
-
const db = await (0, _database.createDatabase)(navigation);
|
|
162
|
-
return db.search(to, body);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const getNavigationCached = withCache("navigation", async () => (0, _navigation.generateNavigation)(await getList()));
|
|
166
|
-
|
|
167
|
-
const getNavigation = async previewKey => {
|
|
168
|
-
if (!previewKey) {
|
|
169
|
-
return getNavigationCached();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return (0, _navigation.generateNavigation)(await getList(void 0, previewKey));
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
exports.getNavigation = getNavigation;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { prefixStorage as unstoragePrefixStorage } from "unstorage";
|
|
2
|
-
import micromatch from "micromatch";
|
|
3
|
-
import { getTransformer } from "../transformers/index.mjs";
|
|
4
|
-
import { createDatabase } from "../database/index.mjs";
|
|
5
|
-
import { generateNavigation } from "../navigation.mjs";
|
|
6
|
-
import { useDocusContext } from "../context.mjs";
|
|
7
|
-
import { cachify } from "./utils/cache.mjs";
|
|
8
|
-
import { storage } from "#storage";
|
|
9
|
-
function prefixStorage(storage2, base) {
|
|
10
|
-
const nsStorage = unstoragePrefixStorage(storage2, base);
|
|
11
|
-
const prefixRegex = new RegExp(`^${base}:`);
|
|
12
|
-
nsStorage.getKeys = (id = "") => {
|
|
13
|
-
return storage2.getKeys(base + ":" + id).then((keys) => keys.map((key) => key.replace(prefixRegex, "")));
|
|
14
|
-
};
|
|
15
|
-
return nsStorage;
|
|
16
|
-
}
|
|
17
|
-
export const contentStorage = prefixStorage(storage, "docus:source");
|
|
18
|
-
export const buildStorage = prefixStorage(storage, "assets:docus:build");
|
|
19
|
-
export const previewStorage = prefixStorage(storage, "docus:preview");
|
|
20
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
21
|
-
const withCache = (name, fn) => isProduction ? cachify(fn, { name, swr: true, ttl: 6e4, integrity: "docus" }) : fn;
|
|
22
|
-
async function getData(id, previewKey) {
|
|
23
|
-
let body;
|
|
24
|
-
let meta;
|
|
25
|
-
if (previewKey) {
|
|
26
|
-
body = await previewStorage.getItem(`${previewKey}:${id}`);
|
|
27
|
-
meta = await previewStorage.getMeta(`${previewKey}:${id}`);
|
|
28
|
-
}
|
|
29
|
-
if (!body) {
|
|
30
|
-
body = await contentStorage.getItem(id);
|
|
31
|
-
meta = await contentStorage.getMeta(id);
|
|
32
|
-
}
|
|
33
|
-
if (body && typeof body === "object") {
|
|
34
|
-
body = JSON.stringify(typeof body.default !== "undefined" ? body.default : body);
|
|
35
|
-
}
|
|
36
|
-
if (typeof body !== "string") {
|
|
37
|
-
body = body + "";
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
body,
|
|
41
|
-
meta
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const getContentKeys = async (id) => {
|
|
45
|
-
let keys = await buildStorage.getKeys(id);
|
|
46
|
-
if (keys.length === 0) {
|
|
47
|
-
keys = await contentStorage.getKeys(id);
|
|
48
|
-
const context = useDocusContext();
|
|
49
|
-
keys = micromatch.not(keys, context?.ignoreList || []);
|
|
50
|
-
}
|
|
51
|
-
return keys;
|
|
52
|
-
};
|
|
53
|
-
const getPreviewKeys = async (id, previewKey) => {
|
|
54
|
-
let keys = (await previewStorage.getKeys(id ? `${previewKey}:${id}` : previewKey)).map((key) => key.replace(`${previewKey}:`, ""));
|
|
55
|
-
const context = useDocusContext();
|
|
56
|
-
keys = micromatch.not(keys, context?.ignoreList || []);
|
|
57
|
-
return keys;
|
|
58
|
-
};
|
|
59
|
-
async function getKeys(id, previewKey) {
|
|
60
|
-
let keys = await getContentKeys(id);
|
|
61
|
-
if (previewKey) {
|
|
62
|
-
const previewKeys = await getPreviewKeys(id, previewKey);
|
|
63
|
-
keys = keys.filter((key) => !previewKeys.includes(key));
|
|
64
|
-
keys.push(...previewKeys);
|
|
65
|
-
}
|
|
66
|
-
return keys;
|
|
67
|
-
}
|
|
68
|
-
export async function buildContent(id, previewKey) {
|
|
69
|
-
const data = await getData(id, previewKey);
|
|
70
|
-
if (typeof data.body === "undefined" || data.body === null) {
|
|
71
|
-
throw new Error(`Content not found: ${id}`);
|
|
72
|
-
}
|
|
73
|
-
const transformResult = await getTransformer(id)(id, data.body);
|
|
74
|
-
const content = {
|
|
75
|
-
meta: {
|
|
76
|
-
...data.meta,
|
|
77
|
-
...transformResult.meta
|
|
78
|
-
},
|
|
79
|
-
body: transformResult.body
|
|
80
|
-
};
|
|
81
|
-
if (!previewKey) {
|
|
82
|
-
await buildStorage.setItem(id, content);
|
|
83
|
-
}
|
|
84
|
-
return content;
|
|
85
|
-
}
|
|
86
|
-
export async function getContent(id, previewKey) {
|
|
87
|
-
let content = !previewKey && await buildStorage.getItem(id);
|
|
88
|
-
if (!content) {
|
|
89
|
-
content = await buildContent(id, previewKey);
|
|
90
|
-
}
|
|
91
|
-
return content;
|
|
92
|
-
}
|
|
93
|
-
export async function getList(id, previewKey) {
|
|
94
|
-
const keys = await getKeys(id, previewKey);
|
|
95
|
-
return Promise.all(keys.map(async (key) => {
|
|
96
|
-
const content = await getContent(key, previewKey);
|
|
97
|
-
return {
|
|
98
|
-
id: key,
|
|
99
|
-
...content.meta
|
|
100
|
-
};
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
export async function searchContent(to, body, previewKey) {
|
|
104
|
-
const navigation = await getNavigation(previewKey);
|
|
105
|
-
const db = await createDatabase(navigation);
|
|
106
|
-
return db.search(to, body);
|
|
107
|
-
}
|
|
108
|
-
const getNavigationCached = withCache("navigation", async () => generateNavigation(await getList()));
|
|
109
|
-
export const getNavigation = async (previewKey) => {
|
|
110
|
-
if (!previewKey) {
|
|
111
|
-
return getNavigationCached();
|
|
112
|
-
}
|
|
113
|
-
return generateNavigation(await getList(void 0, previewKey));
|
|
114
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { IncomingMessage } from 'http';
|
|
3
|
-
/**
|
|
4
|
-
* WebSocket server useful for live content reload.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useWebSocket(): {
|
|
7
|
-
serve: (req: IncomingMessage, socket?: import("net").Socket, head?: any) => void;
|
|
8
|
-
broadcast: (data: any) => void;
|
|
9
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useWebSocket = useWebSocket;
|
|
7
|
-
|
|
8
|
-
var _ws = require("ws");
|
|
9
|
-
|
|
10
|
-
let wss;
|
|
11
|
-
|
|
12
|
-
function useWebSocket() {
|
|
13
|
-
if (!wss) wss = new _ws.Server({
|
|
14
|
-
noServer: true
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const serve = (req, socket = req.socket, head = "") => wss.handleUpgrade(req, socket, head, client => wss.emit("connection", client, req));
|
|
18
|
-
|
|
19
|
-
const broadcast = data => {
|
|
20
|
-
data = JSON.stringify(data);
|
|
21
|
-
|
|
22
|
-
for (const client of wss.clients) {
|
|
23
|
-
try {
|
|
24
|
-
client.send(data);
|
|
25
|
-
} catch (err) {}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
serve,
|
|
31
|
-
broadcast
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Server } from "ws";
|
|
2
|
-
let wss;
|
|
3
|
-
export function useWebSocket() {
|
|
4
|
-
if (!wss)
|
|
5
|
-
wss = new Server({ noServer: true });
|
|
6
|
-
const serve = (req, socket = req.socket, head = "") => wss.handleUpgrade(req, socket, head, (client) => wss.emit("connection", client, req));
|
|
7
|
-
const broadcast = (data) => {
|
|
8
|
-
data = JSON.stringify(data);
|
|
9
|
-
for (const client of wss.clients) {
|
|
10
|
-
try {
|
|
11
|
-
client.send(data);
|
|
12
|
-
} catch (err) {
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
serve,
|
|
18
|
-
broadcast
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Handle } from 'h3';
|
|
2
|
-
export interface CacheEntry {
|
|
3
|
-
value?: any;
|
|
4
|
-
expires?: number;
|
|
5
|
-
mtime?: number;
|
|
6
|
-
integrity?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface CachifyOptions {
|
|
9
|
-
name: string;
|
|
10
|
-
getKey?: (...args: any[]) => string;
|
|
11
|
-
transform?: (entry: CacheEntry, ...args: any[]) => any;
|
|
12
|
-
group?: string;
|
|
13
|
-
integrity?: any;
|
|
14
|
-
ttl?: number;
|
|
15
|
-
swr?: boolean;
|
|
16
|
-
base?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare function cachify(fn: (...args: any[]) => any, opts: CachifyOptions): (...args: any[]) => Promise<any>;
|
|
19
|
-
export declare function cachifyHandle(handle: Handle, opts: Omit<CachifyOptions, 'getKey'>): (...args: any[]) => Promise<any>;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cachify = cachify;
|
|
7
|
-
exports.cachifyHandle = cachifyHandle;
|
|
8
|
-
|
|
9
|
-
var _murmurhashEs = require("murmurhash-es");
|
|
10
|
-
|
|
11
|
-
var _storage = require("#storage");
|
|
12
|
-
|
|
13
|
-
function cachify(fn, opts) {
|
|
14
|
-
const pending = {};
|
|
15
|
-
opts.base = process.env.NODE_ENV === "development" ? "/root/node_modules/.cache/cachify" : "/cache";
|
|
16
|
-
const group = opts.group || "";
|
|
17
|
-
const name = opts.name || fn.name || "_";
|
|
18
|
-
const integrity = (0, _murmurhashEs.murmurHashV3)(JSON.stringify(opts.integrity || fn)) + "-" + name;
|
|
19
|
-
|
|
20
|
-
async function get(key, resolver) {
|
|
21
|
-
const cacheKey = [opts.base, group, name, key].filter(Boolean).join(":");
|
|
22
|
-
const entry = (await _storage.storage.getItem(cacheKey)) || {};
|
|
23
|
-
const ttl = (opts.ttl ?? opts.ttl ?? 0) * 1e3;
|
|
24
|
-
|
|
25
|
-
if (ttl) {
|
|
26
|
-
entry.expires = Date.now() + ttl;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const expired = entry.integrity !== integrity || ttl && Date.now() - (entry.mtime || 0) > ttl;
|
|
30
|
-
|
|
31
|
-
const _resolve = async () => {
|
|
32
|
-
if (!pending[key]) {
|
|
33
|
-
pending[key] = resolver();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
entry.value = await pending[key];
|
|
37
|
-
entry.mtime = Date.now();
|
|
38
|
-
entry.integrity = integrity;
|
|
39
|
-
delete pending[key];
|
|
40
|
-
|
|
41
|
-
_storage.storage.setItem(cacheKey, entry).catch(console.error);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const _resolvePromise = expired ? _resolve() : Promise.resolve();
|
|
45
|
-
|
|
46
|
-
if (opts.swr && entry.value) {
|
|
47
|
-
_resolvePromise.catch(console.error);
|
|
48
|
-
|
|
49
|
-
return Promise.resolve(entry);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return _resolvePromise.then(() => entry);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return async (...args) => {
|
|
56
|
-
const key = (opts.getKey || getKey)(...args);
|
|
57
|
-
const entry = await get(key, () => fn(...args));
|
|
58
|
-
let value = entry.value;
|
|
59
|
-
|
|
60
|
-
if (opts.transform) {
|
|
61
|
-
value = (await opts.transform(entry, ...args)) || value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return value;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function getKey(...args) {
|
|
69
|
-
return "args" + (0, _murmurhashEs.murmurHashV3)(JSON.stringify(args));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function cachifyHandle(handle, opts) {
|
|
73
|
-
const _opts = {
|
|
74
|
-
getKey: req => req.originalUrl || req.url,
|
|
75
|
-
|
|
76
|
-
transform(entry, _req, res) {
|
|
77
|
-
for (const header in entry.value.headers) {
|
|
78
|
-
res.setHeader(header, entry.value.headers[header]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const cacheControl = [];
|
|
82
|
-
|
|
83
|
-
if (opts.swr) {
|
|
84
|
-
if (opts.ttl) {
|
|
85
|
-
cacheControl.push(`s-maxage=${opts.ttl / 1e3}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
cacheControl.push("stale-while-revalidate");
|
|
89
|
-
} else if (opts.ttl) {
|
|
90
|
-
cacheControl.push(`max-age=${opts.ttl / 1e3}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (cacheControl.length) {
|
|
94
|
-
res.setHeader("Cache-Control", cacheControl.join(", "));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return entry.value.body;
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
...opts
|
|
101
|
-
};
|
|
102
|
-
return cachify(async (req, res) => {
|
|
103
|
-
const body = await handle(req, res);
|
|
104
|
-
const headers = res.getHeaders();
|
|
105
|
-
return {
|
|
106
|
-
body,
|
|
107
|
-
headers
|
|
108
|
-
};
|
|
109
|
-
}, _opts);
|
|
110
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { murmurHashV3 } from "murmurhash-es";
|
|
2
|
-
import { storage } from "#storage";
|
|
3
|
-
export function cachify(fn, opts) {
|
|
4
|
-
const pending = {};
|
|
5
|
-
opts.base = process.env.NODE_ENV === "development" ? "/root/node_modules/.cache/cachify" : "/cache";
|
|
6
|
-
const group = opts.group || "";
|
|
7
|
-
const name = opts.name || fn.name || "_";
|
|
8
|
-
const integrity = murmurHashV3(JSON.stringify(opts.integrity || fn)) + "-" + name;
|
|
9
|
-
async function get(key, resolver) {
|
|
10
|
-
const cacheKey = [opts.base, group, name, key].filter(Boolean).join(":");
|
|
11
|
-
const entry = await storage.getItem(cacheKey) || {};
|
|
12
|
-
const ttl = (opts.ttl ?? opts.ttl ?? 0) * 1e3;
|
|
13
|
-
if (ttl) {
|
|
14
|
-
entry.expires = Date.now() + ttl;
|
|
15
|
-
}
|
|
16
|
-
const expired = entry.integrity !== integrity || ttl && Date.now() - (entry.mtime || 0) > ttl;
|
|
17
|
-
const _resolve = async () => {
|
|
18
|
-
if (!pending[key]) {
|
|
19
|
-
pending[key] = resolver();
|
|
20
|
-
}
|
|
21
|
-
entry.value = await pending[key];
|
|
22
|
-
entry.mtime = Date.now();
|
|
23
|
-
entry.integrity = integrity;
|
|
24
|
-
delete pending[key];
|
|
25
|
-
storage.setItem(cacheKey, entry).catch(console.error);
|
|
26
|
-
};
|
|
27
|
-
const _resolvePromise = expired ? _resolve() : Promise.resolve();
|
|
28
|
-
if (opts.swr && entry.value) {
|
|
29
|
-
_resolvePromise.catch(console.error);
|
|
30
|
-
return Promise.resolve(entry);
|
|
31
|
-
}
|
|
32
|
-
return _resolvePromise.then(() => entry);
|
|
33
|
-
}
|
|
34
|
-
return async (...args) => {
|
|
35
|
-
const key = (opts.getKey || getKey)(...args);
|
|
36
|
-
const entry = await get(key, () => fn(...args));
|
|
37
|
-
let value = entry.value;
|
|
38
|
-
if (opts.transform) {
|
|
39
|
-
value = await opts.transform(entry, ...args) || value;
|
|
40
|
-
}
|
|
41
|
-
return value;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function getKey(...args) {
|
|
45
|
-
return "args" + murmurHashV3(JSON.stringify(args));
|
|
46
|
-
}
|
|
47
|
-
export function cachifyHandle(handle, opts) {
|
|
48
|
-
const _opts = {
|
|
49
|
-
getKey: (req) => req.originalUrl || req.url,
|
|
50
|
-
transform(entry, _req, res) {
|
|
51
|
-
for (const header in entry.value.headers) {
|
|
52
|
-
res.setHeader(header, entry.value.headers[header]);
|
|
53
|
-
}
|
|
54
|
-
const cacheControl = [];
|
|
55
|
-
if (opts.swr) {
|
|
56
|
-
if (opts.ttl) {
|
|
57
|
-
cacheControl.push(`s-maxage=${opts.ttl / 1e3}`);
|
|
58
|
-
}
|
|
59
|
-
cacheControl.push("stale-while-revalidate");
|
|
60
|
-
} else if (opts.ttl) {
|
|
61
|
-
cacheControl.push(`max-age=${opts.ttl / 1e3}`);
|
|
62
|
-
}
|
|
63
|
-
if (cacheControl.length) {
|
|
64
|
-
res.setHeader("Cache-Control", cacheControl.join(", "));
|
|
65
|
-
}
|
|
66
|
-
return entry.value.body;
|
|
67
|
-
},
|
|
68
|
-
...opts
|
|
69
|
-
};
|
|
70
|
-
return cachify(async (req, res) => {
|
|
71
|
-
const body = await handle(req, res);
|
|
72
|
-
const headers = res.getHeaders();
|
|
73
|
-
return { body, headers };
|
|
74
|
-
}, _opts);
|
|
75
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useKey = useKey;
|
|
7
|
-
exports.usePreview = usePreview;
|
|
8
|
-
|
|
9
|
-
var _h = require("h3");
|
|
10
|
-
|
|
11
|
-
function usePreview(req) {
|
|
12
|
-
const query = (0, _h.useQuery)(req);
|
|
13
|
-
return (query.preview || "").replace(/\//g, ":");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function useKey(req) {
|
|
17
|
-
return (req.url || "").split("?")[0].replace(/^\//, "");
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getTransformer(id: string): (id: string, body: string) => any;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTransformer = getTransformer;
|
|
7
|
-
|
|
8
|
-
var _markdown = _interopRequireDefault(require("./markdown"));
|
|
9
|
-
|
|
10
|
-
var _json = _interopRequireDefault(require("./json"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const transformers = {
|
|
15
|
-
default: (_id = "", body = "") => ({
|
|
16
|
-
body,
|
|
17
|
-
meta: {}
|
|
18
|
-
}),
|
|
19
|
-
".md": _markdown.default,
|
|
20
|
-
".json": _json.default
|
|
21
|
-
};
|
|
22
|
-
const exts = Object.keys(transformers);
|
|
23
|
-
|
|
24
|
-
function getTransformer(id) {
|
|
25
|
-
return transformers[exts.find(ext => id.endsWith(ext)) || "default"];
|
|
26
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import markdown from "./markdown/index.mjs";
|
|
2
|
-
import json from "./json.mjs";
|
|
3
|
-
const transformers = {
|
|
4
|
-
default: (_id = "", body = "") => ({ body, meta: {} }),
|
|
5
|
-
".md": markdown,
|
|
6
|
-
".json": json
|
|
7
|
-
};
|
|
8
|
-
const exts = Object.keys(transformers);
|
|
9
|
-
export function getTransformer(id) {
|
|
10
|
-
return transformers[exts.find((ext) => id.endsWith(ext)) || "default"];
|
|
11
|
-
}
|