@docusaurus/plugin-content-blog 3.10.1-canary-6654 → 3.10.1-canary-6803

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.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.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"
@@ -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/internal';
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 = `${siteConfig.url}${metadata.permalink}`;
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 = `${siteConfig.url}${permalink}`;
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 = `${siteConfig.url}${metadata.permalink}`;
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': `${siteConfig.url}${blogMetadata.blogBasePath}`,
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 srcset = tslib_1.__importStar(require("srcset"));
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 = srcset.stringify(srcset.parse(srcsetAttr).map((props) => ({
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
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "3.10.1-canary-6654",
3
+ "version": "3.10.1-canary-6803",
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": "yarn docusaurus build src/__tests__/__fixtures__/website --out-dir build-snap && yarn rimraf src/__tests__/__fixtures__/website/.docusaurus && yarn rimraf src/__tests__/__fixtures__/website/build-snap/assets && git add src/__tests__/__fixtures__/website/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,28 +31,28 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@docusaurus/core": "3.10.1-canary-6654",
35
- "@docusaurus/logger": "3.10.1-canary-6654",
36
- "@docusaurus/mdx-loader": "3.10.1-canary-6654",
37
- "@docusaurus/theme-common": "3.10.1-canary-6654",
38
- "@docusaurus/types": "3.10.1-canary-6654",
39
- "@docusaurus/utils": "3.10.1-canary-6654",
40
- "@docusaurus/utils-common": "3.10.1-canary-6654",
41
- "@docusaurus/utils-validation": "3.10.1-canary-6654",
34
+ "@docusaurus/core": "3.10.1-canary-6803",
35
+ "@docusaurus/logger": "3.10.1-canary-6803",
36
+ "@docusaurus/mdx-loader": "3.10.1-canary-6803",
37
+ "@docusaurus/module-type-aliases": "3.10.1-canary-6803",
38
+ "@docusaurus/theme-common": "3.10.1-canary-6803",
39
+ "@docusaurus/types": "3.10.1-canary-6803",
40
+ "@docusaurus/utils": "3.10.1-canary-6803",
41
+ "@docusaurus/utils-common": "3.10.1-canary-6803",
42
+ "@docusaurus/utils-validation": "3.10.1-canary-6803",
42
43
  "cheerio": "^1.2.0",
43
44
  "combine-promises": "^1.1.0",
44
- "feed": "^4.2.2",
45
+ "feed": "^5.2.1",
45
46
  "fs-extra": "^11.2.0",
46
47
  "lodash": "^4.17.21",
47
48
  "schema-dts": "^1.1.2",
48
- "srcset": "^4.0.0",
49
+ "srcset": "^5.0.3",
49
50
  "tslib": "^2.6.0",
50
51
  "unist-util-visit": "^5.1.0",
51
52
  "utility-types": "^3.10.0",
52
53
  "webpack": "^5.106.2"
53
54
  },
54
55
  "peerDependencies": {
55
- "@docusaurus/plugin-content-docs": "*",
56
56
  "react": "^19.2.5",
57
57
  "react-dom": "^19.2.5"
58
58
  },
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@total-typescript/shoehorn": "^0.1.2",
64
- "tree-node-cli": "^1.6.0"
64
+ "tree-node-cli": "^3.0.0"
65
65
  },
66
- "gitHead": "ea27219c71dc99adddae96a1048b3d992648b116"
66
+ "gitHead": "d2c7b381512bd4e7e90e33f56649e68d618eaa92"
67
67
  }
@@ -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/internal';
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 = `${siteConfig.url}${metadata.permalink}`;
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 = `${siteConfig.url}${permalink}`;
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 = `${siteConfig.url}${metadata.permalink}`;
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': `${siteConfig.url}${blogMetadata.blogBasePath}`,
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 * as srcset from 'srcset';
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 = srcset.stringify(
157
- srcset.parse(srcsetAttr).map((props) => ({
156
+ elm.attribs.srcset = stringifySrcset(
157
+ parseSrcset(srcsetAttr).map((props) => ({
158
158
  ...props,
159
159
  url: toAbsoluteUrl(props.url),
160
160
  })),