@docusaurus/plugin-content-blog 2.0.0-beta.fc64c12e4 → 2.0.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.
Files changed (60) hide show
  1. package/lib/authors.d.ts +22 -0
  2. package/lib/authors.js +122 -0
  3. package/lib/blogUtils.d.ts +27 -7
  4. package/lib/blogUtils.js +201 -145
  5. package/lib/feed.d.ts +15 -0
  6. package/lib/feed.js +102 -0
  7. package/lib/frontMatter.d.ts +10 -0
  8. package/lib/{blogFrontMatter.js → frontMatter.js} +31 -19
  9. package/lib/index.d.ts +4 -4
  10. package/lib/index.js +163 -194
  11. package/lib/markdownLoader.d.ts +3 -6
  12. package/lib/markdownLoader.js +6 -7
  13. package/lib/options.d.ts +10 -0
  14. package/lib/{pluginOptionSchema.js → options.js} +41 -14
  15. package/lib/remark/footnoteIDFixer.d.ts +14 -0
  16. package/lib/remark/footnoteIDFixer.js +29 -0
  17. package/lib/translations.d.ts +10 -0
  18. package/lib/translations.js +53 -0
  19. package/lib/types.d.ts +4 -110
  20. package/package.json +23 -19
  21. package/src/authors.ts +168 -0
  22. package/src/blogUtils.ts +305 -205
  23. package/src/feed.ts +171 -0
  24. package/src/frontMatter.ts +81 -0
  25. package/src/index.ts +223 -258
  26. package/src/markdownLoader.ts +11 -16
  27. package/src/{pluginOptionSchema.ts → options.ts} +54 -16
  28. package/src/plugin-content-blog.d.ts +587 -0
  29. package/src/remark/footnoteIDFixer.ts +29 -0
  30. package/src/translations.ts +69 -0
  31. package/src/types.ts +2 -129
  32. package/index.d.ts +0 -138
  33. package/lib/.tsbuildinfo +0 -1
  34. package/lib/blogFrontMatter.d.ts +0 -28
  35. package/lib/pluginOptionSchema.d.ts +0 -34
  36. package/src/__tests__/__fixtures__/website/blog/2018-12-14-Happy-First-Birthday-Slash.md +0 -5
  37. package/src/__tests__/__fixtures__/website/blog/_partials/somePartial.md +0 -3
  38. package/src/__tests__/__fixtures__/website/blog/_partials/subfolder/somePartial.md +0 -3
  39. package/src/__tests__/__fixtures__/website/blog/_somePartial.md +0 -3
  40. package/src/__tests__/__fixtures__/website/blog/complex-slug.md +0 -7
  41. package/src/__tests__/__fixtures__/website/blog/date-matter.md +0 -5
  42. package/src/__tests__/__fixtures__/website/blog/draft.md +0 -6
  43. package/src/__tests__/__fixtures__/website/blog/heading-as-title.md +0 -5
  44. package/src/__tests__/__fixtures__/website/blog/simple-slug.md +0 -7
  45. package/src/__tests__/__fixtures__/website/blog-with-ref/2018-12-14-Happy-First-Birthday-Slash.md +0 -5
  46. package/src/__tests__/__fixtures__/website/blog-with-ref/post-with-broken-links.md +0 -11
  47. package/src/__tests__/__fixtures__/website/blog-with-ref/post.md +0 -5
  48. package/src/__tests__/__fixtures__/website/i18n/en/docusaurus-plugin-content-blog/2018-12-14-Happy-First-Birthday-Slash.md +0 -5
  49. package/src/__tests__/__fixtures__/website-blog-without-date/blog/no date.md +0 -1
  50. package/src/__tests__/__snapshots__/generateBlogFeed.test.ts.snap +0 -116
  51. package/src/__tests__/__snapshots__/linkify.test.ts.snap +0 -24
  52. package/src/__tests__/__snapshots__/pluginOptionSchema.test.ts.snap +0 -5
  53. package/src/__tests__/blogFrontMatter.test.ts +0 -317
  54. package/src/__tests__/generateBlogFeed.test.ts +0 -102
  55. package/src/__tests__/index.test.ts +0 -336
  56. package/src/__tests__/linkify.test.ts +0 -93
  57. package/src/__tests__/pluginOptionSchema.test.ts +0 -150
  58. package/src/blogFrontMatter.ts +0 -88
  59. package/tsconfig.json +0 -9
  60. package/types.d.ts +0 -13
