@docusaurus/plugin-content-blog 2.0.0-beta.677e53d4d → 2.0.0-beta.7
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 -2
- package/lib/blogUtils.js +146 -104
- package/lib/index.js +78 -77
- package/lib/markdownLoader.js +3 -3
- package/lib/pluginOptionSchema.d.ts +3 -26
- package/lib/pluginOptionSchema.js +22 -7
- package/lib/translations.d.ts +10 -0
- package/lib/translations.js +53 -0
- package/lib/types.d.ts +38 -14
- package/package.json +13 -11
- 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/_partials/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/website/blog/_partials/subfolder/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/website/blog/_somePartial.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/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__/__snapshots__/generateBlogFeed.test.ts.snap +81 -3
- 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 +7 -1
- package/src/__tests__/index.test.ts +63 -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 +206 -131
- package/src/index.ts +98 -71
- package/{index.d.ts → src/plugin-content-blog.d.ts} +35 -31
- package/src/pluginOptionSchema.ts +25 -9
- package/src/translations.ts +63 -0
- package/src/types.ts +48 -16
package/src/types.ts
CHANGED
|
@@ -6,27 +6,39 @@
|
|
|
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';
|
|
13
15
|
|
|
14
16
|
export type BlogContentPaths = ContentPaths;
|
|
15
17
|
|
|
16
18
|
export interface BlogContent {
|
|
19
|
+
blogSidebarTitle: string;
|
|
17
20
|
blogPosts: BlogPost[];
|
|
18
21
|
blogListPaginated: BlogPaginated[];
|
|
19
22
|
blogTags: BlogTags;
|
|
20
23
|
blogTagsListPath: string | null;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
export interface DateLink {
|
|
24
|
-
date: Date;
|
|
25
|
-
link: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
26
|
export type FeedType = 'rss' | 'atom';
|
|
29
27
|
|
|
28
|
+
export type FeedOptions = {
|
|
29
|
+
type?: FeedType[] | null;
|
|
30
|
+
title?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
copyright: string;
|
|
33
|
+
language?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Feed options, as provided by user config
|
|
37
|
+
export type UserFeedOptions = Overwrite<
|
|
38
|
+
Partial<FeedOptions>,
|
|
39
|
+
{type?: FeedOptions['type'] | 'all'} // Handle the type: "all" shortcut
|
|
40
|
+
>;
|
|
41
|
+
|
|
30
42
|
export type EditUrlFunction = (editUrlParams: {
|
|
31
43
|
blogDirPath: string;
|
|
32
44
|
blogPath: string;
|
|
@@ -34,12 +46,15 @@ export type EditUrlFunction = (editUrlParams: {
|
|
|
34
46
|
locale: string;
|
|
35
47
|
}) => string | undefined;
|
|
36
48
|
|
|
37
|
-
export
|
|
49
|
+
export type PluginOptions = RemarkAndRehypePluginOptions & {
|
|
38
50
|
id?: string;
|
|
39
51
|
path: string;
|
|
40
52
|
routeBasePath: string;
|
|
53
|
+
tagsBasePath: string;
|
|
54
|
+
archiveBasePath: string;
|
|
41
55
|
include: string[];
|
|
42
|
-
|
|
56
|
+
exclude: string[];
|
|
57
|
+
postsPerPage: number | 'ALL';
|
|
43
58
|
blogListComponent: string;
|
|
44
59
|
blogPostComponent: string;
|
|
45
60
|
blogTagsListComponent: string;
|
|
@@ -51,7 +66,7 @@ export interface PluginOptions extends RemarkAndRehypePluginOptions {
|
|
|
51
66
|
truncateMarker: RegExp;
|
|
52
67
|
showReadingTime: boolean;
|
|
53
68
|
feedOptions: {
|
|
54
|
-
type?: [
|
|
69
|
+
type?: FeedType[] | null;
|
|
55
70
|
title?: string;
|
|
56
71
|
description?: string;
|
|
57
72
|
copyright: string;
|
|
@@ -60,7 +75,14 @@ export interface PluginOptions extends RemarkAndRehypePluginOptions {
|
|
|
60
75
|
editUrl?: string | EditUrlFunction;
|
|
61
76
|
editLocalizedFiles?: boolean;
|
|
62
77
|
admonitions: Record<string, unknown>;
|
|
63
|
-
|
|
78
|
+
authorsMapPath: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Options, as provided in the user config (before normalization)
|
|
82
|
+
export type UserPluginOptions = Overwrite<
|
|
83
|
+
Partial<PluginOptions>,
|
|
84
|
+
{feedOptions?: UserFeedOptions}
|
|
85
|
+
>;
|
|
64
86
|
|
|
65
87
|
export interface BlogTags {
|
|
66
88
|
[key: string]: BlogTag;
|
|
@@ -75,6 +97,7 @@ export interface BlogTag {
|
|
|
75
97
|
export interface BlogPost {
|
|
76
98
|
id: string;
|
|
77
99
|
metadata: MetaData;
|
|
100
|
+
content: string;
|
|
78
101
|
}
|
|
79
102
|
|
|
80
103
|
export interface BlogPaginatedMetadata {
|
|
@@ -94,28 +117,37 @@ export interface BlogPaginated {
|
|
|
94
117
|
items: string[];
|
|
95
118
|
}
|
|
96
119
|
|
|
120
|
+
// We allow passing custom fields to authors, e.g., twitter
|
|
121
|
+
export interface Author extends Record<string, unknown> {
|
|
122
|
+
name?: string;
|
|
123
|
+
imageURL?: string;
|
|
124
|
+
url?: string;
|
|
125
|
+
title?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
97
128
|
export interface MetaData {
|
|
98
129
|
permalink: string;
|
|
99
130
|
source: string;
|
|
100
131
|
description: string;
|
|
101
132
|
date: Date;
|
|
102
133
|
formattedDate: string;
|
|
103
|
-
tags:
|
|
134
|
+
tags: Tag[];
|
|
104
135
|
title: string;
|
|
105
136
|
readingTime?: number;
|
|
106
137
|
prevItem?: Paginator;
|
|
107
138
|
nextItem?: Paginator;
|
|
108
139
|
truncated: boolean;
|
|
109
140
|
editUrl?: string;
|
|
141
|
+
authors: Author[];
|
|
110
142
|
}
|
|
111
143
|
|
|
112
|
-
export interface
|
|
113
|
-
|
|
114
|
-
|
|
144
|
+
export interface Assets {
|
|
145
|
+
image?: string;
|
|
146
|
+
authorsImageUrls: (string | undefined)[]; // Array of same size as the original MetaData.authors array
|
|
115
147
|
}
|
|
116
148
|
|
|
117
|
-
export interface
|
|
118
|
-
|
|
149
|
+
export interface Paginator {
|
|
150
|
+
title: string;
|
|
119
151
|
permalink: string;
|
|
120
152
|
}
|
|
121
153
|
|