mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-05-18 14:34:23 +02:00
Merge 73fc1ce95913103d07fb7cf20e44bd1015178b3c into 7be47742a6dc86f22d148ca9d304f7a9eea318cf
This commit is contained in:
commit
081aa2ba9a
@ -45,7 +45,11 @@ The following properties can be used to customize your link previews:
|
||||
| `socialDescription` | `description` | Description to be used for preview. |
|
||||
| `socialImage` | `image`, `cover` | Link to preview image. |
|
||||
|
||||
The `socialImage` property should contain a link to an image relative to `quartz/static`. If you have a folder for all your images in `quartz/static/my-images`, an example for `socialImage` could be `"my-images/cover.png"`.
|
||||
The `socialImage` property should be a link to an image. It can be relative to your base URL, or you can provide a full URL with scheme (HTTP protocol only). For example:
|
||||
|
||||
1. If you have an image `cover.png` in `quartz/static/`, the `socialImage` value could be `"static/cover.png"`.
|
||||
2. If your image is in `content/assets/`, then the `socialImage` value would become `"assets/cover.png"`.
|
||||
3. If your image is hosted elsewhere, say `https://example.com/cover.png`, then the `socialImage` value should be `"https://example.com/cover.png"`.
|
||||
|
||||
> [!info] Info
|
||||
>
|
||||
|
@ -44,6 +44,8 @@ const defaultOptions: SocialImageOptions = {
|
||||
excludeRoot: false,
|
||||
}
|
||||
|
||||
const urlSchemeRegex = new RegExp("^(http|https)://", "i")
|
||||
|
||||
export default (() => {
|
||||
let fontsPromise: Promise<SatoriOptions["fonts"]>
|
||||
|
||||
@ -147,7 +149,9 @@ export default (() => {
|
||||
|
||||
// Override with frontmatter url if existing
|
||||
if (frontmatterImgUrl) {
|
||||
ogImagePath = `https://${cfg.baseUrl}/static/${frontmatterImgUrl}`
|
||||
ogImagePath = urlSchemeRegex.test(frontmatterImgUrl)
|
||||
? frontmatterImgUrl
|
||||
: `https://${cfg.baseUrl}/${frontmatterImgUrl}`
|
||||
}
|
||||
|
||||
// Url of current page
|
||||
|
Loading…
x
Reference in New Issue
Block a user