@docusaurus/plugin-content-blog 0.0.0-4608 → 0.0.0-4614

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/blogUtils.js CHANGED
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
12
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
13
  const reading_time_1 = (0, tslib_1.__importDefault)(require("reading-time"));
14
- const lodash_1 = require("lodash");
14
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const blogFrontMatter_1 = require("./blogFrontMatter");
17
17
  const authors_1 = require("./authors");
@@ -21,7 +21,7 @@ function truncate(fileString, truncateMarker) {
21
21
  }
22
22
  exports.truncate = truncate;
23
23
  function getSourceToPermalink(blogPosts) {
24
- return (0, lodash_1.mapValues)((0, lodash_1.keyBy)(blogPosts, (item) => item.metadata.source), (v) => v.metadata.permalink);
24
+ return Object.fromEntries(blogPosts.map(({ metadata: { source, permalink } }) => [source, permalink]));
25
25
  }
26
26
  exports.getSourceToPermalink = getSourceToPermalink;
27
27
  function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription, postsPerPageOption, }) {
@@ -55,19 +55,16 @@ function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription,
55
55
  exports.paginateBlogPosts = paginateBlogPosts;
56
56
  function getBlogTags({ blogPosts, ...params }) {
57
57
  const groups = (0, utils_1.groupTaggedItems)(blogPosts, (blogPost) => blogPost.metadata.tags);
58
- return (0, lodash_1.mapValues)(groups, (group) => {
59
- const { tag, items: tagBlogPosts } = group;
60
- return {
61
- name: tag.label,
62
- items: tagBlogPosts.map((item) => item.id),
63
- permalink: tag.permalink,
64
- pages: paginateBlogPosts({
65
- blogPosts: tagBlogPosts,
66
- basePageUrl: group.tag.permalink,
67
- ...params,
68
- }),
69
- };
70
- });
58
+ return lodash_1.default.mapValues(groups, ({ tag, items: tagBlogPosts }) => ({
59
+ name: tag.label,
60
+ items: tagBlogPosts.map((item) => item.id),
61
+ permalink: tag.permalink,
62
+ pages: paginateBlogPosts({
63
+ blogPosts: tagBlogPosts,
64
+ basePageUrl: tag.permalink,
65
+ ...params,
66
+ }),
67
+ }));
71
68
  }
72
69
  exports.getBlogTags = getBlogTags;
73
70
  const DATE_FILENAME_REGEX = /^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(?:\/index)?.mdx?$/;
@@ -218,7 +215,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
218
215
  }
219
216
  async function generateBlogPosts(contentPaths, context, options) {
220
217
  const { include, exclude } = options;
221
- if (!fs_extra_1.default.existsSync(contentPaths.contentPath)) {
218
+ if (!(await fs_extra_1.default.pathExists(contentPaths.contentPath))) {
222
219
  return [];
223
220
  }
224
221
  const blogSourceFiles = await (0, utils_1.Globby)(include, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-4608",
3
+ "version": "0.0.0-4614",
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-4608",
22
- "@docusaurus/logger": "0.0.0-4608",
23
- "@docusaurus/mdx-loader": "0.0.0-4608",
24
- "@docusaurus/utils": "0.0.0-4608",
25
- "@docusaurus/utils-common": "0.0.0-4608",
26
- "@docusaurus/utils-validation": "0.0.0-4608",
21
+ "@docusaurus/core": "0.0.0-4614",
22
+ "@docusaurus/logger": "0.0.0-4614",
23
+ "@docusaurus/mdx-loader": "0.0.0-4614",
24
+ "@docusaurus/utils": "0.0.0-4614",
25
+ "@docusaurus/utils-common": "0.0.0-4614",
26
+ "@docusaurus/utils-validation": "0.0.0-4614",
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.69.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@docusaurus/types": "0.0.0-4608",
38
+ "@docusaurus/types": "0.0.0-4614",
39
39
  "escape-string-regexp": "^4.0.0"
40
40
  },
41
41
  "peerDependencies": {
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=14"
47
47
  },
48
- "gitHead": "b22e657f0f14ffe2bbf983b110c58b7ce7e59f39"
48
+ "gitHead": "0fa2e52fbc24ea9aa80a5da40149036009bcf21c"
49
49
  }
package/src/blogUtils.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  import fs from 'fs-extra';
9
9
  import path from 'path';
10
10
  import readingTime from 'reading-time';
11
- import {keyBy, mapValues} from 'lodash';
11
+ import _ from 'lodash';
12
12
  import type {
13
13
  BlogPost,
14
14
  BlogContentPaths,
@@ -46,9 +46,8 @@ export function truncate(fileString: string, truncateMarker: RegExp): string {
46
46
  export function getSourceToPermalink(
47
47
  blogPosts: BlogPost[],
48
48
  ): Record<string, string> {
49
- return mapValues(
50
- keyBy(blogPosts, (item) => item.metadata.source),
51
- (v) => v.metadata.permalink,
49
+ return Object.fromEntries(
50
+ blogPosts.map(({metadata: {source, permalink}}) => [source, permalink]),
52
51
  );
53
52
  }
54
53
 
@@ -112,19 +111,16 @@ export function getBlogTags({
112
111
  (blogPost) => blogPost.metadata.tags,
113
112
  );
114
113
 
115
- return mapValues(groups, (group) => {
116
- const {tag, items: tagBlogPosts} = group;
117
- return {
118
- name: tag.label,
119
- items: tagBlogPosts.map((item) => item.id),
120
- permalink: tag.permalink,
121
- pages: paginateBlogPosts({
122
- blogPosts: tagBlogPosts,
123
- basePageUrl: group.tag.permalink,
124
- ...params,
125
- }),
126
- };
127
- });
114
+ return _.mapValues(groups, ({tag, items: tagBlogPosts}) => ({
115
+ name: tag.label,
116
+ items: tagBlogPosts.map((item) => item.id),
117
+ permalink: tag.permalink,
118
+ pages: paginateBlogPosts({
119
+ blogPosts: tagBlogPosts,
120
+ basePageUrl: tag.permalink,
121
+ ...params,
122
+ }),
123
+ }));
128
124
  }
129
125
 
130
126
  const DATE_FILENAME_REGEX =
@@ -336,7 +332,7 @@ export async function generateBlogPosts(
336
332
  ): Promise<BlogPost[]> {
337
333
  const {include, exclude} = options;
338
334
 
339
- if (!fs.existsSync(contentPaths.contentPath)) {
335
+ if (!(await fs.pathExists(contentPaths.contentPath))) {
340
336
  return [];
341
337
  }
342
338