@docusaurus/plugin-content-blog 3.10.2 → 4.0.0-canary-6808
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/assets/atom.css +7 -1
- package/assets/atom.xsl +6 -0
- package/assets/rss.css +7 -1
- package/assets/rss.xsl +6 -0
- package/lib/client/contexts.js +1 -1
- package/lib/client/structuredDataUtils.js +12 -4
- package/lib/feed.js +4 -4
- package/lib/frontMatter.d.ts +6 -0
- package/lib/frontMatter.js +3 -2
- package/package.json +27 -27
- package/src/blogUtils.ts +1 -1
- package/src/client/contexts.tsx +1 -1
- package/src/client/sidebarUtils.test.ts +1 -0
- package/src/client/structuredDataUtils.ts +16 -4
- package/src/feed.ts +6 -6
- package/src/frontMatter.ts +2 -0
- package/src/plugin-content-blog.d.ts +1 -2
package/assets/atom.css
CHANGED
|
@@ -11,7 +11,13 @@ main {
|
|
|
11
11
|
margin: 2rem auto;
|
|
12
12
|
max-width: 800px;
|
|
13
13
|
/* stylelint-disable-next-line font-family-name-quotes */
|
|
14
|
-
font-family:
|
|
14
|
+
font-family:
|
|
15
|
+
system-ui,
|
|
16
|
+
-apple-system,
|
|
17
|
+
'Segoe UI',
|
|
18
|
+
Roboto,
|
|
19
|
+
Ubuntu,
|
|
20
|
+
Cantarell;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
.info {
|
package/assets/atom.xsl
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
This source code is licensed under the MIT license found in the
|
|
6
|
+
LICENSE file in the root directory of this source tree.
|
|
7
|
+
-->
|
|
2
8
|
<xsl:stylesheet
|
|
3
9
|
version="3.0"
|
|
4
10
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
package/assets/rss.css
CHANGED
|
@@ -11,7 +11,13 @@ main {
|
|
|
11
11
|
margin: 2rem auto;
|
|
12
12
|
max-width: 800px;
|
|
13
13
|
/* stylelint-disable-next-line font-family-name-quotes */
|
|
14
|
-
font-family:
|
|
14
|
+
font-family:
|
|
15
|
+
system-ui,
|
|
16
|
+
-apple-system,
|
|
17
|
+
'Segoe UI',
|
|
18
|
+
Roboto,
|
|
19
|
+
Ubuntu,
|
|
20
|
+
Cantarell;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
.info {
|
package/assets/rss.xsl
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
This source code is licensed under the MIT license found in the
|
|
6
|
+
LICENSE file in the root directory of this source tree.
|
|
7
|
+
-->
|
|
2
8
|
<xsl:stylesheet
|
|
3
9
|
version="3.0"
|
|
4
10
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
package/lib/client/contexts.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { useMemo, useContext } from 'react';
|
|
8
|
-
import { ReactContextError } from '@docusaurus/theme-common
|
|
8
|
+
import { ReactContextError } from '@docusaurus/theme-common';
|
|
9
9
|
import useRouteContext from '@docusaurus/useRouteContext';
|
|
10
10
|
export function useBlogMetadata() {
|
|
11
11
|
const routeContext = useRouteContext();
|
|
@@ -7,14 +7,22 @@
|
|
|
7
7
|
import { useBaseUrlUtils } from '@docusaurus/useBaseUrl';
|
|
8
8
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
9
9
|
import { useBlogMetadata } from '@docusaurus/plugin-content-blog/client';
|
|
10
|
+
import { applyTrailingSlash } from '@docusaurus/utils-common';
|
|
10
11
|
import { useBlogPost } from './contexts';
|
|
11
12
|
const convertDate = (dateMs) => new Date(dateMs).toISOString();
|
|
13
|
+
function getAbsoluteUrl(permalink, siteConfig) {
|
|
14
|
+
const absoluteUrl = `${siteConfig.url}${permalink}`;
|
|
15
|
+
return applyTrailingSlash(absoluteUrl, {
|
|
16
|
+
trailingSlash: siteConfig.trailingSlash,
|
|
17
|
+
baseUrl: siteConfig.baseUrl,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
12
20
|
function getBlogPost(blogPostContent, siteConfig, withBaseUrl) {
|
|
13
21
|
const { assets, frontMatter, metadata } = blogPostContent;
|
|
14
22
|
const { date, title, description, lastUpdatedAt } = metadata;
|
|
15
23
|
const image = assets.image ?? frontMatter.image;
|
|
16
24
|
const keywords = frontMatter.keywords ?? [];
|
|
17
|
-
const blogUrl =
|
|
25
|
+
const blogUrl = getAbsoluteUrl(metadata.permalink, siteConfig);
|
|
18
26
|
const dateModified = lastUpdatedAt ? convertDate(lastUpdatedAt) : undefined;
|
|
19
27
|
return {
|
|
20
28
|
'@type': 'BlogPosting',
|
|
@@ -53,7 +61,7 @@ export function useBlogListPageStructuredData(props) {
|
|
|
53
61
|
const { siteConfig } = useDocusaurusContext();
|
|
54
62
|
const { withBaseUrl } = useBaseUrlUtils();
|
|
55
63
|
const { metadata: { blogDescription, blogTitle, permalink }, } = props;
|
|
56
|
-
const url =
|
|
64
|
+
const url = getAbsoluteUrl(permalink, siteConfig);
|
|
57
65
|
// details on structured data support: https://schema.org/Blog
|
|
58
66
|
return {
|
|
59
67
|
'@context': 'https://schema.org',
|
|
@@ -74,7 +82,7 @@ export function useBlogPostStructuredData() {
|
|
|
74
82
|
const image = assets.image ?? frontMatter.image;
|
|
75
83
|
const keywords = frontMatter.keywords ?? [];
|
|
76
84
|
const dateModified = lastUpdatedAt ? convertDate(lastUpdatedAt) : undefined;
|
|
77
|
-
const url =
|
|
85
|
+
const url = getAbsoluteUrl(metadata.permalink, siteConfig);
|
|
78
86
|
// details on structured data support: https://schema.org/BlogPosting
|
|
79
87
|
// BlogPosting is one of the structured data types that Google explicitly
|
|
80
88
|
// supports: https://developers.google.com/search/docs/appearance/structured-data/article#structured-data-type-definitions
|
|
@@ -94,7 +102,7 @@ export function useBlogPostStructuredData() {
|
|
|
94
102
|
...(keywords ? { keywords } : {}),
|
|
95
103
|
isPartOf: {
|
|
96
104
|
'@type': 'Blog',
|
|
97
|
-
'@id':
|
|
105
|
+
'@id': getAbsoluteUrl(blogMetadata.blogBasePath, siteConfig),
|
|
98
106
|
name: blogMetadata.blogTitle,
|
|
99
107
|
},
|
|
100
108
|
};
|
package/lib/feed.js
CHANGED
|
@@ -12,7 +12,7 @@ const tslib_1 = require("tslib");
|
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
14
14
|
const feed_1 = require("feed");
|
|
15
|
-
const
|
|
15
|
+
const srcset_1 = require("srcset");
|
|
16
16
|
const utils_1 = require("@docusaurus/utils");
|
|
17
17
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
18
18
|
const cheerio_1 = require("cheerio");
|
|
@@ -80,7 +80,7 @@ async function defaultCreateFeedItems({ blogPosts, siteConfig, outDir, }) {
|
|
|
80
80
|
elm.attribs.src = toAbsoluteUrl(src);
|
|
81
81
|
}
|
|
82
82
|
if (srcsetAttr) {
|
|
83
|
-
elm.attribs.srcset =
|
|
83
|
+
elm.attribs.srcset = (0, srcset_1.stringifySrcset)((0, srcset_1.parseSrcset)(srcsetAttr).map((props) => ({
|
|
84
84
|
...props,
|
|
85
85
|
url: toAbsoluteUrl(props.url),
|
|
86
86
|
})));
|
|
@@ -109,8 +109,8 @@ async function defaultCreateFeedItems({ blogPosts, siteConfig, outDir, }) {
|
|
|
109
109
|
async function resolveXsltFilePaths({ xsltFilePath, contentPaths, }) {
|
|
110
110
|
const xsltAbsolutePath = path_1.default.isAbsolute(xsltFilePath)
|
|
111
111
|
? xsltFilePath
|
|
112
|
-
: (await (0, utils_1.getDataFilePath)({ filePath: xsltFilePath, contentPaths })) ??
|
|
113
|
-
path_1.default.resolve(contentPaths.contentPath, xsltFilePath);
|
|
112
|
+
: ((await (0, utils_1.getDataFilePath)({ filePath: xsltFilePath, contentPaths })) ??
|
|
113
|
+
path_1.default.resolve(contentPaths.contentPath, xsltFilePath));
|
|
114
114
|
if (!(await fs_extra_1.default.pathExists(xsltAbsolutePath))) {
|
|
115
115
|
throw new Error(logger_1.default.interpolate `Blog feed XSLT file not found at path=${path_1.default.relative(process.cwd(), xsltAbsolutePath)}`);
|
|
116
116
|
}
|
package/lib/frontMatter.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
*/
|
|
1
7
|
import type { BlogPostFrontMatter } from '@docusaurus/plugin-content-blog';
|
|
2
8
|
export declare function validateBlogPostFrontMatter(frontMatter: {
|
|
3
9
|
[key: string]: unknown;
|
package/lib/frontMatter.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateBlogPostFrontMatter = validateBlogPostFrontMatter;
|
|
4
2
|
/**
|
|
5
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
*
|
|
7
5
|
* This source code is licensed under the MIT license found in the
|
|
8
6
|
* LICENSE file in the root directory of this source tree.
|
|
9
7
|
*/
|
|
8
|
+
/* eslint-disable camelcase */
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.validateBlogPostFrontMatter = validateBlogPostFrontMatter;
|
|
10
11
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
12
|
const authorsSocials_1 = require("./authorsSocials");
|
|
12
13
|
const BlogPostFrontMatterAuthorSchema = utils_validation_1.JoiFrontMatter.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-blog",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-canary-6808",
|
|
4
4
|
"description": "Blog plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-blog.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc --build",
|
|
21
21
|
"watch": "tsc --build --watch",
|
|
22
|
-
"test:generate-build-snap": "
|
|
22
|
+
"test:generate-build-snap": "pnpm docusaurus build src/__tests__/__fixtures__/website --out-dir build-snap && pnpm rimraf src/__tests__/__fixtures__/website/.docusaurus && pnpm rimraf src/__tests__/__fixtures__/website/build-snap/assets && git add src/__tests__/__fixtures__/website/build-snap"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
@@ -31,37 +31,37 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@docusaurus/core": "
|
|
35
|
-
"@docusaurus/logger": "
|
|
36
|
-
"@docusaurus/mdx-loader": "
|
|
37
|
-
"@docusaurus/
|
|
38
|
-
"@docusaurus/
|
|
39
|
-
"@docusaurus/
|
|
40
|
-
"@docusaurus/utils
|
|
41
|
-
"@docusaurus/utils-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
34
|
+
"@docusaurus/core": "4.0.0-canary-6808",
|
|
35
|
+
"@docusaurus/logger": "4.0.0-canary-6808",
|
|
36
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6808",
|
|
37
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6808",
|
|
38
|
+
"@docusaurus/theme-common": "4.0.0-canary-6808",
|
|
39
|
+
"@docusaurus/types": "4.0.0-canary-6808",
|
|
40
|
+
"@docusaurus/utils": "4.0.0-canary-6808",
|
|
41
|
+
"@docusaurus/utils-common": "4.0.0-canary-6808",
|
|
42
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6808",
|
|
43
|
+
"cheerio": "^1.2.0",
|
|
44
|
+
"combine-promises": "^1.2.0",
|
|
45
|
+
"feed": "^5.2.1",
|
|
46
|
+
"fs-extra": "^11.4.0",
|
|
47
|
+
"lodash": "^4.18.1",
|
|
48
|
+
"schema-dts": "^1.1.5",
|
|
49
|
+
"srcset": "^5.0.3",
|
|
50
|
+
"tslib": "^2.8.1",
|
|
51
|
+
"unist-util-visit": "^5.1.0",
|
|
52
|
+
"utility-types": "^3.11.0",
|
|
53
|
+
"webpack": "^5.110.3"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"
|
|
56
|
-
"react": "^
|
|
57
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
56
|
+
"react": "^19.3.0",
|
|
57
|
+
"react-dom": "^19.3.0"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
|
-
"node": ">=
|
|
60
|
+
"node": ">=24.14"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
64
|
-
"tree-node-cli": "^
|
|
64
|
+
"tree-node-cli": "^3.0.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "91e445730a91fbe20dd5fefae560303a0c655aa7"
|
|
67
67
|
}
|
package/src/blogUtils.ts
CHANGED
package/src/client/contexts.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, {useMemo, type ReactNode, useContext} from 'react';
|
|
9
|
-
import {ReactContextError} from '@docusaurus/theme-common
|
|
9
|
+
import {ReactContextError} from '@docusaurus/theme-common';
|
|
10
10
|
import useRouteContext from '@docusaurus/useRouteContext';
|
|
11
11
|
|
|
12
12
|
import type {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import {useBaseUrlUtils, type BaseUrlUtils} from '@docusaurus/useBaseUrl';
|
|
9
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
10
|
import {useBlogMetadata} from '@docusaurus/plugin-content-blog/client';
|
|
11
|
+
import {applyTrailingSlash} from '@docusaurus/utils-common';
|
|
11
12
|
import type {Props as BlogListPageStructuredDataProps} from '@theme/BlogListPage/StructuredData';
|
|
12
13
|
import {useBlogPost} from './contexts';
|
|
13
14
|
|
|
@@ -26,6 +27,17 @@ import type {DocusaurusConfig} from '@docusaurus/types';
|
|
|
26
27
|
|
|
27
28
|
const convertDate = (dateMs: number) => new Date(dateMs).toISOString();
|
|
28
29
|
|
|
30
|
+
function getAbsoluteUrl(
|
|
31
|
+
permalink: string,
|
|
32
|
+
siteConfig: DocusaurusConfig,
|
|
33
|
+
): string {
|
|
34
|
+
const absoluteUrl = `${siteConfig.url}${permalink}`;
|
|
35
|
+
return applyTrailingSlash(absoluteUrl, {
|
|
36
|
+
trailingSlash: siteConfig.trailingSlash,
|
|
37
|
+
baseUrl: siteConfig.baseUrl,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
function getBlogPost(
|
|
30
42
|
blogPostContent: PropBlogPostContent,
|
|
31
43
|
siteConfig: DocusaurusConfig,
|
|
@@ -37,7 +49,7 @@ function getBlogPost(
|
|
|
37
49
|
const image = assets.image ?? frontMatter.image;
|
|
38
50
|
const keywords = frontMatter.keywords ?? [];
|
|
39
51
|
|
|
40
|
-
const blogUrl =
|
|
52
|
+
const blogUrl = getAbsoluteUrl(metadata.permalink, siteConfig);
|
|
41
53
|
|
|
42
54
|
const dateModified = lastUpdatedAt ? convertDate(lastUpdatedAt) : undefined;
|
|
43
55
|
|
|
@@ -92,7 +104,7 @@ export function useBlogListPageStructuredData(
|
|
|
92
104
|
metadata: {blogDescription, blogTitle, permalink},
|
|
93
105
|
} = props;
|
|
94
106
|
|
|
95
|
-
const url =
|
|
107
|
+
const url = getAbsoluteUrl(permalink, siteConfig);
|
|
96
108
|
|
|
97
109
|
// details on structured data support: https://schema.org/Blog
|
|
98
110
|
return {
|
|
@@ -121,7 +133,7 @@ export function useBlogPostStructuredData(): WithContext<BlogPosting> {
|
|
|
121
133
|
|
|
122
134
|
const dateModified = lastUpdatedAt ? convertDate(lastUpdatedAt) : undefined;
|
|
123
135
|
|
|
124
|
-
const url =
|
|
136
|
+
const url = getAbsoluteUrl(metadata.permalink, siteConfig);
|
|
125
137
|
|
|
126
138
|
// details on structured data support: https://schema.org/BlogPosting
|
|
127
139
|
// BlogPosting is one of the structured data types that Google explicitly
|
|
@@ -142,7 +154,7 @@ export function useBlogPostStructuredData(): WithContext<BlogPosting> {
|
|
|
142
154
|
...(keywords ? {keywords} : {}),
|
|
143
155
|
isPartOf: {
|
|
144
156
|
'@type': 'Blog',
|
|
145
|
-
'@id':
|
|
157
|
+
'@id': getAbsoluteUrl(blogMetadata.blogBasePath, siteConfig),
|
|
146
158
|
name: blogMetadata.blogTitle,
|
|
147
159
|
},
|
|
148
160
|
};
|
package/src/feed.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import fs from 'fs-extra';
|
|
10
10
|
import {Feed, type Author as FeedAuthor} from 'feed';
|
|
11
|
-
import
|
|
11
|
+
import {parseSrcset, stringifySrcset} from 'srcset';
|
|
12
12
|
import {
|
|
13
13
|
getDataFilePath,
|
|
14
14
|
normalizeUrl,
|
|
@@ -153,8 +153,8 @@ async function defaultCreateFeedItems({
|
|
|
153
153
|
elm.attribs.src = toAbsoluteUrl(src);
|
|
154
154
|
}
|
|
155
155
|
if (srcsetAttr) {
|
|
156
|
-
elm.attribs.srcset =
|
|
157
|
-
|
|
156
|
+
elm.attribs.srcset = stringifySrcset(
|
|
157
|
+
parseSrcset(srcsetAttr).map((props) => ({
|
|
158
158
|
...props,
|
|
159
159
|
url: toAbsoluteUrl(props.url),
|
|
160
160
|
})),
|
|
@@ -196,8 +196,8 @@ async function resolveXsltFilePaths({
|
|
|
196
196
|
}) {
|
|
197
197
|
const xsltAbsolutePath: string = path.isAbsolute(xsltFilePath)
|
|
198
198
|
? xsltFilePath
|
|
199
|
-
: (await getDataFilePath({filePath: xsltFilePath, contentPaths})) ??
|
|
200
|
-
path.resolve(contentPaths.contentPath, xsltFilePath);
|
|
199
|
+
: ((await getDataFilePath({filePath: xsltFilePath, contentPaths})) ??
|
|
200
|
+
path.resolve(contentPaths.contentPath, xsltFilePath));
|
|
201
201
|
|
|
202
202
|
if (!(await fs.pathExists(xsltAbsolutePath))) {
|
|
203
203
|
throw new Error(
|
|
@@ -323,7 +323,7 @@ async function createBlogFeedFile({
|
|
|
323
323
|
await fs.outputFile(outputPath, feedContent);
|
|
324
324
|
} catch (err) {
|
|
325
325
|
throw new Error(`Generating ${feedType} feed failed.`, {
|
|
326
|
-
cause: err
|
|
326
|
+
cause: err,
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
329
|
}
|
package/src/frontMatter.ts
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
8
|
|
|
9
9
|
declare module '@docusaurus/plugin-content-blog' {
|
|
10
|
-
import type {LoadedMDXContent} from '@docusaurus/mdx-loader';
|
|
11
|
-
import type {MDXOptions} from '@docusaurus/mdx-loader';
|
|
10
|
+
import type {LoadedMDXContent, MDXOptions} from '@docusaurus/mdx-loader';
|
|
12
11
|
import type {
|
|
13
12
|
FrontMatterTag,
|
|
14
13
|
TagMetadata,
|