@@ -1,116 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`blogFeed atom should not show feed without posts 1`] = `null`;
4
-
5
- exports[`blogFeed atom shows feed item for each post 1`] = `
6
- "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
7
- <feed xmlns=\\"http://www.w3.org/2005/Atom\\">
8
- <id>https://docusaurus.io/myBaseUrl/blog</id>
9
- <title>Hello Blog</title>
10
- <updated>2020-08-16T00:00:00.000Z</updated>
11
- <generator>https://github.com/jpmonette/feed</generator>
12
- <link rel=\\"alternate\\" href=\\"https://docusaurus.io/myBaseUrl/blog\\"/>
13
- <subtitle>Hello Blog</subtitle>
14
- <icon>https://docusaurus.io/myBaseUrl/image/favicon.ico</icon>
15
- <rights>Copyright</rights>
16
- <entry>
17
- <title type=\\"html\\"><![CDATA[Complex Slug]]></title>
18
- <id>/hey/my super path/héllô</id>
19
- <link href=\\"https://docusaurus.io/myBaseUrl/blog/hey/my super path/héllô\\"/>
20
- <updated>2020-08-16T00:00:00.000Z</updated>
21
- <summary type=\\"html\\"><![CDATA[complex url slug]]></summary>
22
- </entry>
23
- <entry>
24
- <title type=\\"html\\"><![CDATA[Simple Slug]]></title>
25
- <id>/simple/slug</id>
26
- <link href=\\"https://docusaurus.io/myBaseUrl/blog/simple/slug\\"/>
27
- <updated>2020-08-15T00:00:00.000Z</updated>
28
- <summary type=\\"html\\"><![CDATA[simple url slug]]></summary>
29
- </entry>
30
- <entry>
31
- <title type=\\"html\\"><![CDATA[draft]]></title>
32
- <id>draft</id>
33
- <link href=\\"https://docusaurus.io/myBaseUrl/blog/draft\\"/>
34
- <updated>2020-02-27T00:00:00.000Z</updated>
35
- <summary type=\\"html\\"><![CDATA[this post should not be published yet]]></summary>
36
- </entry>
37
- <entry>
38
- <title type=\\"html\\"><![CDATA[some heading]]></title>
39
- <id>some heading</id>
40
- <link href=\\"https://docusaurus.io/myBaseUrl/blog/heading-as-title\\"/>
41
- <updated>2019-01-02T00:00:00.000Z</updated>
42
- </entry>
43
- <entry>
44
- <title type=\\"html\\"><![CDATA[date-matter]]></title>
45
- <id>date-matter</id>
46
- <link href=\\"https://docusaurus.io/myBaseUrl/blog/date-matter\\"/>
47
- <updated>2019-01-01T00:00:00.000Z</updated>
48
- <summary type=\\"html\\"><![CDATA[date inside front matter]]></summary>
49
- </entry>
50
- <entry>
51
- <title type=\\"html\\"><![CDATA[Happy 1st Birthday Slash! (translated)]]></title>
52
- <id>Happy 1st Birthday Slash! (translated)</id>
53
- <link href=\\"https://docusaurus.io/myBaseUrl/blog/2018/12/14/Happy-First-Birthday-Slash\\"/>
54
- <updated>2018-12-14T00:00:00.000Z</updated>
55
- <summary type=\\"html\\"><![CDATA[Happy birthday! (translated)]]></summary>
56
- </entry>
57
- </feed>"
58
- `;
59
-
60
- exports[`blogFeed rss should not show feed without posts 1`] = `null`;
61
-
62
- exports[`blogFeed rss shows feed item for each post 1`] = `
63
- "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
64
- <rss version=\\"2.0\\">
65
- <channel>
66
- <title>Hello Blog</title>
67
- <link>https://docusaurus.io/myBaseUrl/blog</link>
68
- <description>Hello Blog</description>
69
- <lastBuildDate>Sun, 16 Aug 2020 00:00:00 GMT</lastBuildDate>
70
- <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
71
- <generator>https://github.com/jpmonette/feed</generator>
72
- <copyright>Copyright</copyright>
73
- <item>
74
- <title><![CDATA[Complex Slug]]></title>
75
- <link>https://docusaurus.io/myBaseUrl/blog/hey/my super path/héllô</link>
76
- <guid>/hey/my super path/héllô</guid>
77
- <pubDate>Sun, 16 Aug 2020 00:00:00 GMT</pubDate>
78
- <description><![CDATA[complex url slug]]></description>
79
- </item>
80
- <item>
81
- <title><![CDATA[Simple Slug]]></title>
82
- <link>https://docusaurus.io/myBaseUrl/blog/simple/slug</link>
83
- <guid>/simple/slug</guid>
84
- <pubDate>Sat, 15 Aug 2020 00:00:00 GMT</pubDate>
85
- <description><![CDATA[simple url slug]]></description>
86
- </item>
87
- <item>
88
- <title><![CDATA[draft]]></title>
89
- <link>https://docusaurus.io/myBaseUrl/blog/draft</link>
90
- <guid>draft</guid>
91
- <pubDate>Thu, 27 Feb 2020 00:00:00 GMT</pubDate>
92
- <description><![CDATA[this post should not be published yet]]></description>
93
- </item>
94
- <item>
95
- <title><![CDATA[some heading]]></title>
96
- <link>https://docusaurus.io/myBaseUrl/blog/heading-as-title</link>
97
- <guid>some heading</guid>
98
- <pubDate>Wed, 02 Jan 2019 00:00:00 GMT</pubDate>
99
- </item>
100
- <item>
101
- <title><![CDATA[date-matter]]></title>
102
- <link>https://docusaurus.io/myBaseUrl/blog/date-matter</link>
103
- <guid>date-matter</guid>
104
- <pubDate>Tue, 01 Jan 2019 00:00:00 GMT</pubDate>
105
- <description><![CDATA[date inside front matter]]></description>
106
- </item>
107
- <item>
108
- <title><![CDATA[Happy 1st Birthday Slash! (translated)]]></title>
109
- <link>https://docusaurus.io/myBaseUrl/blog/2018/12/14/Happy-First-Birthday-Slash</link>
110
- <guid>Happy 1st Birthday Slash! (translated)</guid>
111
- <pubDate>Fri, 14 Dec 2018 00:00:00 GMT</pubDate>
112
- <description><![CDATA[Happy birthday! (translated)]]></description>
113
- </item>
114
- </channel>
115
- </rss>"
116
- `;
@@ -1,24 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`report broken markdown links 1`] = `
4
- "---
5
- title: This post links to another one!
6
- ---
7
-
8
- [Good link 1](/blog/2018/12/14/Happy-First-Birthday-Slash)
9
-
10
- [Good link 2](/blog/2018/12/14/Happy-First-Birthday-Slash)
11
-
12
- [Bad link 1](postNotExist1.md)
13
-
14
- [Bad link 1](./postNotExist2.mdx)
15
- "
16
- `;
17
-
18
- exports[`transform to correct link 1`] = `
19
- "---
20
- title: This post links to another one!
21
- ---
22
-
23
- [Linked post](/blog/2018/12/14/Happy-First-Birthday-Slash)"
24
- `;
@@ -1,5 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`should throw Error in case of invalid feedtype 1`] = `[ValidationError: "feedOptions.type" does not match any of the allowed types]`;
4
-
5
- exports[`should throw Error in case of invalid options 1`] = `[ValidationError: "postsPerPage" must be greater than or equal to 1]`;
@@ -1,317 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import {
9
- BlogPostFrontMatter,
10
- validateBlogPostFrontMatter,
11
- } from '../blogFrontMatter';
12
- import escapeStringRegexp from 'escape-string-regexp';
13
-
14
- function testField(params: {
15
- fieldName: keyof BlogPostFrontMatter;
16
- validFrontMatters: BlogPostFrontMatter[];
17
- convertibleFrontMatter?: [
18
- ConvertableFrontMatter: Record<string, unknown>,
19
- ConvertedFrontMatter: BlogPostFrontMatter,
20
- ][];
21
- invalidFrontMatters?: [
22
- InvalidFrontMatter: Record<string, unknown>,
23
- ErrorMessage: string,
24
- ][];
25
- }) {
26
- describe(`"${params.fieldName}" field`, () => {
27
- test('accept valid values', () => {
28
- params.validFrontMatters.forEach((frontMatter) => {
29
- expect(validateBlogPostFrontMatter(frontMatter)).toEqual(frontMatter);
30
- });
31
- });
32
-
33
- test('convert valid values', () => {
34
- params.convertibleFrontMatter?.forEach(
35
- ([convertibleFrontMatter, convertedFrontMatter]) => {
36
- expect(validateBlogPostFrontMatter(convertibleFrontMatter)).toEqual(
37
- convertedFrontMatter,
38
- );
39
- },
40
- );
41
- });
42
-
43
- test('throw error for values', () => {
44
- params.invalidFrontMatters?.forEach(([frontMatter, message]) => {
45
- try {
46
- validateBlogPostFrontMatter(frontMatter);
47
- fail(
48
- new Error(
49
- `Blog frontmatter is expected to be rejected, but was accepted successfully:\n ${JSON.stringify(
50
- frontMatter,
51
- null,
52
- 2,
53
- )}`,
54
- ),
55
- );
56
- } catch (e) {
57
- expect(e.message).toMatch(new RegExp(escapeStringRegexp(message)));
58
- }
59
- });
60
- });
61
- });
62
- }
63
-
64
- describe('validateBlogPostFrontMatter', () => {
65
- test('accept empty object', () => {
66
- const frontMatter = {};
67
- expect(validateBlogPostFrontMatter(frontMatter)).toEqual(frontMatter);
68
- });
69
-
70
- test('accept unknown field', () => {
71
- const frontMatter = {abc: '1'};
72
- expect(validateBlogPostFrontMatter(frontMatter)).toEqual(frontMatter);
73
- });
74
- });
75
-
76
- describe('validateBlogPostFrontMatter description', () => {
77
- testField({
78
- fieldName: 'description',
79
- validFrontMatters: [
80
- // See https://github.com/facebook/docusaurus/issues/4591#issuecomment-822372398
81
- {description: ''},
82
- {description: 'description'},
83
- ],
84
- });
85
- });
86
-
87
- describe('validateBlogPostFrontMatter title', () => {
88
- testField({
89
- fieldName: 'title',
90
- validFrontMatters: [
91
- // See https://github.com/facebook/docusaurus/issues/4591#issuecomment-822372398
92
- {title: ''},
93
- {title: 'title'},
94
- ],
95
- });
96
- });
97
-
98
- describe('validateBlogPostFrontMatter id', () => {
99
- testField({
100
- fieldName: 'id',
101
- validFrontMatters: [{id: '123'}, {id: 'id'}],
102
- invalidFrontMatters: [[{id: ''}, 'is not allowed to be empty']],
103
- });
104
- });
105
-
106
- describe('validateBlogPostFrontMatter author', () => {
107
- testField({
108
- fieldName: 'author',
109
- validFrontMatters: [{author: '123'}, {author: 'author'}],
110
- invalidFrontMatters: [[{author: ''}, 'is not allowed to be empty']],
111
- });
112
- });
113
-
114
- describe('validateBlogPostFrontMatter author_title', () => {
115
- testField({
116
- fieldName: 'author_title',
117
- validFrontMatters: [{author_title: '123'}, {author_title: 'author_title'}],
118
- invalidFrontMatters: [[{author_title: ''}, 'is not allowed to be empty']],
119
- });
120
-
121
- testField({
122
- fieldName: 'authorTitle',
123
- validFrontMatters: [{authorTitle: '123'}, {authorTitle: 'authorTitle'}],
124
- invalidFrontMatters: [[{authorTitle: ''}, 'is not allowed to be empty']],
125
- });
126
- });
127
-
128
- describe('validateBlogPostFrontMatter author_url', () => {
129
- testField({
130
- fieldName: 'author_url',
131
- validFrontMatters: [
132
- {author_url: 'https://docusaurus.io'},
133
- {author_url: '../../relative'},
134
- {author_url: '/absolute'},
135
- ],
136
- invalidFrontMatters: [
137
- [
138
- {author_url: ''},
139
- '"author_url" does not match any of the allowed types',
140
- ],
141
- ],
142
- });
143
-
144
- testField({
145
- fieldName: 'authorURL',
146
- validFrontMatters: [
147
- {authorURL: 'https://docusaurus.io'},
148
- {authorURL: '../../relative'},
149
- {authorURL: '/absolute'},
150
- ],
151
-
152
- invalidFrontMatters: [
153
- [{authorURL: ''}, '"authorURL" does not match any of the allowed types'],
154
- ],
155
- });
156
- });
157
-
158
- describe('validateBlogPostFrontMatter author_image_url', () => {
159
- testField({
160
- fieldName: 'author_image_url',
161
- validFrontMatters: [
162
- {author_image_url: 'https://docusaurus.io/asset/image.png'},
163
- {author_image_url: '../../relative'},
164
- {author_image_url: '/absolute'},
165
- ],
166
- invalidFrontMatters: [
167
- [
168
- {author_image_url: ''},
169
- '"author_image_url" does not match any of the allowed types',
170
- ],
171
- ],
172
- });
173
-
174
- testField({
175
- fieldName: 'authorImageURL',
176
- validFrontMatters: [
177
- {authorImageURL: 'https://docusaurus.io/asset/image.png'},
178
- {authorImageURL: '../../relative'},
179
- {authorImageURL: '/absolute'},
180
- ],
181
- invalidFrontMatters: [
182
- [
183
- {authorImageURL: ''},
184
- '"authorImageURL" does not match any of the allowed types',
185
- ],
186
- ],
187
- });
188
- });
189
-
190
- describe('validateBlogPostFrontMatter slug', () => {
191
- testField({
192
- fieldName: 'slug',
193
- validFrontMatters: [
194
- {slug: 'blog/'},
195
- {slug: '/blog'},
196
- {slug: '/blog/'},
197
- {slug: './blog'},
198
- {slug: '../blog'},
199
- {slug: '../../blog'},
200
- {slug: '/api/plugins/@docusaurus/plugin-debug'},
201
- {slug: '@site/api/asset/image.png'},
202
- ],
203
- invalidFrontMatters: [[{slug: ''}, 'is not allowed to be empty']],
204
- });
205
- });
206
-
207
- describe('validateBlogPostFrontMatter image', () => {
208
- testField({
209
- fieldName: 'image',
210
- validFrontMatters: [
211
- {image: 'https://docusaurus.io/image.png'},
212
- {image: 'blog/'},
213
- {image: '/blog'},
214
- {image: '/blog/'},
215
- {image: './blog'},
216
- {image: '../blog'},
217
- {image: '../../blog'},
218
- {image: '/api/plugins/@docusaurus/plugin-debug'},
219
- {image: '@site/api/asset/image.png'},
220
- ],
221
- invalidFrontMatters: [
222
- [{image: ''}, '"image" does not match any of the allowed types'],
223
- ],
224
- });
225
- });
226
-
227
- describe('validateBlogPostFrontMatter tags', () => {
228
- testField({
229
- fieldName: 'tags',
230
- validFrontMatters: [
231
- {tags: []},
232
- {tags: ['hello']},
233
- {tags: ['hello', 'world']},
234
- {tags: ['hello', 'world']},
235
- {tags: ['hello', {label: 'tagLabel', permalink: '/tagPermalink'}]},
236
- ],
237
- invalidFrontMatters: [
238
- [{tags: ''}, 'must be an array'],
239
- [{tags: ['']}, 'is not allowed to be empty'],
240
- ],
241
- // See https://github.com/facebook/docusaurus/issues/4642
242
- convertibleFrontMatter: [
243
- [{tags: [42]}, {tags: ['42']}],
244
- [
245
- {tags: [{label: 84, permalink: '/tagPermalink'}]},
246
- {tags: [{label: '84', permalink: '/tagPermalink'}]},
247
- ],
248
- ],
249
- });
250
- });
251
-
252
- describe('validateBlogPostFrontMatter keywords', () => {
253
- testField({
254
- fieldName: 'keywords',
255
- validFrontMatters: [
256
- {keywords: ['hello']},
257
- {keywords: ['hello', 'world']},
258
- {keywords: ['hello', 'world']},
259
- {keywords: ['hello']},
260
- ],
261
- invalidFrontMatters: [
262
- [{keywords: ''}, 'must be an array'],
263
- [{keywords: ['']}, 'is not allowed to be empty'],
264
- [{keywords: []}, 'does not contain 1 required value(s)'],
265
- ],
266
- });
267
- });
268
-
269
- describe('validateBlogPostFrontMatter draft', () => {
270
- testField({
271
- fieldName: 'draft',
272
- validFrontMatters: [{draft: true}, {draft: false}],
273
- convertibleFrontMatter: [
274
- [{draft: 'true'}, {draft: true}],
275
- [{draft: 'false'}, {draft: false}],
276
- ],
277
- invalidFrontMatters: [
278
- [{draft: 'yes'}, 'must be a boolean'],
279
- [{draft: 'no'}, 'must be a boolean'],
280
- ],
281
- });
282
- });
283
-
284
- describe('validateBlogPostFrontMatter hide_table_of_contents', () => {
285
- testField({
286
- fieldName: 'hide_table_of_contents',
287
- validFrontMatters: [
288
- {hide_table_of_contents: true},
289
- {hide_table_of_contents: false},
290
- ],
291
- convertibleFrontMatter: [
292
- [{hide_table_of_contents: 'true'}, {hide_table_of_contents: true}],
293
- [{hide_table_of_contents: 'false'}, {hide_table_of_contents: false}],
294
- ],
295
- invalidFrontMatters: [
296
- [{hide_table_of_contents: 'yes'}, 'must be a boolean'],
297
- [{hide_table_of_contents: 'no'}, 'must be a boolean'],
298
- ],
299
- });
300
- });
301
-
302
- describe('validateBlogPostFrontMatter date', () => {
303
- testField({
304
- fieldName: 'date',
305
- validFrontMatters: [
306
- {date: new Date('2020-01-01')},
307
- // @ts-expect-error: string for test
308
- {date: '2020-01-01'},
309
- // @ts-expect-error: string for test
310
- {date: '2020'},
311
- ],
312
- invalidFrontMatters: [
313
- [{date: 'abc'}, 'must be a valid date'],
314
- [{date: ''}, 'must be a valid date'],
315
- ],
316
- });
317
- });
@@ -1,102 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import path from 'path';
9
- import {generateBlogFeed} from '../blogUtils';
10
- import {LoadContext, I18n} from '@docusaurus/types';
11
- import {PluginOptions, BlogContentPaths} from '../types';
12
- import {DEFAULT_OPTIONS} from '../pluginOptionSchema';
13
-
14
- const DefaultI18N: I18n = {
15
- currentLocale: 'en',
16
- locales: ['en'],
17
- defaultLocale: 'en',
18
- localeConfigs: {},
19
- };
20
-
21
- function getBlogContentPaths(siteDir: string): BlogContentPaths {
22
- return {
23
- contentPath: path.resolve(siteDir, 'blog'),
24
- contentPathLocalized: path.resolve(
25
- siteDir,
26
- 'i18n',
27
- 'en',
28
- 'docusaurus-plugin-content-blog',
29
- ),
30
- };
31
- }
32
-
33
- describe('blogFeed', () => {
34
- (['atom', 'rss'] as const).forEach((feedType) => {
35
- describe(`${feedType}`, () => {
36
- test('should not show feed without posts', async () => {
37
- const siteDir = __dirname;
38
- const siteConfig = {
39
- title: 'Hello',
40
- baseUrl: '/',
41
- url: 'https://docusaurus.io',
42
- favicon: 'image/favicon.ico',
43
- };
44
-
45
- const feed = await generateBlogFeed(
46
- getBlogContentPaths(siteDir),
47
- {
48
- siteDir,
49
- siteConfig,
50
- i18n: DefaultI18N,
51
- } as LoadContext,
52
- {
53
- path: 'invalid-blog-path',
54
- routeBasePath: 'blog',
55
- include: ['*.md', '*.mdx'],
56
- feedOptions: {
57
- type: [feedType],
58
- copyright: 'Copyright',
59
- },
60
- } as PluginOptions,
61
- );
62
- const feedContent =
63
- feed && (feedType === 'rss' ? feed.rss2() : feed.atom1());
64
- expect(feedContent).toMatchSnapshot();
65
- });
66
-
67
- test('shows feed item for each post', async () => {
68
- const siteDir = path.join(__dirname, '__fixtures__', 'website');
69
- const generatedFilesDir = path.resolve(siteDir, '.docusaurus');
70
- const siteConfig = {
71
- title: 'Hello',
72
- baseUrl: '/myBaseUrl/',
73
- url: 'https://docusaurus.io',
74
- favicon: 'image/favicon.ico',
75
- };
76
-
77
- const feed = await generateBlogFeed(
78
- getBlogContentPaths(siteDir),
79
- {
80
- siteDir,
81
- siteConfig,
82
- generatedFilesDir,
83
- i18n: DefaultI18N,
84
- } as LoadContext,
85
- {
86
- path: 'blog',
87
- routeBasePath: 'blog',
88
- include: DEFAULT_OPTIONS.include,
89
- exclude: DEFAULT_OPTIONS.exclude,
90
- feedOptions: {
91
- type: [feedType],
92
- copyright: 'Copyright',
93
- },
94
- } as PluginOptions,
95
- );
96
- const feedContent =
97
- feed && (feedType === 'rss' ? feed.rss2() : feed.atom1());
98
- expect(feedContent).toMatchSnapshot();
99
- });
100
- });
101
- });
102
- });