Skip to content

Commit 212fd5c

Browse files
authored
fix: remove unused ogImage size validation (#462)
* fix: remove unused ogImage size validation Validation of `ogImage` field in blog collection causes unintentional broken og images after the build. Removing the validation solve the issue. * docs: update docs for ogImage path * chore: update asset
1 parent a4a5ced commit 212fd5c

5 files changed

Lines changed: 19 additions & 28 deletions

File tree

275 KB
Loading

src/content.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ const blog = defineCollection({
1313
featured: z.boolean().optional(),
1414
draft: z.boolean().optional(),
1515
tags: z.array(z.string()).default(["others"]),
16-
ogImage: image()
17-
.refine(img => img.width >= 1200 && img.height >= 630, {
18-
message: "OpenGraph image must be at least 1200 X 630 pixels!",
19-
})
20-
.or(z.string())
21-
.optional(),
16+
ogImage: image().or(z.string()).optional(),
2217
description: z.string(),
2318
canonicalURL: z.string().optional(),
2419
editPost: z

src/data/blog/adding-new-post.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ Frontmatter is the main place to store some important information about the blog
2323

2424
Here is the list of frontmatter property for each post.
2525

26-
| Property | Description | Remark |
27-
| ------------------ | ------------------------------------------------------------------------------------------- | --------------------------------------------- |
28-
| **_title_** | Title of the post. (h1) | required<sup>\*</sup> |
29-
| **_description_** | Description of the post. Used in post excerpt and site description of the post. | required<sup>\*</sup> |
30-
| **_pubDatetime_** | Published datetime in ISO 8601 format. | required<sup>\*</sup> |
31-
| **_modDatetime_** | Modified datetime in ISO 8601 format. (only add this property when a blog post is modified) | optional |
32-
| **_author_** | Author of the post. | default = SITE.author |
33-
| **_slug_** | Slug for the post. This field is optional. | default = slugified file name |
34-
| **_featured_** | Whether or not display this post in featured section of home page | default = false |
35-
| **_draft_** | Mark this post 'unpublished'. | default = false |
36-
| **_tags_** | Related keywords for this post. Written in array yaml format. | default = others |
37-
| **_ogImage_** | OG image of the post. Useful for social media sharing and SEO. | default = SITE.ogImage or generated OG image |
38-
| **_canonicalURL_** | Canonical URL (absolute), in case the article already exists on other source. | default = `Astro.site` + `Astro.url.pathname` |
26+
| Property | Description | Remark |
27+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- |
28+
| **_title_** | Title of the post. (h1) | required<sup>\*</sup> |
29+
| **_description_** | Description of the post. Used in post excerpt and site description of the post. | required<sup>\*</sup> |
30+
| **_pubDatetime_** | Published datetime in ISO 8601 format. | required<sup>\*</sup> |
31+
| **_modDatetime_** | Modified datetime in ISO 8601 format. (only add this property when a blog post is modified) | optional |
32+
| **_author_** | Author of the post. | default = SITE.author |
33+
| **_slug_** | Slug for the post. This field is optional. | default = slugified file name |
34+
| **_featured_** | Whether or not display this post in featured section of home page | default = false |
35+
| **_draft_** | Mark this post 'unpublished'. | default = false |
36+
| **_tags_** | Related keywords for this post. Written in array yaml format. | default = others |
37+
| **_ogImage_** | OG image of the post. Useful for social media sharing and SEO. This can be a remote URL or an image path relative to current folder. | default = `SITE.ogImage` or generated OG image |
38+
| **_canonicalURL_** | Canonical URL (absolute), in case the article already exists on other source. | default = `Astro.site` + `Astro.url.pathname` |
3939

4040
> Tip! You can get ISO 8601 datetime by running `new Date().toISOString()` in the console. Make sure you remove quotes though.
4141
@@ -76,7 +76,8 @@ tags:
7676
- some
7777
- example
7878
- tags
79-
ogImage: ""
79+
ogImage: ../../assets/images/example.png # src/assets/images/example.png
80+
# ogImage: "https://example.org/remote-image.png" # remote URL
8081
description: This is the example description of the example post.
8182
canonicalURL: https://example.org/my-article-was-already-posted-here
8283
---

src/data/blog/how-to-update-dependencies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ pubDatetime: 2023-07-20T15:33:05.569Z
55
slug: how-to-update-dependencies
66
featured: false
77
draft: false
8-
ogImage: /assets/forrest-gump-quote.webp
8+
ogImage: ../../assets/images/forrest-gump-quote.png
99
tags:
1010
- FAQ
1111
description: How to update project dependencies and AstroPaper template.
1212
---
1313

1414
Updating the dependencies of a project can be tedious. However, neglecting to update project dependencies is not a good idea either 😬. In this post, I will share how I usually update my projects, focusing on AstroPaper as an example. Nonetheless, these steps can be applied to other js/node projects as well.
1515

16-
![Forrest Gump Fake Quote](/assets/forrest-gump-quote.webp)
16+
![Forrest Gump Fake Quote](@/assets/images/forrest-gump-quote.png)
1717

1818
## Table of contents
1919

src/data/blog/setting-dates-via-git-hooks.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,7 @@ const blog = defineCollection({
155155
featured: z.boolean().optional(),
156156
draft: z.boolean().optional(),
157157
tags: z.array(z.string()).default(["others"]),
158-
ogImage: image()
159-
.refine(img => img.width >= 1200 && img.height >= 630, {
160-
message: "OpenGraph image must be at least 1200 X 630 pixels!",
161-
})
162-
.or(z.string())
163-
.optional(),
158+
ogImage: image().or(z.string()).optional(),
164159
description: z.string(),
165160
canonicalURL: z.string().optional(),
166161
readingTime: z.string().optional(),

0 commit comments

Comments
 (0)