@rspress/plugin-rss 1.41.0 → 1.41.2

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/dist/index.d.ts CHANGED
@@ -1,141 +1,156 @@
1
- import { PageIndexInfo, RspressPlugin, UserConfig } from '@rspress/shared';
2
- import { Feed, Item, FeedOptions, Author } from 'feed';
3
-
4
- interface ResolvedOutput {
5
- type: FeedOutputType;
6
- mime: string;
7
- filename: string;
8
- getContent: (feed: Feed) => string;
9
- dir: string;
10
- publicPath: string;
11
- url: string;
12
- sorting: (left: FeedItem, right: FeedItem) => number;
13
- }
14
-
15
- type PartialPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
16
-
17
- /**
18
- * feed information attached in `PageIndexInfo['feeds']` array
19
- */
20
- interface PageFeedData {
21
- url: string;
22
- language: string;
23
- mime: string;
24
- }
25
- type FeedItem = Item;
26
- /**
27
- * output feed file type
28
- */
29
- type FeedOutputType = /** Atom 1.0 Feed */ 'atom' | /** RSS 2.0 Feed */ 'rss' | /** JSON1 Feed */ 'json';
30
- /**
31
- * output config of a feed.
32
- * a feed will be written into path `${rspress.outDir || 'doc_build'}/${dir}/${filename}`
33
- */
34
- interface FeedOutputOptions {
35
- /**
36
- * output dir of feed files, relative to rspress's outDir
37
- */
38
- dir?: string;
39
- /**
40
- * type of feed files
41
- */
42
- type?: FeedOutputType;
43
- /**
44
- * base filename of feed files. `${id}.${extension by type}` by default.
45
- */
46
- filename?: string;
47
- /**
48
- * public path of feed files. siteUrl by default
49
- */
50
- publicPath?: string;
51
- /**
52
- * sort feed items
53
- */
54
- sorting?: (left: FeedItem, right: FeedItem) => number;
55
- }
56
- interface FeedChannel extends PartialPartial<FeedOptions, 'title' | 'copyright'> {
57
- /**
58
- * used as the basename of rss file, should be unique
59
- **/
60
- id: string;
61
- /**
62
- * to match pages that should be listed in this feed
63
- * if RegExp is given, it will match against the route path of each page
64
- **/
65
- test: RegExp | string | (RegExp | string)[] | ((item: PageIndexInfo, base: string) => boolean);
66
- /**
67
- * a function to modify feed item
68
- * @param item pre-generated feed item
69
- * @param page page data
70
- * @param base base path of the rspress site
71
- * @returns modified feed item
72
- */
73
- item?: (item: FeedItem, page: PageIndexInfo, base: string) => FeedItem | PromiseLike<FeedItem>;
74
- /**
75
- * feed level output config
76
- */
77
- output?: FeedOutputOptions;
78
- }
79
- /**
80
- * plugin options for `pluginRss`
81
- */
82
- interface PluginRssOptions {
83
- /**
84
- * site url of this rspress site. it will be used in feed files and feed link.
85
- * @requires
86
- */
87
- siteUrl: string;
88
- /**
89
- * Feed options for each rss. If array is given, this plugin will produce multiple feed files.
90
- * @default {{ id: 'blog', test: /^\/blog\// }}
91
- */
92
- feed?: PartialPartial<FeedChannel, 'id' | 'test'> | FeedChannel[];
93
- /**
94
- * output config for all feed files
95
- */
96
- output?: Omit<FeedOutputOptions, 'filename'>;
97
- }
98
-
99
- declare function pluginRss(pluginRssOptions: PluginRssOptions): RspressPlugin;
100
-
101
- declare const PluginName = "@rspress/plugin-rss";
102
- declare const PluginComponents: {
103
- readonly FeedsAnnotations: "@rspress/plugin-rss/FeedsAnnotations";
104
- };
105
-
106
- declare function testPage(test: FeedChannel['test'], page: PageIndexInfo, base?: string): boolean;
107
- declare function getDefaultFeedOption(): {
108
- id: string;
109
- test: string;
110
- };
111
- declare function getFeedFileType(type: FeedOutputType): {
112
- extension: string;
113
- mime: string;
114
- getContent: (feed: Feed) => string;
115
- };
116
- declare function getOutputInfo({ id, output }: Pick<FeedChannel, 'id' | 'output'>, { siteUrl, output: globalOutput, }: Pick<PluginRssOptions, 'output' | 'siteUrl'>): ResolvedOutput;
117
-
118
- /**
119
- * @public
120
- * @param page Rspress Page Data
121
- * @param siteUrl
122
- */
123
- declare function generateFeedItem(page: PageIndexInfo, siteUrl: string): {
124
- id: string;
125
- title: string;
126
- author: Author[] | undefined;
127
- link: string;
128
- description: string;
129
- content: string;
130
- date: Date;
131
- category: {
132
- name: string;
133
- }[];
134
- };
135
- declare function createFeed(options: Omit<FeedChannel, 'test' | 'item' | 'output'> & {
136
- item?: any;
137
- test?: any;
138
- output: ResolvedOutput;
139
- }, config: UserConfig): FeedOptions;
140
-
141
- export { type FeedChannel, type FeedItem, type FeedOutputOptions, type FeedOutputType, type PageFeedData, PluginComponents, PluginName, type PluginRssOptions, createFeed, generateFeedItem, getDefaultFeedOption, getFeedFileType, getOutputInfo, pluginRss, testPage };
1
+ import type { Author } from 'feed';
2
+ import type { Feed } from 'feed';
3
+ import type { FeedOptions } from 'feed';
4
+ import type { Item } from 'feed';
5
+ import type { PageIndexInfo } from '@rspress/shared';
6
+ import type { RspressPlugin } from '@rspress/shared';
7
+ import type { UserConfig } from '@rspress/shared';
8
+
9
+ export declare function createFeed(options: Omit<FeedChannel, 'test' | 'item' | 'output'> & {
10
+ item?: any;
11
+ test?: any;
12
+ output: ResolvedOutput;
13
+ }, config: UserConfig): FeedOptions;
14
+
15
+ export declare interface FeedChannel extends PartialPartial<FeedOptions, 'title' | 'copyright'> {
16
+ /**
17
+ * used as the basename of rss file, should be unique
18
+ **/
19
+ id: string;
20
+ /**
21
+ * to match pages that should be listed in this feed
22
+ * if RegExp is given, it will match against the route path of each page
23
+ **/
24
+ test: RegExp | string | (RegExp | string)[] | ((item: PageIndexInfo, base: string) => boolean);
25
+ /**
26
+ * a function to modify feed item
27
+ * @param item pre-generated feed item
28
+ * @param page page data
29
+ * @param base base path of the rspress site
30
+ * @returns modified feed item
31
+ */
32
+ item?: (item: FeedItem, page: PageIndexInfo, base: string) => FeedItem | PromiseLike<FeedItem>;
33
+ /**
34
+ * feed level output config
35
+ */
36
+ output?: FeedOutputOptions;
37
+ }
38
+
39
+ export declare type FeedItem = Item;
40
+
41
+ /**
42
+ * output config of a feed.
43
+ * a feed will be written into path `${rspress.outDir || 'doc_build'}/${dir}/${filename}`
44
+ */
45
+ export declare interface FeedOutputOptions {
46
+ /**
47
+ * output dir of feed files, relative to rspress's outDir
48
+ */
49
+ dir?: string;
50
+ /**
51
+ * type of feed files
52
+ */
53
+ type?: FeedOutputType;
54
+ /**
55
+ * base filename of feed files. `${id}.${extension by type}` by default.
56
+ */
57
+ filename?: string;
58
+ /**
59
+ * public path of feed files. siteUrl by default
60
+ */
61
+ publicPath?: string;
62
+ /**
63
+ * sort feed items
64
+ */
65
+ sorting?: (left: FeedItem, right: FeedItem) => number;
66
+ }
67
+
68
+ /**
69
+ * output feed file type
70
+ */
71
+ export declare type FeedOutputType = /** Atom 1.0 Feed */ 'atom' | /** RSS 2.0 Feed */ 'rss' | /** JSON1 Feed */ 'json';
72
+
73
+ /**
74
+ * @public
75
+ * @param page Rspress Page Data
76
+ * @param siteUrl
77
+ */
78
+ export declare function generateFeedItem(page: PageIndexInfo, siteUrl: string): {
79
+ id: string;
80
+ title: string;
81
+ author: Author[] | undefined;
82
+ link: string;
83
+ description: string;
84
+ content: string;
85
+ date: Date;
86
+ category: {
87
+ name: string;
88
+ }[];
89
+ };
90
+
91
+ export declare function getDefaultFeedOption(): {
92
+ id: string;
93
+ test: string;
94
+ };
95
+
96
+ export declare function getFeedFileType(type: FeedOutputType): {
97
+ extension: string;
98
+ mime: string;
99
+ getContent: (feed: Feed) => string;
100
+ };
101
+
102
+ export declare function getOutputInfo({ id, output }: Pick<FeedChannel, 'id' | 'output'>, { siteUrl, output: globalOutput, }: Pick<PluginRssOptions, 'output' | 'siteUrl'>): ResolvedOutput;
103
+
104
+ /**
105
+ * feed information attached in `PageIndexInfo['feeds']` array
106
+ */
107
+ export declare interface PageFeedData {
108
+ url: string;
109
+ language: string;
110
+ mime: string;
111
+ }
112
+
113
+ declare type PartialPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
114
+
115
+ export declare const PluginComponents: {
116
+ readonly FeedsAnnotations: "@rspress/plugin-rss/FeedsAnnotations";
117
+ };
118
+
119
+ export declare const PluginName = "@rspress/plugin-rss";
120
+
121
+ export declare function pluginRss(pluginRssOptions: PluginRssOptions): RspressPlugin;
122
+
123
+ /**
124
+ * plugin options for `pluginRss`
125
+ */
126
+ export declare interface PluginRssOptions {
127
+ /**
128
+ * site url of this rspress site. it will be used in feed files and feed link.
129
+ * @requires
130
+ */
131
+ siteUrl: string;
132
+ /**
133
+ * Feed options for each rss. If array is given, this plugin will produce multiple feed files.
134
+ * @default {{ id: 'blog', test: /^\/blog\// }}
135
+ */
136
+ feed?: PartialPartial<FeedChannel, 'id' | 'test'> | FeedChannel[];
137
+ /**
138
+ * output config for all feed files
139
+ */
140
+ output?: Omit<FeedOutputOptions, 'filename'>;
141
+ }
142
+
143
+ declare interface ResolvedOutput {
144
+ type: FeedOutputType;
145
+ mime: string;
146
+ filename: string;
147
+ getContent: (feed: Feed) => string;
148
+ dir: string;
149
+ publicPath: string;
150
+ url: string;
151
+ sorting: (left: FeedItem, right: FeedItem) => number;
152
+ }
153
+
154
+ export declare function testPage(test: FeedChannel['test'], page: PageIndexInfo, base?: string): boolean;
155
+
156
+ export { }