nuxt-og-image 3.0.0-beta.9 → 3.0.0-rc.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.
Files changed (143) hide show
  1. package/README.md +4 -4
  2. package/dist/client/200.html +6 -5
  3. package/dist/client/404.html +6 -5
  4. package/dist/client/_nuxt/IconCSS.bca1abaf.js +1 -0
  5. package/dist/client/_nuxt/IconCSS.f0b56d3e.css +1 -0
  6. package/dist/client/_nuxt/builds/latest.json +1 -1
  7. package/dist/client/_nuxt/builds/meta/c430c582-423d-48d2-8592-39b7bfd61658.json +1 -0
  8. package/dist/client/_nuxt/entry.a30f63d0.css +1 -0
  9. package/dist/client/_nuxt/entry.f2e056ce.js +108 -0
  10. package/dist/client/_nuxt/{error-404.18456c20.js → error-404.1b7ec865.js} +1 -1
  11. package/dist/client/_nuxt/{error-500.a3e12514.js → error-500.1f097e6f.js} +1 -1
  12. package/dist/client/_nuxt/vanilla-picker-NKbIFE8h.23409a58.js +8 -0
  13. package/dist/client/index.html +6 -5
  14. package/dist/module.d.mts +63 -48
  15. package/dist/module.d.ts +63 -48
  16. package/dist/module.json +2 -2
  17. package/dist/module.mjs +346 -166
  18. package/dist/runtime/cache.d.ts +7 -10
  19. package/dist/runtime/cache.mjs +40 -27
  20. package/dist/runtime/components/OgImage/OgImage.d.ts +5 -0
  21. package/dist/runtime/components/OgImage/{index.mjs → OgImage.mjs} +1 -1
  22. package/dist/runtime/components/OgImage/OgImageScreenshot.d.ts +5 -0
  23. package/dist/runtime/components/OgImage/{Screenshot.mjs → OgImageScreenshot.mjs} +1 -1
  24. package/dist/runtime/components/Templates/{Official → Community}/BrandedLogo.vue +3 -2
  25. package/dist/runtime/components/Templates/Community/Nuxt.vue +6 -5
  26. package/dist/runtime/components/Templates/Community/NuxtSeo.vue +137 -0
  27. package/dist/runtime/components/Templates/Community/Pergel.vue +104 -0
  28. package/dist/runtime/components/Templates/{Official → Community}/SimpleBlog.vue +7 -5
  29. package/dist/runtime/components/Templates/Community/UnJs.vue +108 -0
  30. package/dist/runtime/components/Templates/{Official → Community}/Wave.vue +3 -2
  31. package/dist/runtime/components/Templates/{Official → Community}/WithEmoji.vue +3 -2
  32. package/dist/runtime/composables/defineOgImage.d.ts +2 -23
  33. package/dist/runtime/composables/defineOgImage.mjs +33 -117
  34. package/dist/runtime/composables/defineOgImageComponent.d.ts +3 -0
  35. package/dist/runtime/composables/defineOgImageComponent.mjs +8 -0
  36. package/dist/runtime/composables/defineOgImageScreenshot.d.ts +2 -0
  37. package/dist/runtime/composables/defineOgImageScreenshot.mjs +13 -0
  38. package/dist/runtime/core/bindings/css-inline/node.d.ts +2 -5
  39. package/dist/runtime/core/bindings/css-inline/node.mjs +2 -10
  40. package/dist/runtime/core/bindings/resvg/wasm-fs.d.ts +40 -0
  41. package/dist/runtime/core/bindings/resvg/wasm-fs.mjs +6 -0
  42. package/dist/runtime/core/bindings/resvg/wasm.mjs +2 -5
  43. package/dist/runtime/core/bindings/satori/wasm-fs.mjs +13 -0
  44. package/dist/runtime/core/bindings/satori/wasm.d.ts +6 -0
  45. package/dist/runtime/core/bindings/satori/wasm.mjs +14 -0
  46. package/dist/runtime/core/cache/emojis.d.ts +1 -0
  47. package/dist/runtime/core/cache/emojis.mjs +5 -0
  48. package/dist/runtime/core/cache/fonts.d.ts +3 -0
  49. package/dist/runtime/core/cache/fonts.mjs +6 -0
  50. package/dist/runtime/core/cache/htmlPayload.d.ts +5 -0
  51. package/dist/runtime/core/cache/htmlPayload.mjs +6 -0
  52. package/dist/runtime/core/cache/prerender.d.ts +1 -5
  53. package/dist/runtime/core/cache/prerender.mjs +1 -2
  54. package/dist/runtime/core/env/assets.d.ts +0 -1
  55. package/dist/runtime/core/env/assets.mjs +0 -4
  56. package/dist/runtime/core/font/fetch.d.ts +2 -3
  57. package/dist/runtime/core/font/fetch.mjs +26 -19
  58. package/dist/runtime/core/html/applyEmojis.d.ts +3 -0
  59. package/dist/runtime/core/html/applyEmojis.mjs +37 -0
  60. package/dist/runtime/core/html/applyInlineCss.d.ts +3 -0
  61. package/dist/runtime/core/html/applyInlineCss.mjs +32 -0
  62. package/dist/runtime/core/html/devIframeTemplate.d.ts +2 -0
  63. package/dist/runtime/core/html/{fetch.mjs → devIframeTemplate.mjs} +33 -42
  64. package/dist/runtime/core/html/fetchIsland.d.ts +3 -0
  65. package/dist/runtime/core/html/fetchIsland.mjs +17 -0
  66. package/dist/runtime/core/options/fetch.d.ts +1 -1
  67. package/dist/runtime/core/options/fetch.mjs +10 -5
  68. package/dist/runtime/core/renderers/chromium/index.mjs +12 -15
  69. package/dist/runtime/core/renderers/chromium/screenshot.d.ts +2 -3
  70. package/dist/runtime/core/renderers/chromium/screenshot.mjs +20 -15
  71. package/dist/runtime/core/renderers/satori/index.d.ts +2 -3
  72. package/dist/runtime/core/renderers/satori/index.mjs +51 -25
  73. package/dist/runtime/core/renderers/satori/instances.d.ts +3 -0
  74. package/dist/runtime/core/renderers/satori/instances.mjs +15 -0
  75. package/dist/runtime/core/renderers/satori/plugins/emojis.mjs +15 -13
  76. package/dist/runtime/core/renderers/satori/plugins/imageSrc.mjs +60 -30
  77. package/dist/runtime/core/renderers/satori/plugins/unocss.d.ts +2 -0
  78. package/dist/runtime/core/renderers/satori/plugins/unocss.mjs +45 -0
  79. package/dist/runtime/core/renderers/satori/utils.d.ts +2 -3
  80. package/dist/runtime/core/renderers/satori/vnodes.d.ts +2 -3
  81. package/dist/runtime/core/renderers/satori/vnodes.mjs +16 -6
  82. package/dist/runtime/core/utils/resolveRendererContext.d.ts +2 -6
  83. package/dist/runtime/core/utils/resolveRendererContext.mjs +47 -29
  84. package/dist/runtime/core/utils/wasm.d.ts +3 -0
  85. package/dist/runtime/core/utils/wasm.mjs +16 -0
  86. package/dist/runtime/nitro/plugins/nuxt-content.mjs +7 -6
  87. package/dist/runtime/nitro/plugins/prerender.d.ts +1 -1
  88. package/dist/runtime/nitro/plugins/prerender.mjs +20 -18
  89. package/dist/runtime/nitro/utils.d.ts +2 -0
  90. package/dist/runtime/nitro/utils.mjs +17 -0
  91. package/dist/runtime/nuxt/plugins/og-image-canonical-urls.server.mjs +43 -0
  92. package/dist/runtime/nuxt/plugins/route-rule-og-image.server.mjs +16 -51
  93. package/dist/runtime/nuxt/utils.d.ts +3 -0
  94. package/dist/runtime/nuxt/utils.mjs +69 -0
  95. package/dist/runtime/server/routes/__og-image__/debug.json.d.ts +2 -3
  96. package/dist/runtime/server/routes/__og-image__/debug.json.mjs +5 -7
  97. package/dist/runtime/server/routes/__og-image__/image.mjs +88 -0
  98. package/dist/runtime/types.d.ts +96 -27
  99. package/dist/runtime/utils.d.ts +4 -0
  100. package/dist/runtime/utils.mjs +11 -0
  101. package/dist/runtime/utils.pure.d.ts +6 -0
  102. package/dist/runtime/utils.pure.mjs +63 -0
  103. package/package.json +33 -38
  104. package/virtual.d.ts +49 -0
  105. package/dist/client/_nuxt/IconCSS.05a4ab6a.js +0 -1
  106. package/dist/client/_nuxt/IconCSS.8f429b14.css +0 -1
  107. package/dist/client/_nuxt/builds/meta/ce33a6eb-5cc2-4c46-8618-9befaa3f226c.json +0 -1
  108. package/dist/client/_nuxt/entry.434c2c45.css +0 -1
  109. package/dist/client/_nuxt/entry.d927023c.js +0 -137
  110. package/dist/client/grid.png +0 -0
  111. package/dist/runtime/components/OgImage/Cached.d.ts +0 -5
  112. package/dist/runtime/components/OgImage/Cached.mjs +0 -10
  113. package/dist/runtime/components/OgImage/Dynamic.d.ts +0 -8
  114. package/dist/runtime/components/OgImage/Dynamic.mjs +0 -10
  115. package/dist/runtime/components/OgImage/Screenshot.d.ts +0 -6
  116. package/dist/runtime/components/OgImage/Static.d.ts +0 -8
  117. package/dist/runtime/components/OgImage/Static.mjs +0 -10
  118. package/dist/runtime/components/OgImage/WithoutCache.d.ts +0 -5
  119. package/dist/runtime/components/OgImage/WithoutCache.mjs +0 -10
  120. package/dist/runtime/components/OgImage/index.d.ts +0 -5
  121. package/dist/runtime/components/Templates/Official/Fallback.vue +0 -147
  122. package/dist/runtime/core/bindings/css-inline/mock.d.ts +0 -5
  123. package/dist/runtime/core/bindings/css-inline/mock.mjs +0 -3
  124. package/dist/runtime/core/bindings/satori/yoga-wasm.mjs +0 -7
  125. package/dist/runtime/core/bindings/sharp/wasm.d.ts +0 -2
  126. package/dist/runtime/core/bindings/sharp/wasm.mjs +0 -2
  127. package/dist/runtime/core/font/cache.d.ts +0 -1
  128. package/dist/runtime/core/font/cache.mjs +0 -1
  129. package/dist/runtime/core/html/fetch.d.ts +0 -3
  130. package/dist/runtime/core/options/normalise.d.ts +0 -2
  131. package/dist/runtime/core/options/normalise.mjs +0 -26
  132. package/dist/runtime/core/renderers/satori/fonts.d.ts +0 -3
  133. package/dist/runtime/core/renderers/satori/fonts.mjs +0 -8
  134. package/dist/runtime/nuxt/plugins/nuxt-content-canonical-urls.mjs +0 -29
  135. package/dist/runtime/public-assets/__nuxt_og_image__/browser-provider-not-supported.png +0 -0
  136. package/dist/runtime/server/routes/__og-image__/image-[path]-og.[extension].mjs +0 -45
  137. package/dist/runtime/utilts.d.ts +0 -2
  138. package/dist/runtime/utilts.mjs +0 -8
  139. /package/dist/runtime/core/bindings/satori/{yoga-wasm.d.ts → wasm-fs.d.ts} +0 -0
  140. /package/dist/runtime/nuxt/plugins/{nuxt-content-canonical-urls.d.ts → og-image-canonical-urls.server.d.ts} +0 -0
  141. /package/dist/runtime/{public-assets-optional/inter-font → server/assets}/inter-latin-ext-400-normal.woff +0 -0
  142. /package/dist/runtime/{public-assets-optional/inter-font → server/assets}/inter-latin-ext-700-normal.woff +0 -0
  143. /package/dist/runtime/server/routes/__og-image__/{image-[path]-og.[extension].d.ts → image.d.ts} +0 -0
