astro-opengraph-images 1.6.2 → 1.6.4
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/CHANGELOG.md +19 -0
- package/README.md +163 -115
- package/README.md.tmpl +91 -61
- package/dist/extract.js +1 -1
- package/dist/extract.js.map +1 -1
- package/package.json +5 -5
- package/src/extract.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.4](https://github.com/shepherdjerred/astro-opengraph-images/compare/v1.6.3...v1.6.4) (2024-07-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* deps ([134d1d2](https://github.com/shepherdjerred/astro-opengraph-images/commit/134d1d26038bbe1a1c0f66bda0de0cc4c6ef269c))
|
|
9
|
+
|
|
10
|
+
## [1.6.3](https://github.com/shepherdjerred/astro-opengraph-images/compare/v1.6.2...v1.6.3) (2024-07-02)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* add more context to site ([3db768a](https://github.com/shepherdjerred/astro-opengraph-images/commit/3db768aef904a95915696accae28b9aa239a1419))
|
|
16
|
+
* don't set description if it equals the title ([42763b5](https://github.com/shepherdjerred/astro-opengraph-images/commit/42763b523ff25ba8b88a7d4ce463f972974f3ddc))
|
|
17
|
+
* formatting ([94ed9b9](https://github.com/shepherdjerred/astro-opengraph-images/commit/94ed9b99c8db98c284e9ffcc39b050ad3ab8e762))
|
|
18
|
+
* regenerate README ([b8c204e](https://github.com/shepherdjerred/astro-opengraph-images/commit/b8c204e0e9b37868e43692fc1d57e795d8dbb456))
|
|
19
|
+
* regenerate README ([531d5f4](https://github.com/shepherdjerred/astro-opengraph-images/commit/531d5f4780b273e317d608411c64fcba4f3e50db))
|
|
20
|
+
* regenerate README ([4e432c6](https://github.com/shepherdjerred/astro-opengraph-images/commit/4e432c6059b7b6f3f10e54c75307cbbd3e204bf0))
|
|
21
|
+
|
|
3
22
|
## [1.6.2](https://github.com/shepherdjerred/astro-opengraph-images/compare/v1.6.1...v1.6.2) (2024-07-01)
|
|
4
23
|
|
|
5
24
|
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
34
34
|
|
|
35
35
|
## Quick Start
|
|
36
36
|
|
|
37
|
-
1. Add this integration to your
|
|
37
|
+
1. Add this integration to your Astro config:
|
|
38
38
|
|
|
39
39
|
- Option 1: use the `astro` command:
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
42
42
|
npx astro add astro-opengraph-images
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
- Option 2: install the package and add the integration to your
|
|
45
|
+
- Option 2: install the package and add the integration to your Astro config:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
48
|
npm i astro-opengraph-images
|
|
@@ -66,7 +66,7 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
66
66
|
|
|
67
67
|
You can find more fonts on [Fontsource](https://fontsource.org/), or you can use any font file that you have. See [Satori's font documentation](https://github.com/vercel/satori?tab=readme-ov-file#fonts) for more information.
|
|
68
68
|
|
|
69
|
-
1. Configure the integration in your
|
|
69
|
+
1. Configure the integration in your Astro config:
|
|
70
70
|
|
|
71
71
|
```diff
|
|
72
72
|
-import opengraphImages from "astro-opengraph-images";
|
|
@@ -92,7 +92,32 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
92
92
|
});
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
1.
|
|
95
|
+
1. Set the [`site`](https://docs.astro.build/en/reference/configuration-reference/#site) property in your Astro config:
|
|
96
|
+
|
|
97
|
+
Open Graph requires URLs to be absolute, including the domain your site is hosted at. This integration uses the site defined in your Astro config to create the correct URLs for Open Graph which is `site` must be defined.
|
|
98
|
+
|
|
99
|
+
```diff
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
+ site: "https://<your site>.com",
|
|
102
|
+
integrations: [
|
|
103
|
+
opengraphImages({
|
|
104
|
+
options: {
|
|
105
|
+
fonts: [
|
|
106
|
+
{
|
|
107
|
+
name: "Roboto",
|
|
108
|
+
weight: 400,
|
|
109
|
+
style: "normal",
|
|
110
|
+
data: fs.readFileSync("node_modules/@fontsource/roboto/files/roboto-latin-400-normal.woff"),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
render: presets.blackAndWhite,
|
|
115
|
+
}),
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
1. Update your main Astro layout with the appropriate `meta` tags. The [Open Graph site](https://ogp.me/) has more information possible tags.
|
|
96
121
|
|
|
97
122
|
The following `meta` tags must be defined:
|
|
98
123
|
|
|
@@ -102,65 +127,68 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
102
127
|
- See the [Open Graph documentation](https://ogp.me/#types) for valid values.
|
|
103
128
|
- `og:image`
|
|
104
129
|
- Set this to the return value of `getImagePath` (example shown below).
|
|
130
|
+
- If the value of `og:image` does not match what this integration expects then your site will fail to build. This will ensure your site is correctly configured to display Open Graph images.
|
|
105
131
|
- `og:description`
|
|
106
132
|
- Optional. This field may be used when generating images.
|
|
107
133
|
|
|
108
|
-
Your site will fail to build if the tags above are not set.
|
|
134
|
+
Your site will fail to build if the tags above are not set.
|
|
109
135
|
|
|
110
|
-
|
|
136
|
+
- Option 1: Use the [`astro-seo`](https://github.com/jonasmerlin/astro-seo) package:
|
|
111
137
|
|
|
112
|
-
|
|
138
|
+
Install the `astro-seo` package:
|
|
113
139
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
140
|
+
```bash
|
|
141
|
+
npm i astro-seo
|
|
142
|
+
```
|
|
117
143
|
|
|
118
|
-
|
|
144
|
+
Update your Astro layout to use the `SEO` component:
|
|
119
145
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
146
|
+
```diff
|
|
147
|
+
---
|
|
148
|
+
+ import { SEO } from "astro-seo";
|
|
149
|
+
|
|
150
|
+
interface Props {
|
|
151
|
+
title: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const { title } = Astro.props;
|
|
155
|
+
+const { url, site } = Astro;
|
|
156
|
+
+const openGraphImageUrl = getImagePath({ url, site });
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
<!doctype html>
|
|
160
|
+
<html lang="en">
|
|
161
|
+
<head>
|
|
162
|
+
<meta charset="UTF-8" />
|
|
163
|
+
<meta name="description" content="Astro description" />
|
|
164
|
+
<meta name="viewport" content="width=device-width" />
|
|
165
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
166
|
+
<meta name="generator" content={Astro.generator} />
|
|
167
|
+
<title>{title}</title>
|
|
168
|
+
|
|
169
|
+
+ <SEO
|
|
170
|
+
+ openGraph={
|
|
171
|
+
+ {
|
|
172
|
+
+ basic: {
|
|
173
|
+
+ title: title,
|
|
174
|
+
+ type: "website",
|
|
175
|
+
+ image: openGraphImageUrl,
|
|
176
|
+
+ url: url,
|
|
177
|
+
+ },
|
|
178
|
+
+ optional: {
|
|
179
|
+
+ description: "My page description",
|
|
180
|
+
+ },
|
|
181
|
+
+ }
|
|
182
|
+
+ }
|
|
183
|
+
+ />
|
|
184
|
+
</head>
|
|
185
|
+
<body>
|
|
186
|
+
<slot />
|
|
187
|
+
</body>
|
|
188
|
+
</html>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- Option 2: Manually add the `meta` tags to your Astro layout.
|
|
164
192
|
|
|
165
193
|
1. Build your site. You should see a `.png` file next to each `.html` page in your `dist` folder. Double-check that the `og:image` proprety in your `.html` file matches the path to the `.png` file.
|
|
166
194
|
|
|
@@ -204,140 +232,160 @@ npm i tw-to-css
|
|
|
204
232
|
|
|
205
233
|
### `backgroundImage`
|
|
206
234
|
|
|
207
|
-
```
|
|
235
|
+
```diff
|
|
208
236
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
209
237
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}),
|
|
238
|
+
export default defineConfig({
|
|
239
|
+
integrations: [
|
|
240
|
+
opengraphImages({
|
|
241
|
+
+ render: presets.backgroundImage,
|
|
242
|
+
}),
|
|
243
|
+
],
|
|
244
|
+
});
|
|
215
245
|
```
|
|
216
246
|
|
|
217
247
|

|
|
218
248
|
|
|
219
249
|
### `blackAndWhite`
|
|
220
250
|
|
|
221
|
-
```
|
|
251
|
+
```diff
|
|
222
252
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
223
253
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}),
|
|
254
|
+
export default defineConfig({
|
|
255
|
+
integrations: [
|
|
256
|
+
opengraphImages({
|
|
257
|
+
+ render: presets.blackAndWhite,
|
|
258
|
+
}),
|
|
259
|
+
],
|
|
260
|
+
});
|
|
229
261
|
```
|
|
230
262
|
|
|
231
263
|

|
|
232
264
|
|
|
233
265
|
### `brandedLogo`
|
|
234
266
|
|
|
235
|
-
```
|
|
267
|
+
```diff
|
|
236
268
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
237
269
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}),
|
|
270
|
+
export default defineConfig({
|
|
271
|
+
integrations: [
|
|
272
|
+
opengraphImages({
|
|
273
|
+
+ render: presets.brandedLogo,
|
|
274
|
+
}),
|
|
275
|
+
],
|
|
276
|
+
});
|
|
243
277
|
```
|
|
244
278
|
|
|
245
279
|

|
|
246
280
|
|
|
247
281
|
### `gradients`
|
|
248
282
|
|
|
249
|
-
```
|
|
283
|
+
```diff
|
|
250
284
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
251
285
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}),
|
|
286
|
+
export default defineConfig({
|
|
287
|
+
integrations: [
|
|
288
|
+
opengraphImages({
|
|
289
|
+
+ render: presets.gradients,
|
|
290
|
+
}),
|
|
291
|
+
],
|
|
292
|
+
});
|
|
257
293
|
```
|
|
258
294
|
|
|
259
295
|

|
|
260
296
|
|
|
261
297
|
### `podcast`
|
|
262
298
|
|
|
263
|
-
```
|
|
299
|
+
```diff
|
|
264
300
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
265
301
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}),
|
|
302
|
+
export default defineConfig({
|
|
303
|
+
integrations: [
|
|
304
|
+
opengraphImages({
|
|
305
|
+
+ render: presets.podcast,
|
|
306
|
+
}),
|
|
307
|
+
],
|
|
308
|
+
});
|
|
271
309
|
```
|
|
272
310
|
|
|
273
311
|

|
|
274
312
|
|
|
275
313
|
### `rauchg`
|
|
276
314
|
|
|
277
|
-
```
|
|
315
|
+
```diff
|
|
278
316
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
279
317
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}),
|
|
318
|
+
export default defineConfig({
|
|
319
|
+
integrations: [
|
|
320
|
+
opengraphImages({
|
|
321
|
+
+ render: presets.rauchg,
|
|
322
|
+
}),
|
|
323
|
+
],
|
|
324
|
+
});
|
|
285
325
|
```
|
|
286
326
|
|
|
287
327
|

|
|
288
328
|
|
|
289
329
|
### `simpleBlog`
|
|
290
330
|
|
|
291
|
-
```
|
|
331
|
+
```diff
|
|
292
332
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
293
333
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}),
|
|
334
|
+
export default defineConfig({
|
|
335
|
+
integrations: [
|
|
336
|
+
opengraphImages({
|
|
337
|
+
+ render: presets.simpleBlog,
|
|
338
|
+
}),
|
|
339
|
+
],
|
|
340
|
+
});
|
|
299
341
|
```
|
|
300
342
|
|
|
301
343
|

|
|
302
344
|
|
|
303
345
|
### `tailwind`
|
|
304
346
|
|
|
305
|
-
```
|
|
347
|
+
```diff
|
|
306
348
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
307
349
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}),
|
|
350
|
+
export default defineConfig({
|
|
351
|
+
integrations: [
|
|
352
|
+
opengraphImages({
|
|
353
|
+
+ render: presets.tailwind,
|
|
354
|
+
}),
|
|
355
|
+
],
|
|
356
|
+
});
|
|
313
357
|
```
|
|
314
358
|
|
|
315
359
|

|
|
316
360
|
|
|
317
361
|
### `vercel`
|
|
318
362
|
|
|
319
|
-
```
|
|
363
|
+
```diff
|
|
320
364
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
321
365
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}),
|
|
366
|
+
export default defineConfig({
|
|
367
|
+
integrations: [
|
|
368
|
+
opengraphImages({
|
|
369
|
+
+ render: presets.vercel,
|
|
370
|
+
}),
|
|
371
|
+
],
|
|
372
|
+
});
|
|
327
373
|
```
|
|
328
374
|
|
|
329
375
|

|
|
330
376
|
|
|
331
377
|
### `waveSvg`
|
|
332
378
|
|
|
333
|
-
```
|
|
379
|
+
```diff
|
|
334
380
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
335
381
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}),
|
|
382
|
+
export default defineConfig({
|
|
383
|
+
integrations: [
|
|
384
|
+
opengraphImages({
|
|
385
|
+
+ render: presets.waveSvg,
|
|
386
|
+
}),
|
|
387
|
+
],
|
|
388
|
+
});
|
|
341
389
|
```
|
|
342
390
|
|
|
343
391
|

|
package/README.md.tmpl
CHANGED
|
@@ -34,7 +34,7 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
34
34
|
|
|
35
35
|
## Quick Start
|
|
36
36
|
|
|
37
|
-
1. Add this integration to your
|
|
37
|
+
1. Add this integration to your Astro config:
|
|
38
38
|
|
|
39
39
|
- Option 1: use the `astro` command:
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
42
42
|
npx astro add astro-opengraph-images
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
- Option 2: install the package and add the integration to your
|
|
45
|
+
- Option 2: install the package and add the integration to your Astro config:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
48
|
npm i astro-opengraph-images
|
|
@@ -66,7 +66,7 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
66
66
|
|
|
67
67
|
You can find more fonts on [Fontsource](https://fontsource.org/), or you can use any font file that you have. See [Satori's font documentation](https://github.com/vercel/satori?tab=readme-ov-file#fonts) for more information.
|
|
68
68
|
|
|
69
|
-
1. Configure the integration in your
|
|
69
|
+
1. Configure the integration in your Astro config:
|
|
70
70
|
|
|
71
71
|
```diff
|
|
72
72
|
-import opengraphImages from "astro-opengraph-images";
|
|
@@ -92,7 +92,32 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
92
92
|
});
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
1.
|
|
95
|
+
1. Set the [`site`](https://docs.astro.build/en/reference/configuration-reference/#site) property in your Astro config:
|
|
96
|
+
|
|
97
|
+
Open Graph requires URLs to be absolute, including the domain your site is hosted at. This integration uses the site defined in your Astro config to create the correct URLs for Open Graph which is `site` must be defined.
|
|
98
|
+
|
|
99
|
+
```diff
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
+ site: "https://<your site>.com",
|
|
102
|
+
integrations: [
|
|
103
|
+
opengraphImages({
|
|
104
|
+
options: {
|
|
105
|
+
fonts: [
|
|
106
|
+
{
|
|
107
|
+
name: "Roboto",
|
|
108
|
+
weight: 400,
|
|
109
|
+
style: "normal",
|
|
110
|
+
data: fs.readFileSync("node_modules/@fontsource/roboto/files/roboto-latin-400-normal.woff"),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
render: presets.blackAndWhite,
|
|
115
|
+
}),
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
1. Update your main Astro layout with the appropriate `meta` tags. The [Open Graph site](https://ogp.me/) has more information possible tags.
|
|
96
121
|
|
|
97
122
|
The following `meta` tags must be defined:
|
|
98
123
|
|
|
@@ -102,65 +127,68 @@ You've probably seen this in action when posting a link on Facebook, Twitter, Sl
|
|
|
102
127
|
* See the [Open Graph documentation](https://ogp.me/#types) for valid values.
|
|
103
128
|
* `og:image`
|
|
104
129
|
* Set this to the return value of `getImagePath` (example shown below).
|
|
130
|
+
* If the value of `og:image` does not match what this integration expects then your site will fail to build. This will ensure your site is correctly configured to display Open Graph images.
|
|
105
131
|
* `og:description`
|
|
106
132
|
* Optional. This field may be used when generating images.
|
|
107
133
|
|
|
108
|
-
Your site will fail to build if the tags above are not set.
|
|
134
|
+
Your site will fail to build if the tags above are not set.
|
|
109
135
|
|
|
110
|
-
|
|
136
|
+
* Option 1: Use the [`astro-seo`](https://github.com/jonasmerlin/astro-seo) package:
|
|
111
137
|
|
|
112
|
-
|
|
138
|
+
Install the `astro-seo` package:
|
|
113
139
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
140
|
+
```bash
|
|
141
|
+
npm i astro-seo
|
|
142
|
+
```
|
|
117
143
|
|
|
118
|
-
|
|
144
|
+
Update your Astro layout to use the `SEO` component:
|
|
119
145
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
146
|
+
```diff
|
|
147
|
+
---
|
|
148
|
+
+ import { SEO } from "astro-seo";
|
|
149
|
+
|
|
150
|
+
interface Props {
|
|
151
|
+
title: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const { title } = Astro.props;
|
|
155
|
+
+const { url, site } = Astro;
|
|
156
|
+
+const openGraphImageUrl = getImagePath({ url, site });
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
<!doctype html>
|
|
160
|
+
<html lang="en">
|
|
161
|
+
<head>
|
|
162
|
+
<meta charset="UTF-8" />
|
|
163
|
+
<meta name="description" content="Astro description" />
|
|
164
|
+
<meta name="viewport" content="width=device-width" />
|
|
165
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
166
|
+
<meta name="generator" content={Astro.generator} />
|
|
167
|
+
<title>{title}</title>
|
|
168
|
+
|
|
169
|
+
+ <SEO
|
|
170
|
+
+ openGraph={
|
|
171
|
+
+ {
|
|
172
|
+
+ basic: {
|
|
173
|
+
+ title: title,
|
|
174
|
+
+ type: "website",
|
|
175
|
+
+ image: openGraphImageUrl,
|
|
176
|
+
+ url: url,
|
|
177
|
+
+ },
|
|
178
|
+
+ optional: {
|
|
179
|
+
+ description: "My page description",
|
|
180
|
+
+ },
|
|
181
|
+
+ }
|
|
182
|
+
+ }
|
|
183
|
+
+ />
|
|
184
|
+
</head>
|
|
185
|
+
<body>
|
|
186
|
+
<slot />
|
|
187
|
+
</body>
|
|
188
|
+
</html>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
* Option 2: Manually add the `meta` tags to your Astro layout.
|
|
164
192
|
|
|
165
193
|
1. Build your site. You should see a `.png` file next to each `.html` page in your `dist` folder. Double-check that the `og:image` proprety in your `.html` file matches the path to the `.png` file.
|
|
166
194
|
|
|
@@ -205,14 +233,16 @@ npm i tw-to-css
|
|
|
205
233
|
{{ range $preset := (ds "presets") -}}
|
|
206
234
|
### `{{ strings.ReplaceAll ".png" "" $preset }}`
|
|
207
235
|
|
|
208
|
-
```
|
|
236
|
+
```diff
|
|
209
237
|
import opengraphImages, { presets } from "astro-opengraph-images";
|
|
210
238
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}),
|
|
239
|
+
export default defineConfig({
|
|
240
|
+
integrations: [
|
|
241
|
+
opengraphImages({
|
|
242
|
+
+ render: presets.{{ strings.ReplaceAll ".png" "" $preset }},
|
|
243
|
+
}),
|
|
244
|
+
],
|
|
245
|
+
});
|
|
216
246
|
```
|
|
217
247
|
|
|
218
248
|

|
package/dist/extract.js
CHANGED
|
@@ -44,7 +44,7 @@ export function extract(html) {
|
|
|
44
44
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
45
|
image: image,
|
|
46
46
|
};
|
|
47
|
-
if (description) {
|
|
47
|
+
if (description && description != title) {
|
|
48
48
|
returnVal.description = description;
|
|
49
49
|
}
|
|
50
50
|
return returnVal;
|
package/dist/extract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,iEAAiE;AACjE,2BAA2B;AAC3B,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI;SACR,OAAO,CAAC,yCAAyC,EAAE,EAAE,CAAC;SACtD,OAAO,CAAC,2CAA2C,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAEpE,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,2BAA2B,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1F,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,iCAAiC,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtG,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,yBAAyB,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtF,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACxF,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,2BAA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AAC;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAChC,OAAO,mBAAmB,KAAK,0BAA0B,CAAC;QAC5D,CAAC,CAAC,CAAC;QACH,MAAM,IAAI,KAAK,CACb,+BAA+B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,sCAAsC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxG,CAAC;IACJ,CAAC;IAED,4DAA4D;IAC5D,MAAM,SAAS,GAAgB;QAC7B,oEAAoE;QACpE,KAAK,EAAE,KAAM;QACb,oEAAoE;QACpE,GAAG,EAAE,GAAI;QACT,oEAAoE;QACpE,IAAI,EAAE,IAAK;QACX,oEAAoE;QACpE,KAAK,EAAE,KAAM;KACd,CAAC;IACF,IAAI,WAAW,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;QACxC,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;IACtC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-opengraph-images",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.4",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "husky",
|
|
7
7
|
"lint": "eslint src",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"@types/jsdom": "^21.1.7",
|
|
38
38
|
"@types/node": "^20.14.9",
|
|
39
39
|
"@types/react": "^18.3.3",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
41
|
-
"@typescript-eslint/parser": "^7.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
41
|
+
"@typescript-eslint/parser": "^7.15.0",
|
|
42
42
|
"astro": "^4.11.3",
|
|
43
43
|
"eslint": "^8.57.0",
|
|
44
44
|
"husky": "^9.0.11",
|
|
45
45
|
"install": "^0.13.0",
|
|
46
46
|
"lint-staged": "^15.2.7",
|
|
47
47
|
"prettier": "^3.3.2",
|
|
48
|
-
"typescript": "^5.5.
|
|
49
|
-
"typescript-eslint": "^7.
|
|
48
|
+
"typescript": "^5.5.3",
|
|
49
|
+
"typescript-eslint": "^7.15.0",
|
|
50
50
|
"vitest": "^1.6.0"
|
|
51
51
|
},
|
|
52
52
|
"lint-staged": {
|
package/src/extract.ts
CHANGED
|
@@ -53,7 +53,7 @@ export function extract(html: string): PageDetails {
|
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
54
54
|
image: image!,
|
|
55
55
|
};
|
|
56
|
-
if (description) {
|
|
56
|
+
if (description && description != title) {
|
|
57
57
|
returnVal.description = description;
|
|
58
58
|
}
|
|
59
59
|
return returnVal;
|