@docusaurus/plugin-content-blog 3.8.1 → 3.9.0-canary-6406

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.
@@ -23,6 +23,7 @@ exports.AuthorSocialsSchema = utils_validation_1.Joi.object({
23
23
  mastodon: utils_validation_1.Joi.string(),
24
24
  twitch: utils_validation_1.Joi.string(),
25
25
  youtube: utils_validation_1.Joi.string(),
26
+ email: utils_validation_1.Joi.string(),
26
27
  }).unknown();
27
28
  const PredefinedPlatformNormalizers = {
28
29
  x: (handle) => `https://x.com/${handle}`,
@@ -36,14 +37,16 @@ const PredefinedPlatformNormalizers = {
36
37
  mastodon: (handle) => `https://mastodon.social/@${handle}`, // can be in format user@other.server and it will redirect if needed
37
38
  twitch: (handle) => `https://twitch.tv/${handle}`,
38
39
  youtube: (handle) => `https://youtube.com/@${handle}`, // https://support.google.com/youtube/answer/6180214?hl=en
40
+ email: (email) => `mailto:${email}`,
39
41
  };
40
42
  function normalizeSocialEntry([platform, value]) {
41
- const normalizer = PredefinedPlatformNormalizers[platform.toLowerCase()];
42
43
  if (typeof value !== 'string') {
43
44
  throw new Error(`Author socials should be usernames/userIds/handles, or fully qualified HTTP(s) absolute URLs.
44
45
  Social platform '${platform}' has illegal value '${value}'`);
45
46
  }
46
- const isAbsoluteUrl = value.startsWith('http://') || value.startsWith('https://');
47
+ const isAbsoluteUrl = value.startsWith('http://') ||
48
+ value.startsWith('https://') ||
49
+ value.startsWith('mailto:');
47
50
  if (isAbsoluteUrl) {
48
51
  return [platform, value];
49
52
  }
@@ -51,6 +54,7 @@ Social platform '${platform}' has illegal value '${value}'`);
51
54
  throw new Error(`Author socials should be usernames/userIds/handles, or fully qualified HTTP(s) absolute URLs.
52
55
  Social platform '${platform}' has illegal value '${value}'`);
53
56
  }
57
+ const normalizer = PredefinedPlatformNormalizers[platform.toLowerCase()];
54
58
  if (normalizer && !isAbsoluteUrl) {
55
59
  const normalizedPlatform = platform.toLowerCase();
56
60
  const normalizedValue = normalizer(value);
package/lib/blogUtils.js CHANGED
@@ -194,7 +194,9 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
194
194
  }
195
195
  else if (typeof editUrl === 'string') {
196
196
  const isLocalized = blogDirPath === contentPaths.contentPathLocalized;
197
- const fileContentPath = isLocalized && options.editLocalizedFiles
197
+ const fileContentPath = isLocalized &&
198
+ options.editLocalizedFiles &&
199
+ contentPaths.contentPathLocalized
198
200
  ? contentPaths.contentPathLocalized
199
201
  : contentPaths.contentPath;
200
202
  const contentPathEditUrl = (0, utils_1.normalizeUrl)([
package/lib/index.js CHANGED
@@ -29,14 +29,17 @@ async function pluginContentBlog(context, options) {
29
29
  if (isBlogFeedDisabledBecauseOfHashRouter) {
30
30
  logger_1.default.warn(`${PluginName} feed feature does not support the Hash Router. Feeds won't be generated.`);
31
31
  }
32
- const { onBrokenMarkdownLinks, baseUrl } = siteConfig;
32
+ const { baseUrl } = siteConfig;
33
+ const shouldTranslate = (0, utils_1.getLocaleConfig)(context.i18n).translate;
33
34
  const contentPaths = {
34
35
  contentPath: path_1.default.resolve(siteDir, options.path),
35
- contentPathLocalized: (0, utils_1.getPluginI18nPath)({
36
- localizationDir,
37
- pluginName: PluginName,
38
- pluginId: options.id,
39
- }),
36
+ contentPathLocalized: shouldTranslate
37
+ ? (0, utils_1.getPluginI18nPath)({
38
+ localizationDir,
39
+ pluginName: PluginName,
40
+ pluginId: options.id,
41
+ })
42
+ : undefined,
40
43
  };
41
44
  const pluginId = options.id ?? utils_1.DEFAULT_PLUGIN_ID;
42
45
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, PluginName);
@@ -89,16 +92,12 @@ async function pluginContentBlog(context, options) {
89
92
  },