Binary file
@@ -1,5 +0,0 @@
1
- import type { OgImageOptions } from '../../types';
2
- declare const _default: import("vue").DefineComponent<OgImageOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<OgImageOptions>>, {
3
- [x: string]: any;
4
- }, {}>;
5
- export default _default;
@@ -1,10 +0,0 @@
1
- import { defineComponent } from "vue";
2
- import { defineOgImageCached } from "#imports";
3
- export default defineComponent({
4
- name: "OgImageCached",
5
- async setup(_, { attrs }) {
6
- if (import.meta.server)
7
- await defineOgImageCached(attrs);
8
- return () => null;
9
- }
10
- });
@@ -1,8 +0,0 @@
1
- import type { OgImageOptions } from '../../types';
2
- /**
3
- * @deprecated Use OgImageWithoutCache
4
- */
5
- declare const _default: import("vue").DefineComponent<OgImageOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<OgImageOptions>>, {
6
- [x: string]: any;
7
- }, {}>;
8
- export default _default;
@@ -1,10 +0,0 @@
1
- import { defineComponent } from "vue";
2
- import { defineOgImageWithoutCache } from "#imports";
3
- export default defineComponent({
4
- name: "OgImageDynamic",
5
- async setup(_, { attrs }) {
6
- if (import.meta.server)
7
- await defineOgImageWithoutCache(attrs);
8
- return () => null;
9
- }
10
- });
@@ -1,6 +0,0 @@
1
- import type { OgImageScreenshotOptions } from '../../types';
2
- declare const _default: import("vue").DefineComponent<OgImageScreenshotOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<OgImageScreenshotOptions>>, {
3
- [x: string]: any;
4
- [x: number]: any;
5
- }, {}>;
6
- export default _default;
@@ -1,8 +0,0 @@
1
- import type { OgImageOptions } from '../../types';
2
- /**
3
- * @deprecated Use OgImageCached instead
4
- */
5
- declare const _default: import("vue").DefineComponent<OgImageOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<OgImageOptions>>, {
6
- [x: string]: any;
7
- }, {}>;
8
- export default _default;
@@ -1,10 +0,0 @@
1
- import { defineComponent } from "vue";
2
- import { defineOgImageCached } from "#imports";
3
- export default defineComponent({
4
- name: "OgImageStatic",
5
- async setup(_, { attrs }) {
6
- if (import.meta.server)
7
- await defineOgImageCached(attrs);
8
- return () => null;
9
- }
10
- });
@@ -1,5 +0,0 @@
1
- import type { OgImageOptions } from '../../types';
2
- declare const _default: import("vue").DefineComponent<OgImageOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<OgImageOptions>>, {
3
- [x: string]: any;
4
- }, {}>;
5
- export default _default;
@@ -1,10 +0,0 @@
1
- import { defineComponent } from "vue";
2
- import { defineOgImageWithoutCache } from "#imports";
3
- export default defineComponent({
4
- name: "OgImageWithoutCache",
5
- async setup(_, { attrs }) {
6
- if (import.meta.server)
7
- defineOgImageWithoutCache(attrs);
8
- return () => null;
9
- }
10
- });
@@ -1,5 +0,0 @@
1
- import type { OgImageOptions } from '../../types';
2
- declare const _default: import("vue").DefineComponent<OgImageOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<OgImageOptions>>, {
3
- [x: string]: any;
4
- }, {}>;
5
- export default _default;
@@ -1,147 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, defineComponent, h, resolveComponent } from 'vue'
3
- import { useRuntimeConfig, useSiteConfig } from '#imports'
4
-
5
- // inherited attrs can mess up the satori parser
6
- defineOptions({
7
- inheritAttrs: false,
8
- })
9
-
10
- // convert to typescript props
11
- const props = withDefaults(defineProps<{
12
- colorMode?: 'dark' | 'light'
13
- title?: string
14
- description?: string
15
- icon?: string | boolean
16
- siteName?: string
17
- siteLogo?: string
18
- theme?: string
19
- }>(), {
20
- theme: '#00dc82',
21
- colorMode: 'dark',
22
- title: 'title',
23
- })
24
-
25
- const backgroundAttrs = computed(() => {
26
- // we want to make a
27
- // const isBackgroundTw = props.background?.startsWith('bg-')
28
- return {
29
- style: {
30
- display: 'flex',
31
- position: 'absolute',
32
- width: '100%',
33
- height: '100%',
34
- background: props.colorMode === 'dark' ? 'rgba(5, 5, 5,1)' : 'rgb(255, 255, 255)',
35
- },
36
- }
37
- })
38
-
39
- const backgroundFlareAttrs = computed(() => {
40
- // we want to make a
41
- // const isBackgroundTw = props.background?.startsWith('bg-')
42
- // need to convert hex to RGB, i.e #123123 -> 18, 49, 35
43
- const rgbColor = props.theme
44
- .replace('#', '')
45
- .match(/.{1,2}/g)
46
- ?.map(v => Number.parseInt(v, 16))
47
- .join(', ')
48
- return {
49
- style: {
50
- display: 'flex',
51
- position: 'absolute',
52
- right: '-100%',
53
- top: '0%',
54
- width: '200%',
55
- height: '200%',
56
- backgroundImage: `radial-gradient(circle, rgba(${rgbColor}, 0.5) 0%, ${props.colorMode === 'dark' ? 'rgba(5, 5, 5,0.3)' : 'rgba(255, 255, 255, 0.7)'} 50%, ${props.colorMode === 'dark' ? 'rgba(5, 5, 5,0)' : 'rgba(255, 255, 255, 0)'} 70%)`,
57
- },
58
- }
59
- })
60
-
61
- const containerAttrs = computed(() => {
62
- const classes = [
63
- 'w-full',
64
- 'h-full',
65
- 'flex',
66
- 'justify-between',
67
- props.colorMode === 'dark' ? 'text-gray-100' : 'text-gray-900',
68
- 'relative',
69
- ]
70
- const styles: Record<string, any> = {
71
- padding: '5rem',
72
- }
73
- return { class: classes, style: styles }
74
- })
75
-
76
- const titleAttrs = computed(() => {
77
- return { style: {
78
- fontWeight: 'bold',
79
- marginBottom: '50px',
80
- fontSize: '75px',
81
- maxWidth: !props.icon ? '70%' : undefined,
82
- } }
83
- })
84
-
85
- const descriptionAttrs = computed(() => {
86
- return { style: {
87
- fontSize: '35px',
88
- lineHeight: `1.5rem`,
89
- opacity: '0.8',
90
- } }
91
- })
92
-
93
- const siteConfig = useSiteConfig()
94
- const siteName = computed(() => {
95
- return props.siteName || siteConfig.name
96
- })
97
- const siteLogo = computed(() => {
98
- return props.siteLogo || siteConfig.logo
99
- })
100
-
101
- const runtimeConfig = useRuntimeConfig()['nuxt-og-image']
102
-
103
- const IconComponent = runtimeConfig.hasNuxtIcon
104
- ? resolveComponent('Icon')
105
- : defineComponent({
106
- render() {
107
- return h('div', 'missing nuxt-icon')
108
- },
109
- })
110
- if (typeof props.icon === 'string' && !runtimeConfig.hasNuxtIcon && process.dev) {
111
- console.warn('Please install `nuxt-icon` to use icons with the fallback OG Image component.')
112
- // eslint-disable-next-line no-console
113
- console.log('\nnpm add -D nuxt-icon\n')
114
- // create simple div renderer component
115
- }
116
- </script>
117
-
118
- <template>
119
- <div v-bind="backgroundAttrs" />
120
- <div v-bind="backgroundFlareAttrs" />
121
- <div v-bind="containerAttrs">
122
- <div class="flex flex-row justify-between items-center">
123
- <div class="flex flex-col w-full" :style="icon ? { width: '65%' } : {}">
124
- <div v-bind="titleAttrs">
125
- {{ title || 'Null Title' }}
126
- </div>
127
- <div v-if="description" v-bind="descriptionAttrs">
128
- {{ description }}
129
- </div>
130
- </div>
131
- <div v-if="icon" style="width: 30%;" class="flex justify-end">
132
- <IconComponent :name="icon" size="250px" style="margin: 0 auto 0 100px;opacity: 0.9;" />
133
- </div>
134
- </div>
135
- <div class="flex flex-row justify-center items-center text-left w-full">
136
- <img v-if="siteLogo" :src="siteLogo" height="30">
137
- <template v-else>
138
- <svg height="50" width="50" class="mr-3" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
139
- <path :fill="theme.includes('#') ? theme : `#${theme}`" d="M62.3,-53.9C74.4,-34.5,73.5,-9,67.1,13.8C60.6,36.5,48.7,56.5,30.7,66.1C12.7,75.7,-11.4,74.8,-31.6,65.2C-51.8,55.7,-67.9,37.4,-73.8,15.7C-79.6,-6,-75.1,-31.2,-61.1,-51C-47.1,-70.9,-23.6,-85.4,0.8,-86C25.1,-86.7,50.2,-73.4,62.3,-53.9Z" transform="translate(100 100)" />
140
- </svg>
141
- <div v-if="siteName" style="font-size: 25px;" class="font-bold">
142
- {{ siteName }}
143
- </div>
144
- </template>
145
- </div>
146
- </div>
147
- </template>
@@ -1,5 +0,0 @@
1
- declare const mockFn: {
2
- (s: string): string;
3
- __mock: boolean;
4
- };
5
- export default mockFn;
@@ -1,3 +0,0 @@
1
- const mockFn = (s) => s;
2
- mockFn.__mock = true;
3
- export default mockFn;
@@ -1,7 +0,0 @@
1
- import _satori, { init } from "satori/wasm";
2
- import initYoga from "yoga-wasm-web";
3
- import YogaWasm from "yoga-wasm-web/dist/yoga.wasm";
4
- export default {
5
- initWasmPromise: initYoga(YogaWasm).then((yoga) => init(yoga)),
6
- satori: _satori
7
- };
@@ -1,2 +0,0 @@
1
- import sharp from '@img/sharp-wasm32/package.json';
2
- export default sharp;
@@ -1,2 +0,0 @@
1
- import sharp from "@img/sharp-wasm32/package.json";
2
- export default sharp;
@@ -1 +0,0 @@
1
- export declare const fontCache: Record<string, any>;
@@ -1 +0,0 @@
1
- export const fontCache = {};
@@ -1,3 +0,0 @@
1
- import { type H3Event } from 'h3';
2
- import type { RendererOptions, RuntimeOgImageOptions } from '../../types';
3
- export declare function fetchHTML(e: H3Event, options: RuntimeOgImageOptions | RendererOptions): Promise<string>;
@@ -1,2 +0,0 @@
1
- import type { OgImageOptions } from '../../types';
2
- export declare function normaliseOptions(_options: OgImageOptions): any;
@@ -1,26 +0,0 @@
1
- import { unref, useRuntimeConfig } from "#imports";
2
- import { componentNames } from "#build/og-image-component-names.mjs";
3
- export function normaliseOptions(_options) {
4
- const { runtimeSatori } = useRuntimeConfig()["nuxt-og-image"];
5
- const options = { ...unref(_options) };
6
- if (options.static)
7
- options.cache = options.cache || options.static;
8
- if (options.provider === "satori")
9
- options.renderer = options.renderer || "satori";
10
- else if (options.provider === "browser")
11
- options.renderer = options.renderer || "chromium";
12
- options.renderer = options.renderer || "satori";
13
- if (options.renderer === "satori" && !runtimeSatori)
14
- options.renderer = "chromium";
15
- if (options.component && componentNames) {
16
- const originalName = options.component;
17
- for (const component of componentNames) {
18
- if (component.pascalName.endsWith(originalName) || component.kebabName.endsWith(originalName)) {
19
- options.component = component.pascalName;
20
- options.componentHash = component.hash;
21
- break;
22
- }
23
- }
24
- }
25
- return options;
26
- }
@@ -1,3 +0,0 @@
1
- import type { FontConfig } from '../../../types';
2
- export declare const satoriFonts: any[];
3
- export declare function loadFonts(baseURL: string, fonts: FontConfig[]): Promise<any>;
@@ -1,8 +0,0 @@
1
- import { loadFont } from "../../font/fetch.mjs";
2
- export const satoriFonts = [];
3
- let fontLoadPromise = null;
4
- export function loadFonts(baseURL, fonts) {
5
- if (fontLoadPromise)
6
- return fontLoadPromise;
7
- return fontLoadPromise = Promise.all(fonts.map((font) => loadFont(baseURL, font)));
8
- }
@@ -1,29 +0,0 @@
1
- import { parseURL } from "ufo";
2
- import { toValue } from "vue";
3
- import { isInternalRoute } from "../../utilts.mjs";
4
- import { useRequestEvent, withSiteUrl } from "#imports";
5
- export default defineNuxtPlugin((nuxtApp) => {
6
- nuxtApp.hooks.hook("app:rendered", async (ctx) => {
7
- const { ssrContext } = ctx;
8
- const e = useRequestEvent();
9
- const path = parseURL(e.path).pathname;
10
- if (isInternalRoute(path))
11
- return;
12
- ssrContext?.head.use({
13
- key: "nuxt-og-image:canonical-urls",
14
- hooks: {
15
- "tags:resolve": async ({ tags }) => {
16
- for (const tag of tags) {
17
- if (tag.tag === "meta" && (tag.props.property === "og:image" || tag.props.name === "twitter:image:src")) {
18
- if (!tag.props.content.startsWith("https")) {
19
- await nuxtApp.runWithContext(() => {
20
- tag.props.content = toValue(withSiteUrl(tag.props.content));
21
- });
22
- }
23
- }
24
- }
25
- }
26
- }
27
- });
28
- });
29
- });
@@ -1,45 +0,0 @@
1
- import { H3Error, createError, defineEventHandler, setHeader } from "h3";
2
- import { resolveRendererContext } from "../../../core/utils/resolveRendererContext.mjs";
3
- import { fetchHTML } from "../../../core/html/fetch.mjs";
4
- import { useSiteConfig } from "#imports";
5
- export default defineEventHandler(async (e) => {
6
- const ctx = await resolveRendererContext(e);
7
- if (ctx instanceof H3Error)
8
- return ctx;
9
- const { extension, options, renderer } = ctx;
10
- if (!options.cacheTtl || import.meta.dev) {
11
- setHeader(e, "Cache-Control", "no-cache, no-store, must-revalidate");
12
- setHeader(e, "Pragma", "no-cache");
13
- setHeader(e, "Expires", "0");
14
- }
15
- switch (extension) {
16
- case "html":
17
- setHeader(e, "Content-Type", `text/html`);
18
- return fetchHTML(e, options);
19
- case "json":
20
- setHeader(e, "Content-Type", "application/json");
21
- return {
22
- ...ctx,
23
- siteConfig: useSiteConfig(e),
24
- vnodes: options.renderer === "satori" ? await renderer.createImage(e, { ...options, extension: "json" }) : void 0
25
- };
26
- case "svg":
27
- case "png":
28
- case "jpeg":
29
- case "jpg":
30
- if (!renderer.supportedFormats.includes(options.extension)) {
31
- return createError({
32
- statusCode: 400,
33
- statusMessage: `Generating ${options.extension}'s with ${renderer.name} is not supported.`
34
- });
35
- }
36
- setHeader(e, "Content-Type", `image/${options.extension === "svg" ? "svg+xml" : options.extension}`);
37
- break;
38
- default:
39
- return createError({
40
- statusCode: 400,
41
- statusMessage: `Invalid request for og.${options.extension}.`
42
- });
43
- }
44
- return renderer.createImage(e, options);
45
- });
@@ -1,2 +0,0 @@
1
- export declare function getOgImagePath(pagePath: string, extension?: string): string;
2
- export declare function isInternalRoute(path: string): boolean;
@@ -1,8 +0,0 @@
1
- import { joinURL } from "ufo";
2
- export function getOgImagePath(pagePath, extension = "png") {
3
- return joinURL("/__og-image__/image", pagePath, `og.${extension}`);
4
- }
5
- export function isInternalRoute(path) {
6
- const lastSegment = path.split("/").pop() || path;
7
- return lastSegment.includes(".") || path.startsWith("/__") || path.startsWith("@");
8
- }