Skip to content

Commit

Permalink
add docs for FeedXSLTOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Aug 2, 2024
1 parent cbb91f9 commit 221e695
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ declare module '@docusaurus/plugin-content-blog' {
onInlineAuthors: 'ignore' | 'log' | 'warn' | 'throw';
};

export type UserFeedXSLTOptions =
| boolean
| null
| {
rss?: string | boolean | null;
atom?: string | boolean | null;
};

/**
* Feed options, as provided by user config. `type` accepts `all` as shortcut
*/
Expand All @@ -532,13 +540,7 @@ declare module '@docusaurus/plugin-content-blog' {
/** Type of feed to be generated. Use `null` to disable generation. */
type?: FeedOptions['type'] | 'all' | FeedType;
/** User-provided XSLT config for feeds, un-normalized */
xslt?:
| boolean
| null
| {
rss?: string | boolean | null;
atom?: string | boolean | null;
};
xslt?: UserFeedXSLTOptions;
}
>;
/**
Expand Down
20 changes: 20 additions & 0 deletions website/docs/api/plugins/plugin-content-blog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Accepted fields:
| `feedOptions.title` | `string` | `siteConfig.title` | Title of the feed. |
| `feedOptions.description` | `string` | <code>\`$\{siteConfig.title} Blog\`</code> | Description of the feed. |
| `feedOptions.copyright` | `string` | `undefined` | Copyright message. |
| `feedOptions.xslt` | <code>boolean \| [FeedXSLTOptions](#FeedXSLTOptions)</code> | `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...). |
Expand Down Expand Up @@ -129,6 +130,25 @@ type ReadingTimeFn = (params: {
type FeedType = 'rss' | 'atom' | 'json';
```

#### `FeedXSLTOptions` {#FeedXSLTOptions}

Permits to style the blog XML feeds so that browsers render them nicely with [XSLT](https://developer.mozilla.org/en-US/docs/Web/XSLT).

- Use `true` to let the blog use its built-in `.xsl` and `.css` files to style the blog feed
- Use a falsy value (`undefined | null | false`) to disable the feature
- Use a `string` to provide a file path to a custom `.xsl` file relative to the blog content folder. By convention, you must provide a `.css` file with the exact same name.

```ts
type FeedXSLTOptions =
| boolean
| undefined
| null
| {
rss?: string | boolean | null | undefined;
atom?: string | boolean | null | undefined;
};
```

#### `CreateFeedItemsFn` {#CreateFeedItemsFn}

```ts
Expand Down
11 changes: 10 additions & 1 deletion website/docs/blog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,18 @@ type BlogOptions = {
title?: string;
description?: string;
copyright: string;
language?: string; // possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
limit?: number | false | null; // defaults to 20
/** Allow control over the construction of BlogFeedItems */
// XSLT permits browsers to style and render nicely the feed XML files
xslt?:
| boolean
| {
//
rss?: string | boolean;
atom?: string | boolean;
};
// Allow control over the construction of BlogFeedItems
createFeedItems?: (params: {
blogPosts: BlogPost[];
siteConfig: DocusaurusConfig;
Expand Down

0 comments on commit 221e695

Please sign in to comment.