@btst/stack 1.0.0 → 1.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/README.md +237 -2
- package/dist/api/index.cjs +2 -2
- package/dist/api/index.d.cts +2 -2
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.mjs +2 -2
- package/dist/client/components/compose.cjs +68 -0
- package/dist/client/components/compose.mjs +65 -0
- package/dist/client/components/error-boundary.cjs +24 -0
- package/dist/client/components/error-boundary.mjs +22 -0
- package/dist/client/components/index.cjs +10 -0
- package/dist/client/components/index.d.cts +52 -0
- package/dist/client/components/index.d.mts +52 -0
- package/dist/client/components/index.d.ts +52 -0
- package/dist/client/components/index.mjs +2 -0
- package/dist/client/index.cjs +21 -16
- package/dist/client/index.d.cts +102 -14
- package/dist/client/index.d.mts +102 -14
- package/dist/client/index.d.ts +102 -14
- package/dist/client/index.mjs +19 -10
- package/dist/client/meta-utils.cjs +162 -0
- package/dist/client/meta-utils.mjs +160 -0
- package/dist/client/sitemap-utils.cjs +14 -0
- package/dist/client/sitemap-utils.mjs +12 -0
- package/dist/context/index.cjs +6 -51
- package/dist/context/index.d.cts +26 -26
- package/dist/context/index.d.mts +26 -26
- package/dist/context/index.d.ts +26 -26
- package/dist/context/index.mjs +1 -50
- package/dist/context/provider.cjs +51 -0
- package/dist/context/provider.mjs +46 -0
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +0 -2
- package/dist/plugins/api/index.cjs +15 -0
- package/dist/plugins/api/index.d.cts +41 -0
- package/dist/plugins/api/index.d.mts +41 -0
- package/dist/plugins/api/index.d.ts +41 -0
- package/dist/plugins/api/index.mjs +9 -0
- package/dist/plugins/blog/api/index.cjs +11 -0
- package/dist/plugins/blog/api/index.d.cts +7 -0
- package/dist/plugins/blog/api/index.d.mts +7 -0
- package/dist/plugins/blog/api/index.d.ts +7 -0
- package/dist/plugins/blog/api/index.mjs +2 -0
- package/dist/plugins/blog/api/plugin.cjs +569 -0
- package/dist/plugins/blog/api/plugin.mjs +565 -0
- package/dist/plugins/blog/client/components/forms/image-field.cjs +133 -0
- package/dist/plugins/blog/client/components/forms/image-field.mjs +131 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.cjs +106 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.mjs +104 -0
- package/dist/plugins/blog/client/components/forms/post-forms.cjs +401 -0
- package/dist/plugins/blog/client/components/forms/post-forms.mjs +398 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.cjs +71 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.mjs +65 -0
- package/dist/plugins/blog/client/components/index.cjs +17 -0
- package/dist/plugins/blog/client/components/index.d.cts +22 -0
- package/dist/plugins/blog/client/components/index.d.mts +22 -0
- package/dist/plugins/blog/client/components/index.d.ts +22 -0
- package/dist/plugins/blog/client/components/index.mjs +12 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.cjs +62 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.mjs +60 -0
- package/dist/plugins/blog/client/components/loading/index.cjs +20 -0
- package/dist/plugins/blog/client/components/loading/index.mjs +16 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.cjs +26 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.mjs +24 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.cjs +13 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.mjs +11 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.cjs +22 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.mjs +20 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.cjs +56 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.mjs +54 -0
- package/dist/plugins/blog/client/components/pages/404-page.cjs +19 -0
- package/dist/plugins/blog/client/components/pages/404-page.mjs +17 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.cjs +57 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.mjs +55 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/home-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/home-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.cjs +37 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.cjs +53 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.mjs +51 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.mjs +35 -0
- package/dist/plugins/blog/client/components/pages/post-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.cjs +101 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.mjs +99 -0
- package/dist/plugins/blog/client/components/pages/post-page.mjs +37 -0
- package/dist/plugins/blog/client/components/pages/tag-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/tag-page.mjs +37 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/default-error.cjs +18 -0
- package/dist/plugins/blog/client/components/shared/default-error.mjs +16 -0
- package/dist/plugins/blog/client/components/shared/defaults.cjs +13 -0
- package/dist/plugins/blog/client/components/shared/defaults.mjs +10 -0
- package/dist/plugins/blog/client/components/shared/empty-list.cjs +21 -0
- package/dist/plugins/blog/client/components/shared/empty-list.mjs +19 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.cjs +53 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.mjs +51 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.cjs +324 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.mjs +315 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.cjs +161 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.mjs +158 -0
- package/dist/plugins/blog/client/components/shared/page-header.cjs +40 -0
- package/dist/plugins/blog/client/components/shared/page-header.mjs +38 -0
- package/dist/plugins/blog/client/components/shared/page-layout.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/page-layout.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.cjs +23 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.mjs +21 -0
- package/dist/plugins/blog/client/components/shared/post-card.cjs +279 -0
- package/dist/plugins/blog/client/components/shared/post-card.mjs +277 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.cjs +74 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.mjs +72 -0
- package/dist/plugins/blog/client/components/shared/posts-list.cjs +48 -0
- package/dist/plugins/blog/client/components/shared/posts-list.mjs +46 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.cjs +59 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.mjs +57 -0
- package/dist/plugins/blog/client/components/shared/search-input.cjs +136 -0
- package/dist/plugins/blog/client/components/shared/search-input.mjs +117 -0
- package/dist/plugins/blog/client/components/shared/search-modal.cjs +135 -0
- package/dist/plugins/blog/client/components/shared/search-modal.mjs +116 -0
- package/dist/plugins/blog/client/components/shared/tags-list.cjs +22 -0
- package/dist/plugins/blog/client/components/shared/tags-list.mjs +20 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.cjs +50 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.mjs +48 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.cjs +380 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.mjs +368 -0
- package/dist/plugins/blog/client/hooks/index.cjs +17 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.mts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.ts +150 -0
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/use-debounce.cjs +16 -0
- package/dist/plugins/blog/client/hooks/use-debounce.mjs +14 -0
- package/dist/plugins/blog/client/index.cjs +7 -0
- package/dist/plugins/blog/client/index.d.cts +414 -0
- package/dist/plugins/blog/client/index.d.mts +414 -0
- package/dist/plugins/blog/client/index.d.ts +414 -0
- package/dist/plugins/blog/client/index.mjs +1 -0
- package/dist/plugins/blog/client/localization/blog-card.cjs +7 -0
- package/dist/plugins/blog/client/localization/blog-card.mjs +5 -0
- package/dist/plugins/blog/client/localization/blog-common.cjs +10 -0
- package/dist/plugins/blog/client/localization/blog-common.mjs +8 -0
- package/dist/plugins/blog/client/localization/blog-forms.cjs +40 -0
- package/dist/plugins/blog/client/localization/blog-forms.mjs +38 -0
- package/dist/plugins/blog/client/localization/blog-list.cjs +18 -0
- package/dist/plugins/blog/client/localization/blog-list.mjs +16 -0
- package/dist/plugins/blog/client/localization/blog-post.cjs +13 -0
- package/dist/plugins/blog/client/localization/blog-post.mjs +11 -0
- package/dist/plugins/blog/client/localization/index.cjs +17 -0
- package/dist/plugins/blog/client/localization/index.mjs +15 -0
- package/dist/plugins/blog/client/plugin.cjs +462 -0
- package/dist/plugins/blog/client/plugin.mjs +460 -0
- package/dist/plugins/blog/client.css +3 -0
- package/dist/plugins/blog/db.cjs +90 -0
- package/dist/plugins/blog/db.mjs +88 -0
- package/dist/plugins/blog/query-keys.cjs +181 -0
- package/dist/plugins/blog/query-keys.d.cts +530 -0
- package/dist/plugins/blog/query-keys.d.mts +530 -0
- package/dist/plugins/blog/query-keys.d.ts +530 -0
- package/dist/plugins/blog/query-keys.mjs +179 -0
- package/dist/plugins/blog/schemas.cjs +39 -0
- package/dist/plugins/blog/schemas.mjs +35 -0
- package/dist/plugins/blog/style.css +22 -0
- package/dist/plugins/blog/utils.cjs +97 -0
- package/dist/plugins/blog/utils.mjs +87 -0
- package/dist/plugins/client/index.cjs +15 -0
- package/dist/plugins/client/index.d.cts +57 -0
- package/dist/plugins/client/index.d.mts +57 -0
- package/dist/plugins/client/index.d.ts +57 -0
- package/dist/plugins/client/index.mjs +9 -0
- package/dist/{shared/stack.Br2KMECJ.cjs → plugins/utils.cjs} +1 -8
- package/dist/{shared/stack.CwGEQ10b.mjs → plugins/utils.mjs} +2 -8
- package/dist/shared/{stack.Dva9muUy.d.cts → stack.ByOugz9d.d.cts} +17 -23
- package/dist/shared/{stack.Dva9muUy.d.mts → stack.ByOugz9d.d.mts} +17 -23
- package/dist/shared/{stack.Dva9muUy.d.ts → stack.ByOugz9d.d.ts} +17 -23
- package/dist/shared/stack.Cr2JoQdo.d.cts +76 -0
- package/dist/shared/stack.Cr2JoQdo.d.mts +76 -0
- package/dist/shared/stack.Cr2JoQdo.d.ts +76 -0
- package/package.json +104 -16
- package/src/__tests__/plugins.test.tsx +539 -0
- package/src/__tests__/sitemap.test.ts +60 -0
- package/src/api/index.ts +73 -0
- package/src/client/components/compose.tsx +116 -0
- package/src/client/components/error-boundary.tsx +30 -0
- package/src/client/components/index.tsx +2 -0
- package/src/client/index.ts +107 -0
- package/src/client/meta-utils.ts +228 -0
- package/src/client/sitemap-utils.ts +46 -0
- package/src/context/index.ts +1 -0
- package/src/context/provider.tsx +157 -0
- package/src/index.ts +1 -0
- package/src/plugins/api/index.ts +51 -0
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/plugin.ts +759 -0
- package/src/plugins/blog/client/components/forms/image-field.tsx +165 -0
- package/src/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/src/plugins/blog/client/components/forms/markdown-editor.tsx +136 -0
- package/src/plugins/blog/client/components/forms/post-forms.tsx +531 -0
- package/src/plugins/blog/client/components/forms/tags-multiselect.tsx +79 -0
- package/src/plugins/blog/client/components/index.tsx +11 -0
- package/src/plugins/blog/client/components/loading/form-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/loading/index.tsx +27 -0
- package/src/plugins/blog/client/components/loading/list-page-skeleton.tsx +38 -0
- package/src/plugins/blog/client/components/loading/page-header-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/post-card-skeleton.tsx +30 -0
- package/src/plugins/blog/client/components/loading/post-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/pages/404-page.tsx +23 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +60 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +40 -0
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +71 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +42 -0
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +59 -0
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +36 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +142 -0
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -0
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +74 -0
- package/src/plugins/blog/client/components/pages/tag-page.tsx +38 -0
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +19 -0
- package/src/plugins/blog/client/components/shared/default-error.tsx +20 -0
- package/src/plugins/blog/client/components/shared/defaults.tsx +9 -0
- package/src/plugins/blog/client/components/shared/empty-list.tsx +25 -0
- package/src/plugins/blog/client/components/shared/error-placeholder.tsx +20 -0
- package/src/plugins/blog/client/components/shared/highlight-text.tsx +80 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +448 -0
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +234 -0
- package/src/plugins/blog/client/components/shared/page-header.tsx +35 -0
- package/src/plugins/blog/client/components/shared/page-layout.tsx +23 -0
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/blog/client/components/shared/post-card.tsx +308 -0
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +98 -0
- package/src/plugins/blog/client/components/shared/posts-list.tsx +67 -0
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +79 -0
- package/src/plugins/blog/client/components/shared/search-input.tsx +146 -0
- package/src/plugins/blog/client/components/shared/search-modal.tsx +162 -0
- package/src/plugins/blog/client/components/shared/tags-list.tsx +34 -0
- package/src/plugins/blog/client/components/shared/use-route-lifecycle.tsx +68 -0
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +623 -0
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/hooks/use-debounce.ts +43 -0
- package/src/plugins/blog/client/index.ts +9 -0
- package/src/plugins/blog/client/localization/blog-card.ts +3 -0
- package/src/plugins/blog/client/localization/blog-common.ts +7 -0
- package/src/plugins/blog/client/localization/blog-forms.ts +45 -0
- package/src/plugins/blog/client/localization/blog-list.ts +14 -0
- package/src/plugins/blog/client/localization/blog-post.ts +9 -0
- package/src/plugins/blog/client/localization/index.ts +15 -0
- package/src/plugins/blog/client/overrides.ts +123 -0
- package/src/plugins/blog/client/plugin.tsx +672 -0
- package/src/plugins/blog/client.css +3 -0
- package/src/plugins/blog/db.ts +90 -0
- package/src/plugins/blog/query-keys.ts +267 -0
- package/src/plugins/blog/schemas.ts +39 -0
- package/src/plugins/blog/style.css +22 -0
- package/src/plugins/blog/types.ts +37 -0
- package/src/plugins/blog/utils.ts +144 -0
- package/src/plugins/client/index.ts +53 -0
- package/src/plugins/index.ts +0 -0
- package/src/plugins/utils.ts +35 -0
- package/src/types.ts +209 -0
- package/dist/plugins/index.cjs +0 -16
- package/dist/plugins/index.d.cts +0 -64
- package/dist/plugins/index.d.mts +0 -64
- package/dist/plugins/index.d.ts +0 -64
- package/dist/plugins/index.mjs +0 -11
- package/dist/shared/stack.DvFqFlOV.d.cts +0 -22
- package/dist/shared/stack.DvFqFlOV.d.mts +0 -22
- package/dist/shared/stack.DvFqFlOV.d.ts +0 -22
package/dist/client/index.cjs
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const yar = require('@btst/yar');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
require('react/jsx-runtime');
|
|
7
|
-
require('react');
|
|
8
|
-
require('better-call/client');
|
|
4
|
+
const sitemapUtils = require('./sitemap-utils.cjs');
|
|
5
|
+
const metaUtils = require('./meta-utils.cjs');
|
|
9
6
|
|
|
10
7
|
function createStackClient(config) {
|
|
11
8
|
const { plugins } = config;
|
|
12
9
|
const allRoutes = {};
|
|
13
|
-
const allHooks = {};
|
|
14
10
|
for (const [pluginKey, plugin] of Object.entries(plugins)) {
|
|
15
11
|
const pluginRoutes = plugin.routes();
|
|
16
12
|
Object.assign(allRoutes, pluginRoutes);
|
|
17
|
-
if (plugin.hooks) {
|
|
18
|
-
allHooks[pluginKey] = plugin.hooks();
|
|
19
|
-
}
|
|
20
13
|
}
|
|
21
14
|
const router = yar.createRouter(allRoutes);
|
|
22
15
|
return {
|
|
23
16
|
router,
|
|
24
|
-
|
|
17
|
+
async generateSitemap() {
|
|
18
|
+
const sitemapEntries = [];
|
|
19
|
+
for (const plugin of Object.values(plugins)) {
|
|
20
|
+
if (typeof plugin.sitemap === "function") {
|
|
21
|
+
const entries = await plugin.sitemap();
|
|
22
|
+
if (Array.isArray(entries)) sitemapEntries.push(...entries);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26
|
+
const deduped = [];
|
|
27
|
+
for (const entry of sitemapEntries) {
|
|
28
|
+
if (!entry?.url || seen.has(entry.url)) continue;
|
|
29
|
+
seen.add(entry.url);
|
|
30
|
+
deduped.push(entry);
|
|
31
|
+
}
|
|
32
|
+
return deduped;
|
|
33
|
+
}
|
|
25
34
|
};
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.usePluginOverride = context_index.usePluginOverride;
|
|
31
|
-
exports.usePluginOverrides = context_index.usePluginOverrides;
|
|
32
|
-
exports.createApiClient = utils.createApiClient;
|
|
33
|
-
exports.getServerBaseURL = utils.getServerBaseURL;
|
|
37
|
+
exports.sitemapEntryToXmlString = sitemapUtils.sitemapEntryToXmlString;
|
|
38
|
+
exports.metaElementsToObject = metaUtils.metaElementsToObject;
|
|
34
39
|
exports.createStackClient = createStackClient;
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,12 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.cjs';
|
|
3
|
-
export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.cjs';
|
|
1
|
+
import { S as Sitemap, C as ClientPlugin, a as PluginRoutes, b as ClientLibConfig, c as ClientLib } from '../shared/stack.ByOugz9d.cjs';
|
|
4
2
|
import '@btst/yar';
|
|
5
3
|
import '@btst/db';
|
|
6
4
|
import 'better-call';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts an array of sitemap entries into an XML string following the sitemap.org protocol.
|
|
8
|
+
*
|
|
9
|
+
* @param entries - Array of sitemap entries from `lib.generateSitemap()`
|
|
10
|
+
* @returns Complete XML string for the sitemap
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const entries = await lib.generateSitemap();
|
|
15
|
+
* const xml = sitemapEntryToXmlString(entries);
|
|
16
|
+
* return new Response(xml, {
|
|
17
|
+
* headers: { "Content-Type": "application/xml; charset=utf-8" }
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function sitemapEntryToXmlString(entries: Sitemap): string;
|
|
22
|
+
|
|
23
|
+
interface Metadata {
|
|
24
|
+
title: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
keywords?: string[];
|
|
27
|
+
applicationName?: string;
|
|
28
|
+
generator?: string;
|
|
29
|
+
referrer?: "no-referrer" | "origin" | "no-referrer-when-downgrade" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin";
|
|
30
|
+
themeColor?: string;
|
|
31
|
+
viewport?: string;
|
|
32
|
+
creator?: string;
|
|
33
|
+
publisher?: string;
|
|
34
|
+
authors?: {
|
|
35
|
+
name: string;
|
|
36
|
+
}[];
|
|
37
|
+
abstract?: string;
|
|
38
|
+
robots?: string;
|
|
39
|
+
alternates?: Partial<{
|
|
40
|
+
canonical: string;
|
|
41
|
+
}>;
|
|
42
|
+
twitter?: Partial<{
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
site: string;
|
|
46
|
+
creator: string;
|
|
47
|
+
images?: string[];
|
|
48
|
+
}>;
|
|
49
|
+
openGraph?: Partial<{
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
url: string;
|
|
53
|
+
siteName: string;
|
|
54
|
+
locale: string;
|
|
55
|
+
images?: string[];
|
|
56
|
+
videos?: string[];
|
|
57
|
+
audio?: string[];
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Converts an array of meta elements to a metadata object
|
|
62
|
+
* @param metaElements - An array of meta elements
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const metaElements = [
|
|
66
|
+
* { name: "title", content: "My Page" },
|
|
67
|
+
* { name: "description", content: "This is my page" },
|
|
68
|
+
* ];
|
|
69
|
+
* const metadata = metaElementsToObject(metaElements);
|
|
70
|
+
* console.log(metadata);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function metaElementsToObject(metaElements: Array<React.JSX.IntrinsicElements["meta"] | undefined>): Metadata;
|
|
10
74
|
|
|
11
75
|
/**
|
|
12
76
|
* Creates the client library with plugin support
|
|
@@ -16,21 +80,45 @@ import 'better-call/client';
|
|
|
16
80
|
* // For Next.js with SSR:
|
|
17
81
|
* const lib = createStackClient({
|
|
18
82
|
* plugins: {
|
|
19
|
-
*
|
|
83
|
+
* blog: blogPlugin.client
|
|
20
84
|
* }
|
|
21
85
|
* });
|
|
22
86
|
*
|
|
23
|
-
* //
|
|
24
|
-
*
|
|
87
|
+
* // SPA usage - just render the route
|
|
88
|
+
* function Page() {
|
|
89
|
+
* return lib.resolveRoute('/blog');
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* // SSR usage - prefetch data with loader, then render
|
|
93
|
+
* async function Page({ params }) {
|
|
94
|
+
* const path = '/blog';
|
|
95
|
+
*
|
|
96
|
+
* // Load data server-side if loader exists
|
|
97
|
+
* const loader = lib.getLoader(path);
|
|
98
|
+
* if (loader) await loader(queryClient, baseURL, basePath);
|
|
99
|
+
*
|
|
100
|
+
* // Render with built-in Suspense + Error Boundary
|
|
101
|
+
* return lib.resolveRoute(path);
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* // Next.js with notFound() function
|
|
105
|
+
* import { notFound } from 'next/navigation';
|
|
106
|
+
*
|
|
107
|
+
* async function Page({ params }) {
|
|
108
|
+
* const path = '/blog';
|
|
109
|
+
* const loader = lib.getLoader(path);
|
|
110
|
+
* if (loader) await loader(queryClient, baseURL);
|
|
111
|
+
*
|
|
112
|
+
* return lib.resolveRoute(path, {
|
|
113
|
+
* onNotFound: notFound // Calls Next.js notFound() instead of rendering
|
|
114
|
+
* });
|
|
115
|
+
* }
|
|
25
116
|
*
|
|
26
|
-
* // For SPA (just use hooks directly):
|
|
27
|
-
* const { useMessages } = lib.hooks.messages;
|
|
28
117
|
* ```
|
|
29
118
|
*
|
|
30
119
|
* @template TPlugins - The exact plugins map (inferred from config)
|
|
31
120
|
* @template TRoutes - All routes from all plugins, merged (computed automatically)
|
|
32
|
-
* @template THooks - All hooks from all plugins, organized by plugin name (computed automatically)
|
|
33
121
|
*/
|
|
34
|
-
declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins
|
|
122
|
+
declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes>;
|
|
35
123
|
|
|
36
|
-
export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
|
|
124
|
+
export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient, metaElementsToObject, sitemapEntryToXmlString };
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,12 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.mjs';
|
|
3
|
-
export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.mjs';
|
|
1
|
+
import { S as Sitemap, C as ClientPlugin, a as PluginRoutes, b as ClientLibConfig, c as ClientLib } from '../shared/stack.ByOugz9d.mjs';
|
|
4
2
|
import '@btst/yar';
|
|
5
3
|
import '@btst/db';
|
|
6
4
|
import 'better-call';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts an array of sitemap entries into an XML string following the sitemap.org protocol.
|
|
8
|
+
*
|
|
9
|
+
* @param entries - Array of sitemap entries from `lib.generateSitemap()`
|
|
10
|
+
* @returns Complete XML string for the sitemap
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const entries = await lib.generateSitemap();
|
|
15
|
+
* const xml = sitemapEntryToXmlString(entries);
|
|
16
|
+
* return new Response(xml, {
|
|
17
|
+
* headers: { "Content-Type": "application/xml; charset=utf-8" }
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function sitemapEntryToXmlString(entries: Sitemap): string;
|
|
22
|
+
|
|
23
|
+
interface Metadata {
|
|
24
|
+
title: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
keywords?: string[];
|
|
27
|
+
applicationName?: string;
|
|
28
|
+
generator?: string;
|
|
29
|
+
referrer?: "no-referrer" | "origin" | "no-referrer-when-downgrade" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin";
|
|
30
|
+
themeColor?: string;
|
|
31
|
+
viewport?: string;
|
|
32
|
+
creator?: string;
|
|
33
|
+
publisher?: string;
|
|
34
|
+
authors?: {
|
|
35
|
+
name: string;
|
|
36
|
+
}[];
|
|
37
|
+
abstract?: string;
|
|
38
|
+
robots?: string;
|
|
39
|
+
alternates?: Partial<{
|
|
40
|
+
canonical: string;
|
|
41
|
+
}>;
|
|
42
|
+
twitter?: Partial<{
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
site: string;
|
|
46
|
+
creator: string;
|
|
47
|
+
images?: string[];
|
|
48
|
+
}>;
|
|
49
|
+
openGraph?: Partial<{
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
url: string;
|
|
53
|
+
siteName: string;
|
|
54
|
+
locale: string;
|
|
55
|
+
images?: string[];
|
|
56
|
+
videos?: string[];
|
|
57
|
+
audio?: string[];
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Converts an array of meta elements to a metadata object
|
|
62
|
+
* @param metaElements - An array of meta elements
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const metaElements = [
|
|
66
|
+
* { name: "title", content: "My Page" },
|
|
67
|
+
* { name: "description", content: "This is my page" },
|
|
68
|
+
* ];
|
|
69
|
+
* const metadata = metaElementsToObject(metaElements);
|
|
70
|
+
* console.log(metadata);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function metaElementsToObject(metaElements: Array<React.JSX.IntrinsicElements["meta"] | undefined>): Metadata;
|
|
10
74
|
|
|
11
75
|
/**
|
|
12
76
|
* Creates the client library with plugin support
|
|
@@ -16,21 +80,45 @@ import 'better-call/client';
|
|
|
16
80
|
* // For Next.js with SSR:
|
|
17
81
|
* const lib = createStackClient({
|
|
18
82
|
* plugins: {
|
|
19
|
-
*
|
|
83
|
+
* blog: blogPlugin.client
|
|
20
84
|
* }
|
|
21
85
|
* });
|
|
22
86
|
*
|
|
23
|
-
* //
|
|
24
|
-
*
|
|
87
|
+
* // SPA usage - just render the route
|
|
88
|
+
* function Page() {
|
|
89
|
+
* return lib.resolveRoute('/blog');
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* // SSR usage - prefetch data with loader, then render
|
|
93
|
+
* async function Page({ params }) {
|
|
94
|
+
* const path = '/blog';
|
|
95
|
+
*
|
|
96
|
+
* // Load data server-side if loader exists
|
|
97
|
+
* const loader = lib.getLoader(path);
|
|
98
|
+
* if (loader) await loader(queryClient, baseURL, basePath);
|
|
99
|
+
*
|
|
100
|
+
* // Render with built-in Suspense + Error Boundary
|
|
101
|
+
* return lib.resolveRoute(path);
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* // Next.js with notFound() function
|
|
105
|
+
* import { notFound } from 'next/navigation';
|
|
106
|
+
*
|
|
107
|
+
* async function Page({ params }) {
|
|
108
|
+
* const path = '/blog';
|
|
109
|
+
* const loader = lib.getLoader(path);
|
|
110
|
+
* if (loader) await loader(queryClient, baseURL);
|
|
111
|
+
*
|
|
112
|
+
* return lib.resolveRoute(path, {
|
|
113
|
+
* onNotFound: notFound // Calls Next.js notFound() instead of rendering
|
|
114
|
+
* });
|
|
115
|
+
* }
|
|
25
116
|
*
|
|
26
|
-
* // For SPA (just use hooks directly):
|
|
27
|
-
* const { useMessages } = lib.hooks.messages;
|
|
28
117
|
* ```
|
|
29
118
|
*
|
|
30
119
|
* @template TPlugins - The exact plugins map (inferred from config)
|
|
31
120
|
* @template TRoutes - All routes from all plugins, merged (computed automatically)
|
|
32
|
-
* @template THooks - All hooks from all plugins, organized by plugin name (computed automatically)
|
|
33
121
|
*/
|
|
34
|
-
declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins
|
|
122
|
+
declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes>;
|
|
35
123
|
|
|
36
|
-
export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
|
|
124
|
+
export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient, metaElementsToObject, sitemapEntryToXmlString };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,12 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.js';
|
|
3
|
-
export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.js';
|
|
1
|
+
import { S as Sitemap, C as ClientPlugin, a as PluginRoutes, b as ClientLibConfig, c as ClientLib } from '../shared/stack.ByOugz9d.js';
|
|
4
2
|
import '@btst/yar';
|
|
5
3
|
import '@btst/db';
|
|
6
4
|
import 'better-call';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts an array of sitemap entries into an XML string following the sitemap.org protocol.
|
|
8
|
+
*
|
|
9
|
+
* @param entries - Array of sitemap entries from `lib.generateSitemap()`
|
|
10
|
+
* @returns Complete XML string for the sitemap
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const entries = await lib.generateSitemap();
|
|
15
|
+
* const xml = sitemapEntryToXmlString(entries);
|
|
16
|
+
* return new Response(xml, {
|
|
17
|
+
* headers: { "Content-Type": "application/xml; charset=utf-8" }
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function sitemapEntryToXmlString(entries: Sitemap): string;
|
|
22
|
+
|
|
23
|
+
interface Metadata {
|
|
24
|
+
title: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
keywords?: string[];
|
|
27
|
+
applicationName?: string;
|
|
28
|
+
generator?: string;
|
|
29
|
+
referrer?: "no-referrer" | "origin" | "no-referrer-when-downgrade" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin";
|
|
30
|
+
themeColor?: string;
|
|
31
|
+
viewport?: string;
|
|
32
|
+
creator?: string;
|
|
33
|
+
publisher?: string;
|
|
34
|
+
authors?: {
|
|
35
|
+
name: string;
|
|
36
|
+
}[];
|
|
37
|
+
abstract?: string;
|
|
38
|
+
robots?: string;
|
|
39
|
+
alternates?: Partial<{
|
|
40
|
+
canonical: string;
|
|
41
|
+
}>;
|
|
42
|
+
twitter?: Partial<{
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
site: string;
|
|
46
|
+
creator: string;
|
|
47
|
+
images?: string[];
|
|
48
|
+
}>;
|
|
49
|
+
openGraph?: Partial<{
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
url: string;
|
|
53
|
+
siteName: string;
|
|
54
|
+
locale: string;
|
|
55
|
+
images?: string[];
|
|
56
|
+
videos?: string[];
|
|
57
|
+
audio?: string[];
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Converts an array of meta elements to a metadata object
|
|
62
|
+
* @param metaElements - An array of meta elements
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const metaElements = [
|
|
66
|
+
* { name: "title", content: "My Page" },
|
|
67
|
+
* { name: "description", content: "This is my page" },
|
|
68
|
+
* ];
|
|
69
|
+
* const metadata = metaElementsToObject(metaElements);
|
|
70
|
+
* console.log(metadata);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function metaElementsToObject(metaElements: Array<React.JSX.IntrinsicElements["meta"] | undefined>): Metadata;
|
|
10
74
|
|
|
11
75
|
/**
|
|
12
76
|
* Creates the client library with plugin support
|
|
@@ -16,21 +80,45 @@ import 'better-call/client';
|
|
|
16
80
|
* // For Next.js with SSR:
|
|
17
81
|
* const lib = createStackClient({
|
|
18
82
|
* plugins: {
|
|
19
|
-
*
|
|
83
|
+
* blog: blogPlugin.client
|
|
20
84
|
* }
|
|
21
85
|
* });
|
|
22
86
|
*
|
|
23
|
-
* //
|
|
24
|
-
*
|
|
87
|
+
* // SPA usage - just render the route
|
|
88
|
+
* function Page() {
|
|
89
|
+
* return lib.resolveRoute('/blog');
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* // SSR usage - prefetch data with loader, then render
|
|
93
|
+
* async function Page({ params }) {
|
|
94
|
+
* const path = '/blog';
|
|
95
|
+
*
|
|
96
|
+
* // Load data server-side if loader exists
|
|
97
|
+
* const loader = lib.getLoader(path);
|
|
98
|
+
* if (loader) await loader(queryClient, baseURL, basePath);
|
|
99
|
+
*
|
|
100
|
+
* // Render with built-in Suspense + Error Boundary
|
|
101
|
+
* return lib.resolveRoute(path);
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* // Next.js with notFound() function
|
|
105
|
+
* import { notFound } from 'next/navigation';
|
|
106
|
+
*
|
|
107
|
+
* async function Page({ params }) {
|
|
108
|
+
* const path = '/blog';
|
|
109
|
+
* const loader = lib.getLoader(path);
|
|
110
|
+
* if (loader) await loader(queryClient, baseURL);
|
|
111
|
+
*
|
|
112
|
+
* return lib.resolveRoute(path, {
|
|
113
|
+
* onNotFound: notFound // Calls Next.js notFound() instead of rendering
|
|
114
|
+
* });
|
|
115
|
+
* }
|
|
25
116
|
*
|
|
26
|
-
* // For SPA (just use hooks directly):
|
|
27
|
-
* const { useMessages } = lib.hooks.messages;
|
|
28
117
|
* ```
|
|
29
118
|
*
|
|
30
119
|
* @template TPlugins - The exact plugins map (inferred from config)
|
|
31
120
|
* @template TRoutes - All routes from all plugins, merged (computed automatically)
|
|
32
|
-
* @template THooks - All hooks from all plugins, organized by plugin name (computed automatically)
|
|
33
121
|
*/
|
|
34
|
-
declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins
|
|
122
|
+
declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes>;
|
|
35
123
|
|
|
36
|
-
export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
|
|
124
|
+
export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient, metaElementsToObject, sitemapEntryToXmlString };
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
import { createRouter } from '@btst/yar';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'better-call/client';
|
|
2
|
+
export { sitemapEntryToXmlString } from './sitemap-utils.mjs';
|
|
3
|
+
export { metaElementsToObject } from './meta-utils.mjs';
|
|
7
4
|
|
|
8
5
|
function createStackClient(config) {
|
|
9
6
|
const { plugins } = config;
|
|
10
7
|
const allRoutes = {};
|
|
11
|
-
const allHooks = {};
|
|
12
8
|
for (const [pluginKey, plugin] of Object.entries(plugins)) {
|
|
13
9
|
const pluginRoutes = plugin.routes();
|
|
14
10
|
Object.assign(allRoutes, pluginRoutes);
|
|
15
|
-
if (plugin.hooks) {
|
|
16
|
-
allHooks[pluginKey] = plugin.hooks();
|
|
17
|
-
}
|
|
18
11
|
}
|
|
19
12
|
const router = createRouter(allRoutes);
|
|
20
13
|
return {
|
|
21
14
|
router,
|
|
22
|
-
|
|
15
|
+
async generateSitemap() {
|
|
16
|
+
const sitemapEntries = [];
|
|
17
|
+
for (const plugin of Object.values(plugins)) {
|
|
18
|
+
if (typeof plugin.sitemap === "function") {
|
|
19
|
+
const entries = await plugin.sitemap();
|
|
20
|
+
if (Array.isArray(entries)) sitemapEntries.push(...entries);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24
|
+
const deduped = [];
|
|
25
|
+
for (const entry of sitemapEntries) {
|
|
26
|
+
if (!entry?.url || seen.has(entry.url)) continue;
|
|
27
|
+
seen.add(entry.url);
|
|
28
|
+
deduped.push(entry);
|
|
29
|
+
}
|
|
30
|
+
return deduped;
|
|
31
|
+
}
|
|
23
32
|
};
|
|
24
33
|
}
|
|
25
34
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function metaElementsToObject(metaElements) {
|
|
4
|
+
const metadata = { title: "" };
|
|
5
|
+
const nameHandlers = {
|
|
6
|
+
title: (c) => {
|
|
7
|
+
metadata.title = c;
|
|
8
|
+
},
|
|
9
|
+
description: (c) => {
|
|
10
|
+
metadata.description = c;
|
|
11
|
+
},
|
|
12
|
+
keywords: (c) => {
|
|
13
|
+
const parts = c.split(",").map((k) => k.trim()).filter(Boolean);
|
|
14
|
+
metadata.keywords = parts.length > 0 ? parts : void 0;
|
|
15
|
+
},
|
|
16
|
+
"application-name": (c) => {
|
|
17
|
+
metadata.applicationName = c;
|
|
18
|
+
},
|
|
19
|
+
generator: (c) => {
|
|
20
|
+
metadata.generator = c;
|
|
21
|
+
},
|
|
22
|
+
referrer: (c) => {
|
|
23
|
+
const allowedReferrers = /* @__PURE__ */ new Set([
|
|
24
|
+
"no-referrer",
|
|
25
|
+
"origin",
|
|
26
|
+
"no-referrer-when-downgrade",
|
|
27
|
+
"origin-when-cross-origin",
|
|
28
|
+
"same-origin",
|
|
29
|
+
"strict-origin",
|
|
30
|
+
"strict-origin-when-cross-origin",
|
|
31
|
+
"unsafe-url"
|
|
32
|
+
]);
|
|
33
|
+
if (allowedReferrers.has(c)) {
|
|
34
|
+
metadata.referrer = c;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"theme-color": (c) => {
|
|
38
|
+
metadata.themeColor = c;
|
|
39
|
+
},
|
|
40
|
+
viewport: (c) => {
|
|
41
|
+
metadata.viewport = c;
|
|
42
|
+
},
|
|
43
|
+
creator: (c) => {
|
|
44
|
+
metadata.creator = c;
|
|
45
|
+
},
|
|
46
|
+
publisher: (c) => {
|
|
47
|
+
metadata.publisher = c;
|
|
48
|
+
},
|
|
49
|
+
author: (c) => {
|
|
50
|
+
metadata.authors = [{ name: c }];
|
|
51
|
+
},
|
|
52
|
+
abstract: (c) => {
|
|
53
|
+
metadata.abstract = c;
|
|
54
|
+
},
|
|
55
|
+
robots: (c) => {
|
|
56
|
+
metadata.robots = c;
|
|
57
|
+
},
|
|
58
|
+
// Twitter
|
|
59
|
+
"twitter:title": (c) => {
|
|
60
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
61
|
+
metadata.twitter.title = c;
|
|
62
|
+
},
|
|
63
|
+
"twitter:description": (c) => {
|
|
64
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
65
|
+
metadata.twitter.description = c;
|
|
66
|
+
},
|
|
67
|
+
"twitter:site": (c) => {
|
|
68
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
69
|
+
metadata.twitter.site = c;
|
|
70
|
+
},
|
|
71
|
+
"twitter:creator": (c) => {
|
|
72
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
73
|
+
metadata.twitter.creator = c;
|
|
74
|
+
},
|
|
75
|
+
"twitter:image": (c) => {
|
|
76
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
77
|
+
const currentImages = metadata.twitter.images;
|
|
78
|
+
if (!currentImages) {
|
|
79
|
+
metadata.twitter.images = [c];
|
|
80
|
+
} else if (Array.isArray(currentImages)) {
|
|
81
|
+
metadata.twitter.images = [...currentImages, c];
|
|
82
|
+
} else {
|
|
83
|
+
metadata.twitter.images = [currentImages, c];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const propertyHandlers = {
|
|
88
|
+
"og:title": (c) => {
|
|
89
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
90
|
+
metadata.openGraph.title = c;
|
|
91
|
+
},
|
|
92
|
+
"og:description": (c) => {
|
|
93
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
94
|
+
metadata.openGraph.description = c;
|
|
95
|
+
},
|
|
96
|
+
"og:url": (c) => {
|
|
97
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
98
|
+
metadata.openGraph.url = c;
|
|
99
|
+
metadata.alternates = {
|
|
100
|
+
...metadata.alternates ?? {},
|
|
101
|
+
canonical: c
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
"og:site_name": (c) => {
|
|
105
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
106
|
+
metadata.openGraph.siteName = c;
|
|
107
|
+
},
|
|
108
|
+
"og:locale": (c) => {
|
|
109
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
110
|
+
metadata.openGraph.locale = c;
|
|
111
|
+
},
|
|
112
|
+
"og:image": (c) => {
|
|
113
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
114
|
+
const currentImages = metadata.openGraph.images;
|
|
115
|
+
if (!currentImages) {
|
|
116
|
+
metadata.openGraph.images = [c];
|
|
117
|
+
} else if (Array.isArray(currentImages)) {
|
|
118
|
+
metadata.openGraph.images = [...currentImages, c];
|
|
119
|
+
} else {
|
|
120
|
+
metadata.openGraph.images = [currentImages, c];
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"og:video": (c) => {
|
|
124
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
125
|
+
const currentVideos = metadata.openGraph.videos;
|
|
126
|
+
if (!currentVideos) {
|
|
127
|
+
metadata.openGraph.videos = [c];
|
|
128
|
+
} else if (Array.isArray(currentVideos)) {
|
|
129
|
+
metadata.openGraph.videos = [...currentVideos, c];
|
|
130
|
+
} else {
|
|
131
|
+
metadata.openGraph.videos = [currentVideos, c];
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"og:audio": (c) => {
|
|
135
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
136
|
+
const currentAudio = metadata.openGraph.audio;
|
|
137
|
+
if (!currentAudio) {
|
|
138
|
+
metadata.openGraph.audio = [c];
|
|
139
|
+
} else if (Array.isArray(currentAudio)) {
|
|
140
|
+
metadata.openGraph.audio = [...currentAudio, c];
|
|
141
|
+
} else {
|
|
142
|
+
metadata.openGraph.audio = [currentAudio, c];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
for (const meta of metaElements) {
|
|
147
|
+
if (!meta) continue;
|
|
148
|
+
if ("name" in meta && "content" in meta) {
|
|
149
|
+
const handler = nameHandlers[String(meta.name)];
|
|
150
|
+
if (handler) handler(String(meta.content));
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if ("property" in meta && "content" in meta) {
|
|
154
|
+
const handler = propertyHandlers[String(meta.property)];
|
|
155
|
+
if (handler) handler(String(meta.content));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return metadata;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
exports.metaElementsToObject = metaElementsToObject;
|