@quartz-community/og-image 0.1.0
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 +12 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +24365 -0
- package/dist/index.js.map +1 -0
- package/package.json +137 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial Quartz community plugin template.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Quartz Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @quartz-community/og-image
|
|
2
|
+
|
|
3
|
+
Generates Open Graph social preview images for each page using Satori and Sharp.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx quartz plugin add github:quartz-community/og-image
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```yaml title="quartz.config.yaml"
|
|
14
|
+
plugins:
|
|
15
|
+
- source: github:quartz-community/og-image
|
|
16
|
+
enabled: true
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For advanced use cases, you can override in TypeScript:
|
|
20
|
+
|
|
21
|
+
```ts title="quartz.ts (override)"
|
|
22
|
+
import * as ExternalPlugin from "./.quartz/plugins";
|
|
23
|
+
|
|
24
|
+
ExternalPlugin.CustomOgImages({
|
|
25
|
+
colorScheme: "lightMode",
|
|
26
|
+
width: 1200,
|
|
27
|
+
height: 630,
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
| Option | Type | Default | Description |
|
|
34
|
+
| -------------------- | ----------------------------- | --------------------------- | ------------------------------------------------------------ |
|
|
35
|
+
| `colorScheme` | `"lightMode" \| "darkMode"` | `"lightMode"` | The color scheme to use for the generated images. |
|
|
36
|
+
| `width` | `number` | `1200` | The width of the generated images. |
|
|
37
|
+
| `height` | `number` | `630` | The height of the generated images. |
|
|
38
|
+
| `excludeRoot` | `boolean` | `false` | Whether to exclude the root page from image generation. |
|
|
39
|
+
| `defaultTitle` | `string` | `"Untitled"` | The default title to use if a page has no title. |
|
|
40
|
+
| `defaultDescription` | `string` | `"No description provided"` | The default description to use if a page has no description. |
|
|
41
|
+
| `readingTimeText` | `(minutes: number) => string` | `undefined` | A function to format the reading time text. |
|
|
42
|
+
| `imageStructure` | `function` | `undefined` | A function to define the structure of the generated image. |
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
See the [Quartz documentation](https://quartz.jzhao.xyz/plugins/CustomOgImages) for more information.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { SatoriOptions } from 'satori';
|
|
2
|
+
import { QuartzEmitterPlugin, ThemeKey, GlobalConfiguration, FullSlug } from '@quartz-community/types';
|
|
3
|
+
export { QuartzEmitterPlugin } from '@quartz-community/types';
|
|
4
|
+
import { JSX } from 'preact';
|
|
5
|
+
|
|
6
|
+
type Frontmatter = {
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
socialDescription?: string;
|
|
10
|
+
socialImage?: string;
|
|
11
|
+
tags?: string[];
|
|
12
|
+
} & Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Page data passed to user-provided `imageStructure` callbacks.
|
|
15
|
+
*
|
|
16
|
+
* This is deliberately narrower than `@quartz-community/types`'
|
|
17
|
+
* `QuartzPluginData`: it documents exactly which fields the og-image
|
|
18
|
+
* emitter promises to populate before invoking `imageStructure`. The
|
|
19
|
+
* extra `text?` field is synthesised by this plugin from the page's
|
|
20
|
+
* rendered content prior to the callback.
|
|
21
|
+
*
|
|
22
|
+
* Do NOT replace this with `QuartzPluginData`: doing so would advertise
|
|
23
|
+
* fields (e.g. `htmlAst`) that this emitter does not pass through.
|
|
24
|
+
*/
|
|
25
|
+
type SocialImageFileData = {
|
|
26
|
+
slug?: FullSlug;
|
|
27
|
+
frontmatter?: Frontmatter;
|
|
28
|
+
description?: string;
|
|
29
|
+
text?: string;
|
|
30
|
+
filePath?: string;
|
|
31
|
+
dates?: Record<string, Date>;
|
|
32
|
+
};
|
|
33
|
+
type SocialImageOptions = {
|
|
34
|
+
colorScheme: ThemeKey;
|
|
35
|
+
height: number;
|
|
36
|
+
width: number;
|
|
37
|
+
excludeRoot: boolean;
|
|
38
|
+
defaultTitle?: string;
|
|
39
|
+
defaultDescription?: string;
|
|
40
|
+
readingTimeText?: (minutes: number) => string;
|
|
41
|
+
imageStructure: (options: ImageOptions & {
|
|
42
|
+
userOpts: UserOpts;
|
|
43
|
+
iconBase64?: string;
|
|
44
|
+
}) => JSX.Element;
|
|
45
|
+
};
|
|
46
|
+
type UserOpts = Omit<SocialImageOptions, "imageStructure">;
|
|
47
|
+
type ImageOptions = {
|
|
48
|
+
title: string;
|
|
49
|
+
description: string;
|
|
50
|
+
fonts: SatoriOptions["fonts"];
|
|
51
|
+
cfg: GlobalConfiguration;
|
|
52
|
+
fileData: SocialImageFileData;
|
|
53
|
+
};
|
|
54
|
+
declare const CustomOgImagesEmitterName = "CustomOgImages";
|
|
55
|
+
declare const CustomOgImages: QuartzEmitterPlugin<Partial<SocialImageOptions>>;
|
|
56
|
+
|
|
57
|
+
export { CustomOgImages, CustomOgImagesEmitterName, type ImageOptions, type SocialImageFileData, type SocialImageOptions, type UserOpts };
|