@docusaurus/plugin-content-blog 3.0.0-beta.0 → 3.0.0-rc.1
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/index.js +3 -2
- package/lib/remark/footnoteIDFixer.js +4 -5
- package/package.json +11 -11
- package/src/index.ts +4 -2
- package/src/remark/footnoteIDFixer.ts +3 -2
package/lib/index.js
CHANGED
|
@@ -106,6 +106,7 @@ async function pluginContentBlog(context, options) {
|
|
|
106
106
|
const { blogListComponent, blogPostComponent, blogTagsListComponent, blogTagsPostsComponent, blogArchiveComponent, routeBasePath, archiveBasePath, } = options;
|
|
107
107
|
const { addRoute, createData } = actions;
|
|
108
108
|
const { blogSidebarTitle, blogPosts, blogListPaginated, blogTags, blogTagsListPath, } = blogContents;
|
|
109
|
+
const listedBlogPosts = blogPosts.filter(blogUtils_1.shouldBeListed);
|
|
109
110
|
const blogItemsToMetadata = {};
|
|
110
111
|
const sidebarBlogPosts = options.blogSidebarCount === 'ALL'
|
|
111
112
|
? blogPosts
|
|
@@ -124,14 +125,14 @@ async function pluginContentBlog(context, options) {
|
|
|
124
125
|
};
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
|
-
if (archiveBasePath &&
|
|
128
|
+
if (archiveBasePath && listedBlogPosts.length) {
|
|
128
129
|
const archiveUrl = (0, utils_1.normalizeUrl)([
|
|
129
130
|
baseUrl,
|
|
130
131
|
routeBasePath,
|
|
131
132
|
archiveBasePath,
|
|
132
133
|
]);
|
|
133
134
|
// Create a blog archive route
|
|
134
|
-
const archiveProp = await createData(`${(0, utils_1.docuHash)(archiveUrl)}.json`, JSON.stringify({ blogPosts }, null, 2));
|
|
135
|
+
const archiveProp = await createData(`${(0, utils_1.docuHash)(archiveUrl)}.json`, JSON.stringify({ blogPosts: listedBlogPosts }, null, 2));
|
|
135
136
|
addRoute({
|
|
136
137
|
path: archiveUrl,
|
|
137
138
|
component: blogArchiveComponent,
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const tslib_1 = require("tslib");
|
|
10
|
-
const unist_util_visit_1 = tslib_1.__importDefault(require("unist-util-visit"));
|
|
11
9
|
const utils_1 = require("@docusaurus/utils");
|
|
12
10
|
/**
|
|
13
11
|
* In the blog list view, each post will be compiled separately. However, they
|
|
@@ -16,12 +14,13 @@ const utils_1 = require("@docusaurus/utils");
|
|
|
16
14
|
* unique hash to each reference/definition.
|
|
17
15
|
*/
|
|
18
16
|
function plugin() {
|
|
19
|
-
return (root, vfile) => {
|
|
17
|
+
return async (root, vfile) => {
|
|
18
|
+
const { visit } = await import('unist-util-visit');
|
|
20
19
|
const suffix = `-${(0, utils_1.simpleHash)(vfile.path, 6)}`;
|
|
21
|
-
(
|
|
20
|
+
visit(root, 'footnoteReference', (node) => {
|
|
22
21
|
node.identifier += suffix;
|
|
23
22
|
});
|
|
24
|
-
(
|
|
23
|
+
visit(root, 'footnoteDefinition', (node) => {
|
|
25
24
|
node.identifier += suffix;
|
|
26
25
|
});
|
|
27
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-blog",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.1",
|
|
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": "3.0.0-
|
|
23
|
-
"@docusaurus/logger": "3.0.0-
|
|
24
|
-
"@docusaurus/mdx-loader": "3.0.0-
|
|
25
|
-
"@docusaurus/types": "3.0.0-
|
|
26
|
-
"@docusaurus/utils": "3.0.0-
|
|
27
|
-
"@docusaurus/utils-common": "3.0.0-
|
|
28
|
-
"@docusaurus/utils-validation": "3.0.0-
|
|
22
|
+
"@docusaurus/core": "3.0.0-rc.1",
|
|
23
|
+
"@docusaurus/logger": "3.0.0-rc.1",
|
|
24
|
+
"@docusaurus/mdx-loader": "3.0.0-rc.1",
|
|
25
|
+
"@docusaurus/types": "3.0.0-rc.1",
|
|
26
|
+
"@docusaurus/utils": "3.0.0-rc.1",
|
|
27
|
+
"@docusaurus/utils-common": "3.0.0-rc.1",
|
|
28
|
+
"@docusaurus/utils-validation": "3.0.0-rc.1",
|
|
29
29
|
"cheerio": "^1.0.0-rc.12",
|
|
30
30
|
"feed": "^4.2.2",
|
|
31
31
|
"fs-extra": "^11.1.1",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"reading-time": "^1.5.0",
|
|
34
34
|
"srcset": "^4.0.0",
|
|
35
35
|
"tslib": "^2.6.0",
|
|
36
|
-
"unist-util-visit": "^
|
|
36
|
+
"unist-util-visit": "^5.0.0",
|
|
37
37
|
"utility-types": "^3.10.0",
|
|
38
38
|
"webpack": "^5.88.1"
|
|
39
39
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^18.0.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
45
|
+
"node": ">=18.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "a51cc6fd7660d47ea08349f723cec9c017af0b4e"
|
|
48
48
|
}
|
package/src/index.ts
CHANGED
|
@@ -191,6 +191,8 @@ export default async function pluginContentBlog(
|
|
|
191
191
|
blogTagsListPath,
|
|
192
192
|
} = blogContents;
|
|
193
193
|
|
|
194
|
+
const listedBlogPosts = blogPosts.filter(shouldBeListed);
|
|
195
|
+
|
|
194
196
|
const blogItemsToMetadata: {[postId: string]: BlogPostMetadata} = {};
|
|
195
197
|
|
|
196
198
|
const sidebarBlogPosts =
|
|
@@ -213,7 +215,7 @@ export default async function pluginContentBlog(
|
|
|
213
215
|
});
|
|
214
216
|
}
|
|
215
217
|
|
|
216
|
-
if (archiveBasePath &&
|
|
218
|
+
if (archiveBasePath && listedBlogPosts.length) {
|
|
217
219
|
const archiveUrl = normalizeUrl([
|
|
218
220
|
baseUrl,
|
|
219
221
|
routeBasePath,
|
|
@@ -222,7 +224,7 @@ export default async function pluginContentBlog(
|
|
|
222
224
|
// Create a blog archive route
|
|
223
225
|
const archiveProp = await createData(
|
|
224
226
|
`${docuHash(archiveUrl)}.json`,
|
|
225
|
-
JSON.stringify({blogPosts}, null, 2),
|
|
227
|
+
JSON.stringify({blogPosts: listedBlogPosts}, null, 2),
|
|
226
228
|
);
|
|
227
229
|
addRoute({
|
|
228
230
|
path: archiveUrl,
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import visit from 'unist-util-visit';
|
|
9
8
|
import {simpleHash} from '@docusaurus/utils';
|
|
10
9
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
11
10
|
import type {Transformer} from 'unified';
|
|
@@ -18,7 +17,9 @@ import type {FootnoteReference, FootnoteDefinition} from 'mdast';
|
|
|
18
17
|
* unique hash to each reference/definition.
|
|
19
18
|
*/
|
|
20
19
|
export default function plugin(): Transformer {
|
|
21
|
-
return (root, vfile) => {
|
|
20
|
+
return async (root, vfile) => {
|
|
21
|
+
const {visit} = await import('unist-util-visit');
|
|
22
|
+
|
|
22
23
|
const suffix = `-${simpleHash(vfile.path!, 6)}`;
|
|
23
24
|
visit(root, 'footnoteReference', (node: FootnoteReference) => {
|
|
24
25
|
node.identifier += suffix;
|