nuxt-og-image 1.5.3 → 1.5.5
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/dist/module.json +1 -1
- package/dist/runtime/components/OgImageBasic.island.vue +2 -2
- package/dist/runtime/nitro/renderers/satori/utils.mjs +4 -0
- package/dist/runtime/nitro/routes/options.mjs +1 -2
- package/dist/runtime/nitro/utils-pure.d.ts +2 -0
- package/dist/runtime/nitro/utils-pure.mjs +33 -0
- package/dist/runtime/nitro/utils.d.ts +1 -0
- package/dist/runtime/nitro/utils.mjs +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -82,9 +82,9 @@ const descriptionAttrs = computed(() => {
|
|
|
82
82
|
<div v-bind="containerAttrs">
|
|
83
83
|
<div class="flex flex-col w-full">
|
|
84
84
|
<div v-bind="titleAttrs">
|
|
85
|
-
{{ title }}
|
|
85
|
+
{{ title || 'Null Title' }}
|
|
86
86
|
</div>
|
|
87
|
-
<div v-bind="descriptionAttrs">
|
|
87
|
+
<div v-if="description" v-bind="descriptionAttrs">
|
|
88
88
|
{{ description }}
|
|
89
89
|
</div>
|
|
90
90
|
</div>
|
|
@@ -30,6 +30,10 @@ export async function loadFont(font) {
|
|
|
30
30
|
export async function walkSatoriTree(url, node, plugins) {
|
|
31
31
|
if (!node.props?.children)
|
|
32
32
|
return;
|
|
33
|
+
if (Array.isArray(node.props.children) && node.props.children.length === 0) {
|
|
34
|
+
delete node.props.children;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
33
37
|
for (const child of node.props.children || []) {
|
|
34
38
|
if (child) {
|
|
35
39
|
for (const plugin of plugins) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getHeaders, getQuery } from "h3";
|
|
2
|
-
import { useHostname } from "../utils.mjs";
|
|
3
|
-
import { extractOgImageOptions } from "../../../utils";
|
|
2
|
+
import { extractOgImageOptions, useHostname } from "../utils.mjs";
|
|
4
3
|
import { getRouteRules } from "#internal/nitro";
|
|
5
4
|
import { defaults } from "#nuxt-og-image/config";
|
|
6
5
|
export default defineEventHandler(async (e) => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function decodeHtmlEntities(obj) {
|
|
2
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
3
|
+
if (typeof value === "string") {
|
|
4
|
+
obj[key] = value.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'").replace(///g, "/");
|
|
5
|
+
}
|
|
6
|
+
});
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
export function extractOgImageOptions(html) {
|
|
10
|
+
const htmlPayload = html.match(/<script id="nuxt-og-image-options" type="application\/json">(.+?)<\/script>/)?.[1];
|
|
11
|
+
if (!htmlPayload)
|
|
12
|
+
return false;
|
|
13
|
+
let options;
|
|
14
|
+
try {
|
|
15
|
+
options = JSON.parse(htmlPayload);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
options = false;
|
|
18
|
+
if (process.dev)
|
|
19
|
+
console.warn("Failed to parse #nuxt-og-image-options", e, options);
|
|
20
|
+
}
|
|
21
|
+
if (options) {
|
|
22
|
+
const description = html.match(/<meta property="og:description" content="(.*?)">/)?.[1];
|
|
23
|
+
if (description)
|
|
24
|
+
options.description = description;
|
|
25
|
+
else
|
|
26
|
+
options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
|
|
27
|
+
return decodeHtmlEntities(options);
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
export function stripOgImageOptions(html) {
|
|
32
|
+
return html.replace(/<script id="nuxt-og-image-options" type="application\/json">(.*?)<\/script>/, "");
|
|
33
|
+
}
|
|
@@ -14,3 +14,4 @@ export declare function renderIsland(payload: OgImageOptions): Promise<{
|
|
|
14
14
|
export declare function useHostname(e: H3Event): string;
|
|
15
15
|
export declare function readPublicAsset(file: string, encoding?: BufferEncoding): Promise<string | Buffer | undefined>;
|
|
16
16
|
export declare function readPublicAssetBase64(file: string): Promise<string | undefined>;
|
|
17
|
+
export * from './utils-pure';
|