File tree 4 files changed +39
-19
lines changed
4 files changed +39
-19
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,28 @@ https://loremflickr.com/640/480/city?3
184
184
![ ] ( https://loremflickr.com/640/480/city?4 )
185
185
:::
186
186
187
+ ```
188
+ ::: grid {cols=3,rows=2,gap=12,type=images}
189
+ 
190
+ 
191
+ 
192
+ 
193
+ 
194
+ 
195
+ :::
196
+
197
+ ```
198
+
199
+ ::: grid {cols=3,rows=2,gap=12,type=images}
200
+ ![ ] ( https://loremflickr.com/640/480/city?4 )
201
+ ![ ] ( https://loremflickr.com/640/480/city?4 )
202
+ ![ ] ( https://loremflickr.com/640/480/city?4 )
203
+ ![ ] ( https://loremflickr.com/640/480/city?4 )
204
+ ![ ] ( https://loremflickr.com/640/480/city?4 )
205
+ ![ ] ( https://loremflickr.com/640/480/city?4 )
206
+ :::
207
+
208
+
187
209
188
210
## Rich Link
189
211
Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ export const ContainerRule: MarkdownToJSX.Rule = {
143
143
144
144
return (
145
145
< GridMarkdownImages
146
+ height = { rows && cols ? + rows / + cols : 1 }
146
147
key = { state . key }
147
148
imagesSrc = { imagesSrc }
148
149
Wrapper = { Grid }
Original file line number Diff line number Diff line change @@ -56,9 +56,15 @@ export const GridMarkdownImage = (props: any) => {
56
56
export const GridMarkdownImages : FC < {
57
57
imagesSrc : string [ ]
58
58
Wrapper : Component
59
- } > = ( { imagesSrc, Wrapper } ) => {
59
+ height : number
60
+ } > = ( { imagesSrc, Wrapper, height = 1 } ) => {
60
61
return (
61
- < div className = "relative pb-[100%]" >
62
+ < div
63
+ className = "relative"
64
+ style = { {
65
+ paddingBottom : `${ height * 100 } %` ,
66
+ } }
67
+ >
62
68
< Wrapper className = "absolute inset-0" >
63
69
{ imagesSrc . map ( ( src ) => {
64
70
return < GridZoomImage key = { src } src = { src } />
Original file line number Diff line number Diff line change @@ -40,25 +40,16 @@ export function getDominantColor(imageObject: HTMLImageElement) {
40
40
. slice ( 1 ) } `
41
41
}
42
42
43
- export const addImageUrlCropSizeQuery = ( url : string , size : number ) => {
44
- const parsedUrl = new URL ( url )
45
-
46
- // Tencent Cloud 数据万象
47
- // ?imageMogr2/thumbnail/300x/crop/300x300/gravity/center
48
- parsedUrl . searchParams . set (
49
- `imageMogr2/thumbnail/${ size } x/crop/${ size } x${ size } /gravity/center/strip` ,
50
- '' ,
51
- )
52
-
53
- return parsedUrl . toString ( ) . replace ( / = $ / , '' )
54
- }
55
-
43
+ const TENCENT_CDN_DOMAIN = 'cdn.innei.ren'
56
44
export const addImageUrlResizeQuery = ( url : string , size : number ) => {
57
45
const parsedUrl = new URL ( url )
58
46
59
- // Tencent Cloud 数据万象
60
- // ?imageMogr2/thumbnail/300x
61
- parsedUrl . searchParams . set ( `imageMogr2/thumbnail/${ size } x/strip` , '' )
47
+ if ( parsedUrl . host === TENCENT_CDN_DOMAIN ) {
48
+ // Tencent Cloud 数据万象
49
+ // ?imageMogr2/thumbnail/300x
50
+
51
+ return `${ url } ?imageMogr2/thumbnail/${ size } x/strip`
52
+ }
62
53
63
- return parsedUrl . toString ( ) . replace ( / = $ / , '' )
54
+ return url
64
55
}
You can’t perform that action at this time.
0 commit comments