nuxt-og-image 0.0.5 → 0.2.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/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -114,7 +114,7 @@ declare module 'nitropack' {
|
|
|
114
114
|
island: true
|
|
115
115
|
});
|
|
116
116
|
nuxt.hooks.hook("nitro:init", async (nitro) => {
|
|
117
|
-
|
|
117
|
+
let entries = [];
|
|
118
118
|
const _routeRulesMatcher = toRouteMatcher(
|
|
119
119
|
createRouter({ routes: nitro.options.routeRules })
|
|
120
120
|
);
|
|
@@ -197,6 +197,7 @@ declare module 'nitropack' {
|
|
|
197
197
|
const ogImageFolders = await fg([`**/${HtmlRendererRoute}`], { cwd: nitro.options.output.dir, onlyDirectories: true });
|
|
198
198
|
for (const ogImageFolder of ogImageFolders)
|
|
199
199
|
await rm(`${nitro.options.output.dir}/${ogImageFolder}`, { recursive: true, force: true });
|
|
200
|
+
entries = [];
|
|
200
201
|
};
|
|
201
202
|
nitro.hooks.hook("rollup:before", async () => {
|
|
202
203
|
await outputOgImages();
|
|
@@ -4,10 +4,10 @@ export declare const PayloadScriptId = "nuxt-og-image-payload";
|
|
|
4
4
|
export declare const MetaOgImageContentPlaceholder = "__NUXT_OG_IMAGE_PLACEHOLDER__";
|
|
5
5
|
export declare const LinkPrerenderId = "nuxt-og-image-screenshot-path";
|
|
6
6
|
export interface OgImagePayload {
|
|
7
|
-
runtime
|
|
8
|
-
title
|
|
9
|
-
description
|
|
10
|
-
component
|
|
7
|
+
runtime?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
component?: string;
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
}
|
|
13
|
-
export declare function defineOgImage(options
|
|
13
|
+
export declare function defineOgImage(options?: OgImagePayload): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useServerHead } from "@vueuse/head";
|
|
2
|
+
import { useRouter } from "#imports";
|
|
2
3
|
export const HtmlRendererRoute = "__og_image";
|
|
3
4
|
export const RuntimeImageSuffix = "og-image.png";
|
|
4
5
|
export const PayloadScriptId = "nuxt-og-image-payload";
|
|
5
6
|
export const MetaOgImageContentPlaceholder = "__NUXT_OG_IMAGE_PLACEHOLDER__";
|
|
6
7
|
export const LinkPrerenderId = "nuxt-og-image-screenshot-path";
|
|
7
|
-
export function defineOgImage(options) {
|
|
8
|
+
export function defineOgImage(options = {}) {
|
|
8
9
|
if (process.server) {
|
|
9
10
|
const router = useRouter();
|
|
10
11
|
useServerHead({
|
|
@@ -14,13 +15,13 @@ export function defineOgImage(options) {
|
|
|
14
15
|
content: () => options.runtime ? `${router.currentRoute.value.path}/${RuntimeImageSuffix}` : MetaOgImageContentPlaceholder
|
|
15
16
|
}
|
|
16
17
|
],
|
|
17
|
-
link: [
|
|
18
|
+
link: options.component ? [
|
|
18
19
|
{
|
|
19
20
|
id: LinkPrerenderId,
|
|
20
21
|
rel: "prerender",
|
|
21
22
|
href: `${router.currentRoute.value.path}/${HtmlRendererRoute}`
|
|
22
23
|
}
|
|
23
|
-
],
|
|
24
|
+
] : [],
|
|
24
25
|
script: [
|
|
25
26
|
{
|
|
26
27
|
id: PayloadScriptId,
|