@docusaurus/plugin-content-blog 2.0.0-beta.8e9b829d9 → 2.0.0-beta.9
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/lib/.tsbuildinfo +1 -1
- package/lib/authors.d.ts +23 -0
- package/lib/authors.js +150 -0
- package/lib/blogFrontMatter.d.ts +19 -6
- package/lib/blogFrontMatter.js +31 -19
- package/lib/blogUtils.d.ts +10 -4
- package/lib/blogUtils.js +141 -135
- package/lib/feed.d.ts +20 -0
- package/lib/feed.js +90 -0
- package/lib/index.js +86 -85
- package/lib/markdownLoader.d.ts +3 -6
- package/lib/markdownLoader.js +5 -5
- package/lib/pluginOptionSchema.d.ts +3 -27
- package/lib/pluginOptionSchema.js +21 -7
- package/lib/translations.d.ts +10 -0
- package/lib/translations.js +53 -0
- package/lib/types.d.ts +52 -14
- package/package.json +15 -13
- package/src/__tests__/__fixtures__/authorsMapFiles/authors.json +29 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authors.yml +27 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad1.json +5 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad1.yml +3 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad2.json +3 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad2.yml +2 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad3.json +8 -0
- package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad3.yml +3 -0
- package/src/__tests__/__fixtures__/component/Typography.tsx +6 -0
- package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathEmpty/empty +0 -0
- package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathJson1/authors.json +0 -0
- package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathJson2/authors.json +0 -0
- package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathNestedYml/sub/folder/authors.yml +0 -0
- package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathYml1/authors.yml +0 -0
- package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathYml2/authors.yml +0 -0
- package/src/__tests__/__fixtures__/website/blog/2018-12-14-Happy-First-Birthday-Slash.md +3 -0
- package/src/__tests__/__fixtures__/website/blog/authors.yml +4 -0
- package/src/__tests__/__fixtures__/website/blog/mdx-blog-post.mdx +36 -0
- package/src/__tests__/__fixtures__/website/blog/mdx-require-blog-post.mdx +14 -0
- package/src/__tests__/__fixtures__/website/blog/simple-slug.md +4 -0
- package/src/__tests__/__fixtures__/website/i18n/en/docusaurus-plugin-content-blog/2018-12-14-Happy-First-Birthday-Slash.md +3 -0
- package/src/__tests__/__fixtures__/website/i18n/en/docusaurus-plugin-content-blog/authors.yml +5 -0
- package/src/__tests__/__fixtures__/website/static/img/docusaurus.png +0 -0
- package/src/__tests__/__snapshots__/{generateBlogFeed.test.ts.snap → feed.test.ts.snap} +55 -7
- package/src/__tests__/__snapshots__/translations.test.ts.snap +64 -0
- package/src/__tests__/authors.test.ts +608 -0
- package/src/__tests__/blogFrontMatter.test.ts +93 -16
- package/src/__tests__/blogUtils.test.ts +94 -0
- package/src/__tests__/{generateBlogFeed.test.ts → feed.test.ts} +32 -8
- package/src/__tests__/index.test.ts +73 -12
- package/src/__tests__/pluginOptionSchema.test.ts +3 -3
- package/src/__tests__/translations.test.ts +92 -0
- package/src/authors.ts +202 -0
- package/src/blogFrontMatter.ts +73 -33
- package/src/blogUtils.ts +201 -180
- package/src/feed.ts +129 -0
- package/src/index.ts +105 -88
- package/src/markdownLoader.ts +8 -12
- package/{index.d.ts → src/plugin-content-blog.d.ts} +35 -31
- package/src/pluginOptionSchema.ts +24 -9
- package/src/translations.ts +63 -0
- package/src/types.ts +67 -16
package/src/types.ts
CHANGED
|
@@ -6,27 +6,40 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
|
|
9
|
-
import {
|
|
9
|
+
import type {Tag} from '@docusaurus/utils';
|
|
10
|
+
import type {
|
|
10
11
|
BrokenMarkdownLink,
|
|
11
12
|
ContentPaths,
|
|
12
13
|
} from '@docusaurus/utils/lib/markdownLinks';
|
|
14
|
+
import {Overwrite} from 'utility-types';
|
|
15
|
+
import {BlogPostFrontMatter} from './blogFrontMatter';
|
|
13
16
|
|
|
14
17
|
export type BlogContentPaths = ContentPaths;
|
|
15
18
|
|
|
16
19
|
export interface BlogContent {
|
|
20
|
+
blogSidebarTitle: string;
|
|
17
21
|
blogPosts: BlogPost[];
|
|
18
22
|
blogListPaginated: BlogPaginated[];
|
|
19
23
|
blogTags: BlogTags;
|
|
20
24
|
blogTagsListPath: string | null;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
export interface DateLink {
|
|
24
|
-
date: Date;
|
|
25
|
-
link: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
27
|
export type FeedType = 'rss' | 'atom';
|
|
29
28
|
|
|
29
|
+
export type FeedOptions = {
|
|
30
|
+
type?: FeedType[] | null;
|
|
31
|
+
title?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
copyright: string;
|
|
34
|
+
language?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Feed options, as provided by user config
|
|
38
|
+
export type UserFeedOptions = Overwrite<
|
|
39
|
+
Partial<FeedOptions>,
|
|
40
|
+
{type?: FeedOptions['type'] | 'all'} // Handle the type: "all" shortcut
|
|
41
|
+
>;
|
|
42
|
+
|
|
30
43
|
export type EditUrlFunction = (editUrlParams: {
|
|
31
44
|
blogDirPath: string;
|
|
32
45
|
blogPath: string;
|
|
@@ -34,13 +47,33 @@ export type EditUrlFunction = (editUrlParams: {
|
|
|
34
47
|
locale: string;
|
|
35
48
|
}) => string | undefined;
|
|
36
49
|
|
|
37
|
-
|
|
50
|
+
// Duplicate from ngryman/reading-time to keep stability of API
|
|
51
|
+
type ReadingTimeOptions = {
|
|
52
|
+
wordsPerMinute?: number;
|
|
53
|
+
wordBound?: (char: string) => boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type ReadingTimeFunction = (params: {
|
|
57
|
+
content: string;
|
|
58
|
+
frontMatter?: BlogPostFrontMatter & Record<string, unknown>;
|
|
59
|
+
options?: ReadingTimeOptions;
|
|
60
|
+
}) => number;
|
|
61
|
+
|
|
62
|
+
export type ReadingTimeFunctionOption = (
|
|
63
|
+
params: Required<Omit<Parameters<ReadingTimeFunction>[0], 'options'>> & {
|
|
64
|
+
defaultReadingTime: ReadingTimeFunction;
|
|
65
|
+
},
|
|
66
|
+
) => number | undefined;
|
|
67
|
+
|
|
68
|
+
export type PluginOptions = RemarkAndRehypePluginOptions & {
|
|
38
69
|
id?: string;
|
|
39
70
|
path: string;
|
|
40
71
|
routeBasePath: string;
|
|
72
|
+
tagsBasePath: string;
|
|
73
|
+
archiveBasePath: string;
|
|
41
74
|
include: string[];
|
|
42
75
|
exclude: string[];
|
|
43
|
-
postsPerPage: number;
|
|
76
|
+
postsPerPage: number | 'ALL';
|
|
44
77
|
blogListComponent: string;
|
|
45
78
|
blogPostComponent: string;
|
|
46
79
|
blogTagsListComponent: string;
|
|
@@ -52,7 +85,7 @@ export interface PluginOptions extends RemarkAndRehypePluginOptions {
|
|
|
52
85
|
truncateMarker: RegExp;
|
|
53
86
|
showReadingTime: boolean;
|
|
54
87
|
feedOptions: {
|
|
55
|
-
type?: [
|
|
88
|
+
type?: FeedType[] | null;
|
|
56
89
|
title?: string;
|
|
57
90
|
description?: string;
|
|
58
91
|
copyright: string;
|
|
@@ -61,7 +94,15 @@ export interface PluginOptions extends RemarkAndRehypePluginOptions {
|
|
|
61
94
|
editUrl?: string | EditUrlFunction;
|
|
62
95
|
editLocalizedFiles?: boolean;
|
|
63
96
|
admonitions: Record<string, unknown>;
|
|
64
|
-
|
|
97
|
+
authorsMapPath: string;
|
|
98
|
+
readingTime: ReadingTimeFunctionOption;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Options, as provided in the user config (before normalization)
|
|
102
|
+
export type UserPluginOptions = Overwrite<
|
|
103
|
+
Partial<PluginOptions>,
|
|
104
|
+
{feedOptions?: UserFeedOptions}
|
|
105
|
+
>;
|
|
65
106
|
|
|
66
107
|
export interface BlogTags {
|
|
67
108
|
[key: string]: BlogTag;
|
|
@@ -76,6 +117,7 @@ export interface BlogTag {
|
|
|
76
117
|
export interface BlogPost {
|
|
77
118
|
id: string;
|
|
78
119
|
metadata: MetaData;
|
|
120
|
+
content: string;
|
|
79
121
|
}
|
|
80
122
|
|
|
81
123
|
export interface BlogPaginatedMetadata {
|
|
@@ -95,28 +137,37 @@ export interface BlogPaginated {
|
|
|
95
137
|
items: string[];
|
|
96
138
|
}
|
|
97
139
|
|
|
140
|
+
// We allow passing custom fields to authors, e.g., twitter
|
|
141
|
+
export interface Author extends Record<string, unknown> {
|
|
142
|
+
name?: string;
|
|
143
|
+
imageURL?: string;
|
|
144
|
+
url?: string;
|
|
145
|
+
title?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
98
148
|
export interface MetaData {
|
|
99
149
|
permalink: string;
|
|
100
150
|
source: string;
|
|
101
151
|
description: string;
|
|
102
152
|
date: Date;
|
|
103
153
|
formattedDate: string;
|
|
104
|
-
tags:
|
|
154
|
+
tags: Tag[];
|
|
105
155
|
title: string;
|
|
106
156
|
readingTime?: number;
|
|
107
157
|
prevItem?: Paginator;
|
|
108
158
|
nextItem?: Paginator;
|
|
109
159
|
truncated: boolean;
|
|
110
160
|
editUrl?: string;
|
|
161
|
+
authors: Author[];
|
|
111
162
|
}
|
|
112
163
|
|
|
113
|
-
export interface
|
|
114
|
-
|
|
115
|
-
|
|
164
|
+
export interface Assets {
|
|
165
|
+
image?: string;
|
|
166
|
+
authorsImageUrls: (string | undefined)[]; // Array of same size as the original MetaData.authors array
|
|
116
167
|
}
|
|
117
168
|
|
|
118
|
-
export interface
|
|
119
|
-
|
|
169
|
+
export interface Paginator {
|
|
170
|
+
title: string;
|
|
120
171
|
permalink: string;
|
|
121
172
|
}
|
|
122
173
|
|