@docusaurus/plugin-content-blog 0.0.0-4521 → 0.0.0-4526

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/authors.js CHANGED
@@ -52,9 +52,9 @@ function getFrontMatterAuthorLegacy(frontMatter) {
52
52
  function normalizeFrontMatterAuthors(frontMatterAuthors = []) {
53
53
  function normalizeAuthor(authorInput) {
54
54
  if (typeof authorInput === 'string') {
55
- // Technically, we could allow users to provide an author's name here
56
- // IMHO it's better to only support keys here
57
- // Reason: a typo in a key would fallback to becoming a name and may end-up un-noticed
55
+ // Technically, we could allow users to provide an author's name here, but
56
+ // we only support keys, otherwise, a typo in a key would fallback to
57
+ // becoming a name and may end up unnoticed
58
58
  return { key: authorInput };
59
59
  }
60
60
  return authorInput;
@@ -97,7 +97,8 @@ function getBlogPostAuthors(params) {
97
97
  const authorLegacy = getFrontMatterAuthorLegacy(params.frontMatter);
98
98
  const authors = getFrontMatterAuthors(params);
99
99
  if (authorLegacy) {
100
- // Technically, we could allow mixing legacy/authors front matter, but do we really want to?
100
+ // Technically, we could allow mixing legacy/authors front matter, but do we
101
+ // really want to?
101
102
  if (authors.length > 0) {
102
103
  throw new Error(`To declare blog post authors, use the 'authors' front matter in priority.
103
104
  Don't mix 'authors' with other existing 'author_*' front matter. Choose one or the other, not both at the same time.`);
package/lib/blogUtils.js CHANGED
@@ -33,7 +33,7 @@ function getBlogTags(blogPosts) {
33
33
  }));
34
34
  }
35
35
  exports.getBlogTags = getBlogTags;
36
- const DATE_FILENAME_REGEX = /^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(\/index)?.mdx?$/;
36
+ const DATE_FILENAME_REGEX = /^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(?:\/index)?.mdx?$/;
37
37
  function parseBlogFileName(blogSourceRelative) {
38
38
  const dateFilenameMatch = blogSourceRelative.match(DATE_FILENAME_REGEX);
39
39
  if (dateFilenameMatch) {
@@ -44,11 +44,9 @@ function parseBlogFileName(blogSourceRelative) {
44
44
  const slug = `/${slugDate}/${folder}${text}`;
45
45
  return { date, text, slug };
46
46
  }
47
- else {
48
- const text = blogSourceRelative.replace(/(\/index)?\.mdx?$/, '');
49
- const slug = `/${text}`;
50
- return { date: undefined, text, slug };
51
- }
47
+ const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
48
+ const slug = `/${text}`;
49
+ return { date: undefined, text, slug };
52
50
  }
53
51
  exports.parseBlogFileName = parseBlogFileName;
54
52
  function formatBlogPostDate(locale, date) {
package/lib/index.js CHANGED
@@ -193,7 +193,8 @@ async function pluginContentBlog(context, options) {
193
193
  modules: {
194
194
  sidebar: aliasedSource(sidebarProp),
195
195
  items: items.map((postID) =>
196
- // To tell routes.js this is an import and not a nested object to recurse.
196
+ // To tell routes.js this is an import and not a nested object
197
+ // to recurse.
197
198
  ({
198
199
  content: {
199
200
  __import: true,
@@ -286,7 +287,7 @@ async function pluginContentBlog(context, options) {
286
287
  module: {
287
288
  rules: [
288
289
  {
289
- test: /(\.mdx?)$/,
290
+ test: /\.mdx?$/i,
290
291
  include: contentDirs
291
292
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
292
293
  .map(utils_1.addTrailingPathSeparator),
@@ -311,7 +312,8 @@ async function pluginContentBlog(context, options) {
311
312
  // For blog posts a title in markdown is always removed
312
313
  // Blog posts title are rendered separately
313
314
  removeContentTitle: true,
314
- // Assets allow to convert some relative images paths to require() calls
315
+ // Assets allow to convert some relative images paths to
316
+ // require() calls
315
317
  createAssets: ({ frontMatter, metadata, }) => ({
316
318
  image: frontMatter.image,
317
319
  authorsImageUrls: metadata.authors.map((author) => author.imageURL),
@@ -14,7 +14,7 @@ exports.DEFAULT_OPTIONS = {
14
14
  beforeDefaultRehypePlugins: [],
15
15
  beforeDefaultRemarkPlugins: [],
16
16
  admonitions: {},
17
- truncateMarker: /<!--\s*(truncate)\s*-->/,
17
+ truncateMarker: /<!--\s*truncate\s*-->/,
18
18
  rehypePlugins: [],
19
19
  remarkPlugins: [],
20
20
  showReadingTime: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-4521",
3
+ "version": "0.0.0-4526",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -18,12 +18,12 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-4521",
22
- "@docusaurus/logger": "0.0.0-4521",
23
- "@docusaurus/mdx-loader": "0.0.0-4521",
24
- "@docusaurus/utils": "0.0.0-4521",
25
- "@docusaurus/utils-common": "0.0.0-4521",
26
- "@docusaurus/utils-validation": "0.0.0-4521",
21
+ "@docusaurus/core": "0.0.0-4526",
22
+ "@docusaurus/logger": "0.0.0-4526",
23
+ "@docusaurus/mdx-loader": "0.0.0-4526",
24
+ "@docusaurus/utils": "0.0.0-4526",
25
+ "@docusaurus/utils-common": "0.0.0-4526",
26
+ "@docusaurus/utils-validation": "0.0.0-4526",
27
27
  "cheerio": "^1.0.0-rc.10",
28
28
  "feed": "^4.2.2",
29
29
  "fs-extra": "^10.0.0",
@@ -35,7 +35,7 @@
35
35
  "webpack": "^5.61.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@docusaurus/types": "0.0.0-4521",
38
+ "@docusaurus/types": "0.0.0-4526",
39
39
  "escape-string-regexp": "^4.0.0"
40
40
  },
41
41
  "peerDependencies": {
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=14"
48
48
  },
49
- "gitHead": "10eacaa44e87420d300c367fc5e1538c21485767"
49
+ "gitHead": "3086e9e823783e306698097d959007f44de275b1"
50
50
  }
package/src/authors.ts CHANGED
@@ -83,9 +83,9 @@ function normalizeFrontMatterAuthors(
83
83
  authorInput: string | BlogPostFrontMatterAuthor,
84
84
  ): BlogPostFrontMatterAuthor {
85
85
  if (typeof authorInput === 'string') {
86
- // Technically, we could allow users to provide an author's name here
87
- // IMHO it's better to only support keys here
88
- // Reason: a typo in a key would fallback to becoming a name and may end-up un-noticed
86
+ // Technically, we could allow users to provide an author's name here, but
87
+ // we only support keys, otherwise, a typo in a key would fallback to
88
+ // becoming a name and may end up unnoticed
89
89
  return {key: authorInput};
90
90
  }
91
91
  return authorInput;
@@ -137,7 +137,8 @@ export function getBlogPostAuthors(params: AuthorsParam): Author[] {
137
137
  const authors = getFrontMatterAuthors(params);
138
138
 
139
139
  if (authorLegacy) {
140
- // Technically, we could allow mixing legacy/authors front matter, but do we really want to?
140
+ // Technically, we could allow mixing legacy/authors front matter, but do we
141
+ // really want to?
141
142
  if (authors.length > 0) {
142
143
  throw new Error(
143
144
  `To declare blog post authors, use the 'authors' front matter in priority.
package/src/blogUtils.ts CHANGED
@@ -63,7 +63,7 @@ export function getBlogTags(blogPosts: BlogPost[]): BlogTags {
63
63
  }
64
64
 
65
65
  const DATE_FILENAME_REGEX =
66
- /^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(\/index)?.mdx?$/;
66
+ /^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(?:\/index)?.mdx?$/;
67
67
 
68
68
  type ParsedBlogFileName = {
69
69
  date: Date | undefined;
@@ -82,11 +82,10 @@ export function parseBlogFileName(
82
82
  const slugDate = dateString.replace(/-/g, '/');
83
83
  const slug = `/${slugDate}/${folder}${text}`;
84
84
  return {date, text, slug};
85
- } else {
86
- const text = blogSourceRelative.replace(/(\/index)?\.mdx?$/, '');
87
- const slug = `/${text}`;
88
- return {date: undefined, text, slug};
89
85
  }
86
+ const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
87
+ const slug = `/${text}`;
88
+ return {date: undefined, text, slug};
90
89
  }
91
90
 
92
91
  function formatBlogPostDate(locale: string, date: Date): string {
package/src/index.ts CHANGED
@@ -322,7 +322,8 @@ export default async function pluginContentBlog(
322
322
  modules: {
323
323
  sidebar: aliasedSource(sidebarProp),
324
324
  items: items.map((postID) =>
325
- // To tell routes.js this is an import and not a nested object to recurse.
325
+ // To tell routes.js this is an import and not a nested object
326
+ // to recurse.
326
327
  ({
327
328
  content: {
328
329
  __import: true,
@@ -451,7 +452,7 @@ export default async function pluginContentBlog(
451
452
  module: {
452
453
  rules: [
453
454
  {
454
- test: /(\.mdx?)$/,
455
+ test: /\.mdx?$/i,
455
456
  include: contentDirs
456
457
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
457
458
  .map(addTrailingPathSeparator),
@@ -485,7 +486,8 @@ export default async function pluginContentBlog(
485
486
  // Blog posts title are rendered separately
486
487
  removeContentTitle: true,
487
488
 
488
- // Assets allow to convert some relative images paths to require() calls
489
+ // Assets allow to convert some relative images paths to
490
+ // require() calls
489
491
  createAssets: ({
490
492
  frontMatter,
491
493
  metadata,
@@ -20,7 +20,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
20
20
  beforeDefaultRehypePlugins: [],
21
21
  beforeDefaultRemarkPlugins: [],
22
22
  admonitions: {},
23
- truncateMarker: /<!--\s*(truncate)\s*-->/,
23
+ truncateMarker: /<!--\s*truncate\s*-->/,
24
24
  rehypePlugins: [],
25
25
  remarkPlugins: [],
26
26
  showReadingTime: true,