@docusaurus/plugin-content-blog 2.0.0-beta.16 → 2.0.0-beta.19
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/authors.d.ts +3 -1
- package/lib/authors.js +14 -6
- package/lib/blogUtils.d.ts +5 -3
- package/lib/blogUtils.js +21 -19
- package/lib/feed.d.ts +3 -3
- package/lib/feed.js +16 -17
- package/lib/{blogFrontMatter.d.ts → frontMatter.d.ts} +3 -1
- package/lib/{blogFrontMatter.js → frontMatter.js} +0 -0
- package/lib/index.d.ts +3 -4
- package/lib/index.js +50 -58
- package/lib/markdownLoader.js +1 -1
- package/lib/options.d.ts +10 -0
- package/lib/{pluginOptionSchema.js → options.js} +9 -4
- package/lib/remark/footnoteIDFixer.d.ts +14 -0
- package/lib/remark/footnoteIDFixer.js +29 -0
- package/lib/translations.d.ts +4 -5
- package/lib/translations.js +4 -4
- package/lib/types.d.ts +4 -73
- package/package.json +13 -12
- package/src/authors.ts +29 -17
- package/src/blogUtils.ts +30 -22
- package/src/deps.d.ts +1 -1
- package/src/feed.ts +53 -56
- package/src/{blogFrontMatter.ts → frontMatter.ts} +3 -3
- package/src/index.ts +74 -98
- package/src/markdownLoader.ts +1 -1
- package/src/{pluginOptionSchema.ts → options.ts} +16 -4
- package/src/plugin-content-blog.d.ts +408 -97
- package/src/remark/footnoteIDFixer.ts +29 -0
- package/src/translations.ts +14 -9
- package/src/types.ts +2 -94
- package/lib/pluginOptionSchema.d.ts +0 -10
package/src/translations.ts
CHANGED
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
|
|
8
|
+
import type {TranslationFileContent, TranslationFile} from '@docusaurus/types';
|
|
9
|
+
import type {
|
|
10
|
+
PluginOptions,
|
|
11
|
+
BlogContent,
|
|
12
|
+
BlogPaginated,
|
|
13
|
+
} from '@docusaurus/plugin-content-blog';
|
|
11
14
|
|
|
12
15
|
function translateListPage(
|
|
13
16
|
blogListPaginated: BlogPaginated[],
|
|
@@ -19,14 +22,15 @@ function translateListPage(
|
|
|
19
22
|
items,
|
|
20
23
|
metadata: {
|
|
21
24
|
...metadata,
|
|
22
|
-
blogTitle: translations.title.
|
|
23
|
-
blogDescription:
|
|
25
|
+
blogTitle: translations.title?.message ?? page.metadata.blogTitle,
|
|
26
|
+
blogDescription:
|
|
27
|
+
translations.description?.message ?? page.metadata.blogDescription,
|
|
24
28
|
},
|
|
25
29
|
};
|
|
26
30
|
});
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
export function getTranslationFiles(options: PluginOptions):
|
|
33
|
+
export function getTranslationFiles(options: PluginOptions): TranslationFile[] {
|
|
30
34
|
return [
|
|
31
35
|
{
|
|
32
36
|
path: 'options',
|
|
@@ -50,12 +54,13 @@ export function getTranslationFiles(options: PluginOptions): TranslationFiles {
|
|
|
50
54
|
|
|
51
55
|
export function translateContent(
|
|
52
56
|
content: BlogContent,
|
|
53
|
-
translationFiles:
|
|
57
|
+
translationFiles: TranslationFile[],
|
|
54
58
|
): BlogContent {
|
|
55
|
-
const
|
|
59
|
+
const {content: optionsTranslations} = translationFiles[0]!;
|
|
56
60
|
return {
|
|
57
61
|
...content,
|
|
58
|
-
blogSidebarTitle:
|
|
62
|
+
blogSidebarTitle:
|
|
63
|
+
optionsTranslations['sidebar.title']?.message ?? content.blogSidebarTitle,
|
|
59
64
|
blogListPaginated: translateListPage(
|
|
60
65
|
content.blogListPaginated,
|
|
61
66
|
optionsTranslations,
|
package/src/types.ts
CHANGED
|
@@ -5,107 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
BrokenMarkdownLink,
|
|
11
|
-
ContentPaths,
|
|
12
|
-
} from '@docusaurus/utils/lib/markdownLinks';
|
|
13
|
-
import type {
|
|
14
|
-
BlogPostFrontMatter,
|
|
15
|
-
Author,
|
|
16
|
-
} from '@docusaurus/plugin-content-blog';
|
|
8
|
+
import type {BrokenMarkdownLink, ContentPaths} from '@docusaurus/utils';
|
|
17
9
|
|
|
18
10
|
export type BlogContentPaths = ContentPaths;
|
|
19
11
|
|
|
20
|
-
export interface BlogContent {
|
|
21
|
-
blogSidebarTitle: string;
|
|
22
|
-
blogPosts: BlogPost[];
|
|
23
|
-
blogListPaginated: BlogPaginated[];
|
|
24
|
-
blogTags: BlogTags;
|
|
25
|
-
blogTagsListPath: string | null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface BlogTags {
|
|
29
|
-
// TODO, the key is the tag slug/permalink
|
|
30
|
-
// This is due to legacy frontmatter: tags:
|
|
31
|
-
// [{label: "xyz", permalink: "/1"}, {label: "xyz", permalink: "/2"}]
|
|
32
|
-
// Soon we should forbid declaring permalink through frontmatter
|
|
33
|
-
[tagKey: string]: BlogTag;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface BlogTag {
|
|
37
|
-
name: string;
|
|
38
|
-
items: string[]; // blog post permalinks
|
|
39
|
-
permalink: string;
|
|
40
|
-
pages: BlogPaginated[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface BlogPost {
|
|
44
|
-
id: string;
|
|
45
|
-
metadata: MetaData;
|
|
46
|
-
content: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface BlogPaginatedMetadata {
|
|
50
|
-
permalink: string;
|
|
51
|
-
page: number;
|
|
52
|
-
postsPerPage: number;
|
|
53
|
-
totalPages: number;
|
|
54
|
-
totalCount: number;
|
|
55
|
-
previousPage: string | null;
|
|
56
|
-
nextPage: string | null;
|
|
57
|
-
blogTitle: string;
|
|
58
|
-
blogDescription: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface BlogPaginated {
|
|
62
|
-
metadata: BlogPaginatedMetadata;
|
|
63
|
-
items: string[]; // blog post permalinks
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface MetaData {
|
|
67
|
-
permalink: string;
|
|
68
|
-
source: string;
|
|
69
|
-
description: string;
|
|
70
|
-
date: Date;
|
|
71
|
-
formattedDate: string;
|
|
72
|
-
tags: Tag[];
|
|
73
|
-
title: string;
|
|
74
|
-
readingTime?: number;
|
|
75
|
-
prevItem?: Paginator;
|
|
76
|
-
nextItem?: Paginator;
|
|
77
|
-
truncated: boolean;
|
|
78
|
-
editUrl?: string;
|
|
79
|
-
authors: Author[];
|
|
80
|
-
frontMatter: BlogPostFrontMatter & Record<string, unknown>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface Paginator {
|
|
84
|
-
title: string;
|
|
85
|
-
permalink: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface BlogItemsToMetadata {
|
|
89
|
-
[key: string]: MetaData;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface TagsModule {
|
|
93
|
-
[key: string]: TagModule;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface TagModule {
|
|
97
|
-
allTagsPath: string;
|
|
98
|
-
slug: string;
|
|
99
|
-
name: string;
|
|
100
|
-
count: number;
|
|
101
|
-
permalink: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
12
|
export type BlogBrokenMarkdownLink = BrokenMarkdownLink<BlogContentPaths>;
|
|
105
13
|
export type BlogMarkdownLoaderOptions = {
|
|
106
14
|
siteDir: string;
|
|
107
15
|
contentPaths: BlogContentPaths;
|
|
108
16
|
truncateMarker: RegExp;
|
|
109
|
-
sourceToPermalink:
|
|
17
|
+
sourceToPermalink: {[aliasedPath: string]: string};
|
|
110
18
|
onBrokenMarkdownLink: (brokenMarkdownLink: BlogBrokenMarkdownLink) => void;
|
|
111
19
|
};
|
|
@@ -1,10 +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
|
-
import { Joi } from '@docusaurus/utils-validation';
|
|
8
|
-
import type { PluginOptions } from '@docusaurus/plugin-content-blog';
|
|
9
|
-
export declare const DEFAULT_OPTIONS: PluginOptions;
|
|
10
|
-
export declare const PluginOptionSchema: Joi.ObjectSchema<PluginOptions>;
|