nuxt-og-image 0.1.0 → 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
|
@@ -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,
|