@docusaurus/plugin-content-blog 0.0.0-5828 → 0.0.0-5831
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/blogUtils.d.ts +3 -1
- package/lib/blogUtils.js +2 -2
- package/lib/index.js +4 -3
- package/lib/options.js +2 -0
- package/package.json +9 -9
- package/src/blogUtils.ts +4 -1
- package/src/index.ts +4 -2
- package/src/options.ts +2 -0
- package/src/plugin-content-blog.d.ts +6 -1
package/lib/blogUtils.d.ts
CHANGED
|
@@ -11,12 +11,13 @@ export declare function truncate(fileString: string, truncateMarker: RegExp): st
|
|
|
11
11
|
export declare function getSourceToPermalink(blogPosts: BlogPost[]): {
|
|
12
12
|
[aliasedPath: string]: string;
|
|
13
13
|
};
|
|
14
|
-
export declare function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription, postsPerPageOption, }: {
|
|
14
|
+
export declare function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription, postsPerPageOption, pageBasePath, }: {
|
|
15
15
|
blogPosts: BlogPost[];
|
|
16
16
|
basePageUrl: string;
|
|
17
17
|
blogTitle: string;
|
|
18
18
|
blogDescription: string;
|
|
19
19
|
postsPerPageOption: number | 'ALL';
|
|
20
|
+
pageBasePath: string;
|
|
20
21
|
}): BlogPaginated[];
|
|
21
22
|
export declare function shouldBeListed(blogPost: BlogPost): boolean;
|
|
22
23
|
export declare function getBlogTags({ blogPosts, ...params }: {
|
|
@@ -24,6 +25,7 @@ export declare function getBlogTags({ blogPosts, ...params }: {
|
|
|
24
25
|
blogTitle: string;
|
|
25
26
|
blogDescription: string;
|
|
26
27
|
postsPerPageOption: number | 'ALL';
|
|
28
|
+
pageBasePath: string;
|
|
27
29
|
}): BlogTags;
|
|
28
30
|
type ParsedBlogFileName = {
|
|
29
31
|
date: Date | undefined;
|
package/lib/blogUtils.js
CHANGED
|
@@ -24,14 +24,14 @@ function getSourceToPermalink(blogPosts) {
|
|
|
24
24
|
return Object.fromEntries(blogPosts.map(({ metadata: { source, permalink } }) => [source, permalink]));
|
|
25
25
|
}
|
|
26
26
|
exports.getSourceToPermalink = getSourceToPermalink;
|
|
27
|
-
function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription, postsPerPageOption, }) {
|
|
27
|
+
function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription, postsPerPageOption, pageBasePath, }) {
|
|
28
28
|
const totalCount = blogPosts.length;
|
|
29
29
|
const postsPerPage = postsPerPageOption === 'ALL' ? totalCount : postsPerPageOption;
|
|
30
30
|
const numberOfPages = Math.ceil(totalCount / postsPerPage);
|
|
31
31
|
const pages = [];
|
|
32
32
|
function permalink(page) {
|
|
33
33
|
return page > 0
|
|
34
|
-
? (0, utils_1.normalizeUrl)([basePageUrl,
|
|
34
|
+
? (0, utils_1.normalizeUrl)([basePageUrl, pageBasePath, `${page + 1}`])
|
|
35
35
|
: basePageUrl;
|
|
36
36
|
}
|
|
37
37
|
for (let page = 0; page < numberOfPages; page += 1) {
|
package/lib/index.js
CHANGED
|
@@ -47,7 +47,7 @@ async function pluginContentBlog(context, options) {
|
|
|
47
47
|
},
|
|
48
48
|
// Fetches blog contents and returns metadata for the necessary routes.
|
|
49
49
|
async loadContent() {
|
|
50
|
-
const { postsPerPage: postsPerPageOption, routeBasePath, tagsBasePath, blogDescription, blogTitle, blogSidebarTitle, } = options;
|
|
50
|
+
const { postsPerPage: postsPerPageOption, routeBasePath, tagsBasePath, blogDescription, blogTitle, blogSidebarTitle, pageBasePath, } = options;
|
|
51
51
|
const baseBlogUrl = (0, utils_1.normalizeUrl)([baseUrl, routeBasePath]);
|
|
52
52
|
const blogTagsListPath = (0, utils_1.normalizeUrl)([baseBlogUrl, tagsBasePath]);
|
|
53
53
|
const blogPosts = await (0, blogUtils_1.generateBlogPosts)(contentPaths, context, options);
|
|
@@ -59,10 +59,9 @@ async function pluginContentBlog(context, options) {
|
|
|
59
59
|
blogListPaginated: [],
|
|
60
60
|
blogTags: {},
|
|
61
61
|
blogTagsListPath,
|
|
62
|
-
blogTagsPaginated: [],
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
|
-
//
|
|
64
|
+
// Collocate next and prev metadata.
|
|
66
65
|
listedBlogPosts.forEach((blogPost, index) => {
|
|
67
66
|
const prevItem = index > 0 ? listedBlogPosts[index - 1] : null;
|
|
68
67
|
if (prevItem) {
|
|
@@ -87,12 +86,14 @@ async function pluginContentBlog(context, options) {
|
|
|
87
86
|
blogDescription,
|
|
88
87
|
postsPerPageOption,
|
|
89
88
|
basePageUrl: baseBlogUrl,
|
|
89
|
+
pageBasePath,
|
|
90
90
|
});
|
|
91
91
|
const blogTags = (0, blogUtils_1.getBlogTags)({
|
|
92
92
|
blogPosts,
|
|
93
93
|
postsPerPageOption,
|
|
94
94
|
blogDescription,
|
|
95
95
|
blogTitle,
|
|
96
|
+
pageBasePath,
|
|
96
97
|
});
|
|
97
98
|
return {
|
|
98
99
|
blogSidebarTitle,
|
package/lib/options.js
CHANGED
|
@@ -33,6 +33,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
33
33
|
routeBasePath: 'blog',
|
|
34
34
|
tagsBasePath: 'tags',
|
|
35
35
|
archiveBasePath: 'archive',
|
|
36
|
+
pageBasePath: 'page',
|
|
36
37
|
path: 'blog',
|
|
37
38
|
editLocalizedFiles: false,
|
|
38
39
|
authorsMapPath: 'authors.yml',
|
|
@@ -46,6 +47,7 @@ const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
|
46
47
|
.allow(null),
|
|
47
48
|
routeBasePath: utils_validation_1.RouteBasePathSchema.default(exports.DEFAULT_OPTIONS.routeBasePath),
|
|
48
49
|
tagsBasePath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.tagsBasePath),
|
|
50
|
+
pageBasePath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.pageBasePath),
|
|
49
51
|
include: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()).default(exports.DEFAULT_OPTIONS.include),
|
|
50
52
|
exclude: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()).default(exports.DEFAULT_OPTIONS.exclude),
|
|
51
53
|
postsPerPage: utils_validation_1.Joi.alternatives()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-blog",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5831",
|
|
4
4
|
"description": "Blog plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-blog.d.ts",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@docusaurus/core": "0.0.0-
|
|
23
|
-
"@docusaurus/logger": "0.0.0-
|
|
24
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
25
|
-
"@docusaurus/types": "0.0.0-
|
|
26
|
-
"@docusaurus/utils": "0.0.0-
|
|
27
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
28
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
22
|
+
"@docusaurus/core": "0.0.0-5831",
|
|
23
|
+
"@docusaurus/logger": "0.0.0-5831",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5831",
|
|
25
|
+
"@docusaurus/types": "0.0.0-5831",
|
|
26
|
+
"@docusaurus/utils": "0.0.0-5831",
|
|
27
|
+
"@docusaurus/utils-common": "0.0.0-5831",
|
|
28
|
+
"@docusaurus/utils-validation": "0.0.0-5831",
|
|
29
29
|
"cheerio": "^1.0.0-rc.12",
|
|
30
30
|
"feed": "^4.2.2",
|
|
31
31
|
"fs-extra": "^11.1.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=18.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ae029ea17949629c9ab651e035696f21660b0330"
|
|
48
48
|
}
|
package/src/blogUtils.ts
CHANGED
|
@@ -57,12 +57,14 @@ export function paginateBlogPosts({
|
|
|
57
57
|
blogTitle,
|
|
58
58
|
blogDescription,
|
|
59
59
|
postsPerPageOption,
|
|
60
|
+
pageBasePath,
|
|
60
61
|
}: {
|
|
61
62
|
blogPosts: BlogPost[];
|
|
62
63
|
basePageUrl: string;
|
|
63
64
|
blogTitle: string;
|
|
64
65
|
blogDescription: string;
|
|
65
66
|
postsPerPageOption: number | 'ALL';
|
|
67
|
+
pageBasePath: string;
|
|
66
68
|
}): BlogPaginated[] {
|
|
67
69
|
const totalCount = blogPosts.length;
|
|
68
70
|
const postsPerPage =
|
|
@@ -73,7 +75,7 @@ export function paginateBlogPosts({
|
|
|
73
75
|
|
|
74
76
|
function permalink(page: number) {
|
|
75
77
|
return page > 0
|
|
76
|
-
? normalizeUrl([basePageUrl,
|
|
78
|
+
? normalizeUrl([basePageUrl, pageBasePath, `${page + 1}`])
|
|
77
79
|
: basePageUrl;
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -111,6 +113,7 @@ export function getBlogTags({
|
|
|
111
113
|
blogTitle: string;
|
|
112
114
|
blogDescription: string;
|
|
113
115
|
postsPerPageOption: number | 'ALL';
|
|
116
|
+
pageBasePath: string;
|
|
114
117
|
}): BlogTags {
|
|
115
118
|
const groups = groupTaggedItems(
|
|
116
119
|
blogPosts,
|
package/src/index.ts
CHANGED
|
@@ -107,6 +107,7 @@ export default async function pluginContentBlog(
|
|
|
107
107
|
blogDescription,
|
|
108
108
|
blogTitle,
|
|
109
109
|
blogSidebarTitle,
|
|
110
|
+
pageBasePath,
|
|
110
111
|
} = options;
|
|
111
112
|
|
|
112
113
|
const baseBlogUrl = normalizeUrl([baseUrl, routeBasePath]);
|
|
@@ -121,11 +122,10 @@ export default async function pluginContentBlog(
|
|
|
121
122
|
blogListPaginated: [],
|
|
122
123
|
blogTags: {},
|
|
123
124
|
blogTagsListPath,
|
|
124
|
-
blogTagsPaginated: [],
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
//
|
|
128
|
+
// Collocate next and prev metadata.
|
|
129
129
|
listedBlogPosts.forEach((blogPost, index) => {
|
|
130
130
|
const prevItem = index > 0 ? listedBlogPosts[index - 1] : null;
|
|
131
131
|
if (prevItem) {
|
|
@@ -153,6 +153,7 @@ export default async function pluginContentBlog(
|
|
|
153
153
|
blogDescription,
|
|
154
154
|
postsPerPageOption,
|
|
155
155
|
basePageUrl: baseBlogUrl,
|
|
156
|
+
pageBasePath,
|
|
156
157
|
});
|
|
157
158
|
|
|
158
159
|
const blogTags: BlogTags = getBlogTags({
|
|
@@ -160,6 +161,7 @@ export default async function pluginContentBlog(
|
|
|
160
161
|
postsPerPageOption,
|
|
161
162
|
blogDescription,
|
|
162
163
|
blogTitle,
|
|
164
|
+
pageBasePath,
|
|
163
165
|
});
|
|
164
166
|
|
|
165
167
|
return {
|
package/src/options.ts
CHANGED
|
@@ -45,6 +45,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|
|
45
45
|
routeBasePath: 'blog',
|
|
46
46
|
tagsBasePath: 'tags',
|
|
47
47
|
archiveBasePath: 'archive',
|
|
48
|
+
pageBasePath: 'page',
|
|
48
49
|
path: 'blog',
|
|
49
50
|
editLocalizedFiles: false,
|
|
50
51
|
authorsMapPath: 'authors.yml',
|
|
@@ -59,6 +60,7 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
|
|
|
59
60
|
.allow(null),
|
|
60
61
|
routeBasePath: RouteBasePathSchema.default(DEFAULT_OPTIONS.routeBasePath),
|
|
61
62
|
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
|
63
|
+
pageBasePath: Joi.string().default(DEFAULT_OPTIONS.pageBasePath),
|
|
62
64
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
|
63
65
|
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
|
64
66
|
postsPerPage: Joi.alternatives()
|
|
@@ -351,9 +351,14 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the
|
|
|
351
351
|
routeBasePath: string;
|
|
352
352
|
/**
|
|
353
353
|
* URL route for the tags section of your blog. Will be appended to
|
|
354
|
-
* `routeBasePath`.
|
|
354
|
+
* `routeBasePath`.
|
|
355
355
|
*/
|
|
356
356
|
tagsBasePath: string;
|
|
357
|
+
/**
|
|
358
|
+
* URL route for the pages section of your blog. Will be appended to
|
|
359
|
+
* `routeBasePath`.
|
|
360
|
+
*/
|
|
361
|
+
pageBasePath: string;
|
|
357
362
|
/**
|
|
358
363
|
* URL route for the archive section of your blog. Will be appended to
|
|
359
364
|
* `routeBasePath`. **DO NOT** include a trailing slash. Use `null` to
|