90
93
  markdownConfig: siteConfig.markdown,
91
94
  resolveMarkdownLink: ({ linkPathname, sourceFilePath }) => {
92
- const permalink = (0, utils_1.resolveMarkdownLinkPathname)(linkPathname, {
95
+ return (0, utils_1.resolveMarkdownLinkPathname)(linkPathname, {
93
96
  sourceFilePath,
94
97
  sourceToPermalink: contentHelpers.sourceToPermalink,
95
98
  siteDir,
96
99
  contentPaths,
97
100
  });
98
- if (permalink === null) {
99
- logger_1.default.report(onBrokenMarkdownLinks) `Blog markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath}`;
100
- }
101
- return permalink;
102
101
  },
103
102
  });
104
103
  function createBlogMarkdownLoader() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "3.8.1",
3
+ "version": "3.9.0-canary-6406",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@docusaurus/core": "3.8.1",
35
- "@docusaurus/logger": "3.8.1",
36
- "@docusaurus/mdx-loader": "3.8.1",
37
- "@docusaurus/theme-common": "3.8.1",
38
- "@docusaurus/types": "3.8.1",
39
- "@docusaurus/utils": "3.8.1",
40
- "@docusaurus/utils-common": "3.8.1",
41
- "@docusaurus/utils-validation": "3.8.1",
34
+ "@docusaurus/core": "3.9.0-canary-6406",
35
+ "@docusaurus/logger": "3.9.0-canary-6406",
36
+ "@docusaurus/mdx-loader": "3.9.0-canary-6406",
37
+ "@docusaurus/theme-common": "3.9.0-canary-6406",
38
+ "@docusaurus/types": "3.9.0-canary-6406",
39
+ "@docusaurus/utils": "3.9.0-canary-6406",
40
+ "@docusaurus/utils-common": "3.9.0-canary-6406",
41
+ "@docusaurus/utils-validation": "3.9.0-canary-6406",
42
42
  "cheerio": "1.0.0-rc.12",
43
43
  "feed": "^4.2.2",
44
44
  "fs-extra": "^11.1.1",
@@ -56,11 +56,11 @@
56
56
  "react-dom": "^18.0.0 || ^19.0.0"
57
57
  },
58
58
  "engines": {
59
- "node": ">=18.0"
59
+ "node": ">=20.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@total-typescript/shoehorn": "^0.1.2",
63
63
  "tree-node-cli": "^1.6.0"
64
64
  },
65
- "gitHead": "fa8ae13e668fcbc0481ce10c0a734e2a5b397293"
65
+ "gitHead": "796441f4f831278ffc57971fabcd4c730da9e9d7"
66
66
  }
@@ -27,6 +27,7 @@ export const AuthorSocialsSchema = Joi.object<AuthorSocials>({
27
27
  mastodon: Joi.string(),
28
28
  twitch: Joi.string(),
29
29
  youtube: Joi.string(),
30
+ email: Joi.string(),
30
31
  }).unknown();
31
32
 
32
33
  type PredefinedPlatformNormalizer = (value: string) => string;
@@ -47,12 +48,12 @@ const PredefinedPlatformNormalizers: Record<
47
48
  mastodon: (handle: string) => `https://mastodon.social/@${handle}`, // can be in format user@other.server and it will redirect if needed
48
49
  twitch: (handle: string) => `https://twitch.tv/${handle}`,
49
50
  youtube: (handle: string) => `https://youtube.com/@${handle}`, // https://support.google.com/youtube/answer/6180214?hl=en
51
+ email: (email: string) => `mailto:${email}`,
50
52
  };
51
53
 
52
54
  type SocialEntry = [string, string];
