@rxdrag/website-lib 0.0.129 → 0.0.131
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/components/Image.astro +8 -0
- package/components/Image.type.ts +16 -0
- package/components/Video.astro +16 -9
- package/package.json +4 -4
package/components/Image.astro
CHANGED
|
@@ -7,6 +7,8 @@ interface Props extends ImageProps {}
|
|
|
7
7
|
const {
|
|
8
8
|
src,
|
|
9
9
|
alt = "",
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
10
12
|
layout,
|
|
11
13
|
formats,
|
|
12
14
|
loading,
|
|
@@ -42,6 +44,8 @@ if (isStringSrc && (src.startsWith("/src/") || src.startsWith("src/"))) {
|
|
|
42
44
|
<img
|
|
43
45
|
src={src}
|
|
44
46
|
alt={alt}
|
|
47
|
+
width={width}
|
|
48
|
+
height={height}
|
|
45
49
|
loading={loading}
|
|
46
50
|
class={className}
|
|
47
51
|
{...restProps}
|
|
@@ -50,6 +54,8 @@ if (isStringSrc && (src.startsWith("/src/") || src.startsWith("src/"))) {
|
|
|
50
54
|
<AstroPicture
|
|
51
55
|
src={src}
|
|
52
56
|
alt={alt}
|
|
57
|
+
width={width}
|
|
58
|
+
height={height}
|
|
53
59
|
formats={formats}
|
|
54
60
|
quality={quality}
|
|
55
61
|
loading={priority ? "eager" : loading}
|
|
@@ -62,6 +68,8 @@ if (isStringSrc && (src.startsWith("/src/") || src.startsWith("src/"))) {
|
|
|
62
68
|
<AstroImage
|
|
63
69
|
src={src}
|
|
64
70
|
alt={alt}
|
|
71
|
+
width={width}
|
|
72
|
+
height={height}
|
|
65
73
|
quality={quality}
|
|
66
74
|
loading={loading}
|
|
67
75
|
sizes={actualSizes}
|
package/components/Image.type.ts
CHANGED
|
@@ -113,6 +113,22 @@ export interface ImageProps extends Omit<HTMLAttributes<"img">, "src" | "width"
|
|
|
113
113
|
*/
|
|
114
114
|
src: string | ImageMetadata;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 图片宽度
|
|
118
|
+
* - 本地图片可自动推断,可不填
|
|
119
|
+
* - 远程图片必须填写
|
|
120
|
+
* - 使用 Tailwind aspect-* 时可省略
|
|
121
|
+
*/
|
|
122
|
+
width?: number;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 图片高度
|
|
126
|
+
* - 本地图片可自动推断,可不填
|
|
127
|
+
* - 远程图片必须填写
|
|
128
|
+
* - 使用 Tailwind aspect-* 时可省略
|
|
129
|
+
*/
|
|
130
|
+
height?: number;
|
|
131
|
+
|
|
116
132
|
/**
|
|
117
133
|
* 图片描述(用于无障碍访问和 SEO)
|
|
118
134
|
* - 内容图片:填写描述文字
|
package/components/Video.astro
CHANGED
|
@@ -4,15 +4,14 @@ import {
|
|
|
4
4
|
ReactVideoPlayer,
|
|
5
5
|
type Locals,
|
|
6
6
|
} from "@rxdrag/website-lib-core";
|
|
7
|
+
import { getImage } from "astro:assets";
|
|
8
|
+
import type { ImageMetadata } from "astro";
|
|
9
|
+
|
|
7
10
|
const { env, imageSizes } = Astro.locals as Locals;
|
|
8
11
|
|
|
9
12
|
interface Props {
|
|
10
|
-
//TODO 要删除
|
|
11
13
|
videoRef?: string;
|
|
12
|
-
|
|
13
|
-
posterRef?: string;
|
|
14
|
-
src?: string;
|
|
15
|
-
poster?: string;
|
|
14
|
+
poster?: string | ImageMetadata;
|
|
16
15
|
endTitle?: string;
|
|
17
16
|
eagerLoad?: boolean;
|
|
18
17
|
classNames?: {
|
|
@@ -31,8 +30,6 @@ interface Props {
|
|
|
31
30
|
|
|
32
31
|
const {
|
|
33
32
|
videoRef,
|
|
34
|
-
posterRef,
|
|
35
|
-
src,
|
|
36
33
|
poster,
|
|
37
34
|
eagerLoad,
|
|
38
35
|
endTitle = "Contact Us Now",
|
|
@@ -43,7 +40,17 @@ const rx = Entify.getInstance(env, imageSizes);
|
|
|
43
40
|
|
|
44
41
|
// 获取媒体数据(增加 rx 为空时的保护)
|
|
45
42
|
const media = rx ? await rx.getMedia(videoRef) : undefined;
|
|
46
|
-
|
|
43
|
+
|
|
44
|
+
// 处理封面图
|
|
45
|
+
let posterUrl: string | undefined;
|
|
46
|
+
if (poster) {
|
|
47
|
+
if (typeof poster === "string") {
|
|
48
|
+
posterUrl = poster;
|
|
49
|
+
} else {
|
|
50
|
+
const posterImage = await getImage({ src: poster });
|
|
51
|
+
posterUrl = posterImage.src;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
47
54
|
---
|
|
48
55
|
|
|
49
56
|
{
|
|
@@ -52,7 +59,7 @@ const posterObj = rx ? await rx.getMedia(posterRef) : undefined;
|
|
|
52
59
|
client:load
|
|
53
60
|
media={media}
|
|
54
61
|
endTitle={endTitle}
|
|
55
|
-
posterUrl={
|
|
62
|
+
posterUrl={posterUrl}
|
|
56
63
|
eagerLoad={eagerLoad}
|
|
57
64
|
classNames={classNames}
|
|
58
65
|
/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdrag/website-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.131",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.ts",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"eslint": "^9.39.2",
|
|
27
27
|
"gsap": "^3.12.7",
|
|
28
28
|
"typescript": "^5",
|
|
29
|
+
"@rxdrag/tiptap-preview": "0.0.3",
|
|
29
30
|
"@rxdrag/entify-hooks": "0.2.79",
|
|
30
31
|
"@rxdrag/rxcms-models": "0.3.98",
|
|
31
32
|
"@rxdrag/eslint-config-custom": "0.2.13",
|
|
32
|
-
"@rxdrag/tiptap-preview": "0.0.3",
|
|
33
33
|
"@rxdrag/tsconfig": "0.2.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"react": "^19.1.0",
|
|
39
39
|
"react-dom": "^19.1.0",
|
|
40
40
|
"vanilla-cookieconsent": "3.1.0",
|
|
41
|
-
"@rxdrag/
|
|
42
|
-
"@rxdrag/
|
|
41
|
+
"@rxdrag/rxcms-models": "0.3.98",
|
|
42
|
+
"@rxdrag/website-lib-core": "0.0.123"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"astro": "^4.0.0 || ^5.0.0"
|