feat(blog): allow processing blog posts through a processBlogPosts function (#9886)

Co-authored-by: OzakIOne <OzakIOne@users.noreply.github.com>
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
ozaki 2024-03-05 22:58:16 +01:00 committed by GitHub
parent 05279dc3d8
commit 2851c93d0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 400 additions and 6 deletions

View file

@ -75,6 +75,7 @@ Accepted fields:
| `feedOptions.copyright` | `string` | `undefined` | Copyright message. |
| `feedOptions.language` | `string` (See [documentation](http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes) for possible values) | `undefined` | Language metadata of the feed. |
| `sortPosts` | <code>'descending' \| 'ascending' </code> | `'descending'` | Governs the direction of blog post sorting. |
| `processBlogPosts` | <code>[ProcessBlogPostsFn](#ProcessBlogPostsFn)</code> | `undefined` | An optional function which can be used to transform blog posts (filter, modify, delete, etc...). |
```mdx-code-block
</APITable>
@ -131,6 +132,14 @@ type CreateFeedItemsFn = (params: {
}) => Promise<BlogFeedItem[]>;
```
#### `ProcessBlogPostsFn` {#ProcessBlogPostsFn}
```ts
type ProcessBlogPostsFn = (params: {
blogPosts: BlogPost[];
}) => Promise<void | BlogPost[]>;
```
### Example configuration {#ex-config}
You can configure this plugin through preset options or plugin options.