53
55
 
54
56
  function normalizeSocialEntry([platform, value]: SocialEntry): SocialEntry {
55
- const normalizer = PredefinedPlatformNormalizers[platform.toLowerCase()];
56
57
  if (typeof value !== 'string') {
57
58
  throw new Error(
58
59
  `Author socials should be usernames/userIds/handles, or fully qualified HTTP(s) absolute URLs.
@@ -60,7 +61,9 @@ Social platform '${platform}' has illegal value '${value}'`,
60
61
  );
61
62
  }
62
63
  const isAbsoluteUrl =
63
- value.startsWith('http://') || value.startsWith('https://');
64
+ value.startsWith('http://') ||
65
+ value.startsWith('https://') ||
66
+ value.startsWith('mailto:');
64
67
  if (isAbsoluteUrl) {
65
68
  return [platform, value];
66
69
  } else if (value.includes('/')) {
@@ -69,6 +72,7 @@ Social platform '${platform}' has illegal value '${value}'`,
69
72
  Social platform '${platform}' has illegal value '${value}'`,
70
73
  );
71
74
  }
75
+ const normalizer = PredefinedPlatformNormalizers[platform.toLowerCase()];
72
76
  if (normalizer && !isAbsoluteUrl) {
73
77
  const normalizedPlatform = platform.toLowerCase();
74
78
  const normalizedValue = normalizer(value);
package/src/blogUtils.ts CHANGED
@@ -323,7 +323,9 @@ async function processBlogSourceFile(
323
323
  } else if (typeof editUrl === 'string') {
324
324
  const isLocalized = blogDirPath === contentPaths.contentPathLocalized;
325
325
  const fileContentPath =
326
- isLocalized && options.editLocalizedFiles
326
+ isLocalized &&
327
+ options.editLocalizedFiles &&
328
+ contentPaths.contentPathLocalized
327
329
  ? contentPaths.contentPathLocalized
328
330
  : contentPaths.contentPath;
329
331
 
package/src/index.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  getDataFilePath,
20
20
  DEFAULT_PLUGIN_ID,
21
21
  resolveMarkdownLinkPathname,
22
+ getLocaleConfig,
22
23
  } from '@docusaurus/utils';
23
24
  import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
24
25
  import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
@@ -71,15 +72,18 @@ export default async function pluginContentBlog(
71
72
  );
72
73
  }
73
74
 
74
- const {onBrokenMarkdownLinks, baseUrl} = siteConfig;
75
+ const {baseUrl} = siteConfig;
75
76
 
77
+ const shouldTranslate = getLocaleConfig(context.i18n).translate;
76
78
  const contentPaths: BlogContentPaths = {
77
79
  contentPath: path.resolve(siteDir, options.path),
78
- contentPathLocalized: getPluginI18nPath({
79
- localizationDir,
80
- pluginName: PluginName,
81
- pluginId: options.id,
82
- }),
80
+ contentPathLocalized: shouldTranslate
81
+ ? getPluginI18nPath({
82
+ localizationDir,
83
+ pluginName: PluginName,
84
+ pluginId: options.id,
85
+ })
86
+ : undefined,
83
87
  };
84
88
  const pluginId = options.id ?? DEFAULT_PLUGIN_ID;
85
89
 
@@ -154,18 +158,12 @@ export default async function pluginContentBlog(
154
158
  },
155
159
  markdownConfig: siteConfig.markdown,
156
160
  resolveMarkdownLink: ({linkPathname, sourceFilePath}) => {
157
- const permalink = resolveMarkdownLinkPathname(linkPathname, {
161
+ return resolveMarkdownLinkPathname(linkPathname, {
158
162
  sourceFilePath,
159
163
  sourceToPermalink: contentHelpers.sourceToPermalink,
160
164
  siteDir,
161
165
  contentPaths,
162
166
  });
163
- if (permalink === null) {
164
- logger.report(
165
- onBrokenMarkdownLinks,
166
- )`Blog markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath}`;
167
- }
168
- return permalink;
169
167
  },
170
168
  });
171
169