@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.cjs +265 -289
- package/dist/index.d.ts +156 -141
- package/dist/index.mjs +212 -247
- package/package.json +8 -9
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
@@ -1,141 +1,156 @@
|
|
1
|
-
import {
|
2
|
-
import { Feed
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
*
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
declare
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
declare
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
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 { }
|