@phosart/common 0.4.28 → 0.4.30
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/Image.svelte
CHANGED
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
playsinline
|
|
116
116
|
use:onload
|
|
117
117
|
>
|
|
118
|
-
<source src={video} type="video/mp4" />
|
|
118
|
+
<source src={transformSrc(video)} type="video/mp4" />
|
|
119
119
|
</video>
|
|
120
120
|
{:else}
|
|
121
121
|
<picture style="background: {background}; aspect-ratio: {src.fallback.w} / {src.fallback.h};">
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
// If unspecified, the following will be inferred from above
|
|
78
78
|
Partial<OpengraphMeta> & {
|
|
79
79
|
setPageTitle?: boolean;
|
|
80
|
+
transformSrc?: (src: string) => string;
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
const {
|
|
@@ -87,11 +88,16 @@
|
|
|
87
88
|
description: userDescription,
|
|
88
89
|
title: userTitle,
|
|
89
90
|
width: userWidth,
|
|
91
|
+
transformSrc: userTransformSrc,
|
|
90
92
|
...resourceRef
|
|
91
93
|
}: Props = $props();
|
|
92
94
|
|
|
93
95
|
const config = useLibraryConfig();
|
|
94
96
|
|
|
97
|
+
const transformSrc = $derived(
|
|
98
|
+
userTransformSrc ?? config.defaultTransformSrc ?? ((s: string) => s)
|
|
99
|
+
);
|
|
100
|
+
|
|
95
101
|
const inferred = getMeta(resourceRef, config.siteName);
|
|
96
102
|
const height = $derived(userHeight ?? inferred.height);
|
|
97
103
|
const image = $derived(userImage ?? inferred.image);
|
|
@@ -116,7 +122,7 @@
|
|
|
116
122
|
<meta property="og:description" content={description} />
|
|
117
123
|
{/if}
|
|
118
124
|
{#if image && width && height}
|
|
119
|
-
<meta property="og:image" content={image} />
|
|
125
|
+
<meta property="og:image" content={transformSrc(image)} />
|
|
120
126
|
<meta property="og:image:width" content={String(width)} />
|
|
121
127
|
<meta property="og:image:height" content={String(height)} />
|
|
122
128
|
<meta name="twitter:card" content="summary_large_image" />
|
|
@@ -9,6 +9,7 @@ interface OpengraphMeta {
|
|
|
9
9
|
}
|
|
10
10
|
type Props = ResourceRef & Partial<OpengraphMeta> & {
|
|
11
11
|
setPageTitle?: boolean;
|
|
12
|
+
transformSrc?: (src: string) => string;
|
|
12
13
|
};
|
|
13
14
|
declare const OpengraphMeta: import("svelte").Component<Props, {}, "">;
|
|
14
15
|
export default OpengraphMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpengraphMeta.svelte.d.ts","sourceRoot":"","sources":["../src/lib/OpengraphMeta.svelte.ts"],"names":[],"mappings":"AAIC,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGlE,UAAU,aAAa;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AA6DD,KAAK,KAAK,GAAG,WAAW,GAEvB,OAAO,CAAC,aAAa,CAAC,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"OpengraphMeta.svelte.d.ts","sourceRoot":"","sources":["../src/lib/OpengraphMeta.svelte.ts"],"names":[],"mappings":"AAIC,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGlE,UAAU,aAAa;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AA6DD,KAAK,KAAK,GAAG,WAAW,GAEvB,OAAO,CAAC,aAAa,CAAC,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC,CAAC;AA0DJ,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAE5D,eAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
package/src/lib/Image.svelte
CHANGED
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
playsinline
|
|
116
116
|
use:onload
|
|
117
117
|
>
|
|
118
|
-
<source src={video} type="video/mp4" />
|
|
118
|
+
<source src={transformSrc(video)} type="video/mp4" />
|
|
119
119
|
</video>
|
|
120
120
|
{:else}
|
|
121
121
|
<picture style="background: {background}; aspect-ratio: {src.fallback.w} / {src.fallback.h};">
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
// If unspecified, the following will be inferred from above
|
|
78
78
|
Partial<OpengraphMeta> & {
|
|
79
79
|
setPageTitle?: boolean;
|
|
80
|
+
transformSrc?: (src: string) => string;
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
const {
|
|
@@ -87,11 +88,16 @@
|
|
|
87
88
|
description: userDescription,
|
|
88
89
|
title: userTitle,
|
|
89
90
|
width: userWidth,
|
|
91
|
+
transformSrc: userTransformSrc,
|
|
90
92
|
...resourceRef
|
|
91
93
|
}: Props = $props();
|
|
92
94
|
|
|
93
95
|
const config = useLibraryConfig();
|
|
94
96
|
|
|
97
|
+
const transformSrc = $derived(
|
|
98
|
+
userTransformSrc ?? config.defaultTransformSrc ?? ((s: string) => s)
|
|
99
|
+
);
|
|
100
|
+
|
|
95
101
|
const inferred = getMeta(resourceRef, config.siteName);
|
|
96
102
|
const height = $derived(userHeight ?? inferred.height);
|
|
97
103
|
const image = $derived(userImage ?? inferred.image);
|
|
@@ -116,7 +122,7 @@
|
|
|
116
122
|
<meta property="og:description" content={description} />
|
|
117
123
|
{/if}
|
|
118
124
|
{#if image && width && height}
|
|
119
|
-
<meta property="og:image" content={image} />
|
|
125
|
+
<meta property="og:image" content={transformSrc(image)} />
|
|
120
126
|
<meta property="og:image:width" content={String(width)} />
|
|
121
127
|
<meta property="og:image:height" content={String(height)} />
|
|
122
128
|
<meta name="twitter:card" content="summary_large_image" />
|