@docusaurus/plugin-content-blog 0.0.0-6065 → 0.0.0-6068

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.
Files changed (3) hide show
  1. package/lib/index.js +12 -13
  2. package/package.json +10 -10
  3. package/src/index.ts +16 -25
package/lib/index.js CHANGED
@@ -70,23 +70,22 @@ async function pluginContentBlog(context, options) {
70
70
  // Note that metadataPath must be the same/in-sync as
71
71
  // the path from createData for each MDX.
72
72
  const aliasedPath = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
73
- const metadataPath = path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
74
- const metadataContent = contentHelpers.sourceToBlogPost.get(aliasedPath).metadata;
75
- return {
76
- metadataPath,
77
- metadataContent,
78
- };
73
+ return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
79
74
  },
80
75
  // For blog posts a title in markdown is always removed
81
76
  // Blog posts title are rendered separately
82
77
  removeContentTitle: true,
83
- // Assets allow to convert some relative images paths to
84
- // require() calls
85
- // @ts-expect-error: TODO fix typing issue
86
- createAssets: ({ frontMatter, metadata, }) => ({
87
- image: frontMatter.image,
88
- authorsImageUrls: metadata.authors.map((author) => author.imageURL),
89
- }),
78
+ // createAssets converts relative paths to require() calls
79
+ createAssets: ({ filePath }) => {
80
+ const blogPost = contentHelpers.sourceToBlogPost.get((0, utils_1.aliasedSitePath)(filePath, siteDir));
81
+ if (!blogPost) {
82
+ throw new Error(`Blog post not found for filePath=${filePath}`);
83
+ }
84
+ return {
85
+ image: blogPost.metadata.frontMatter.image,
86
+ authorsImageUrls: blogPost.metadata.authors.map((author) => author.imageURL),
87
+ };
88
+ },
90
89
  markdownConfig: siteConfig.markdown,
91
90
  resolveMarkdownLink: ({ linkPathname, sourceFilePath }) => {
92
91
  const permalink = (0, utils_1.resolveMarkdownLinkPathname)(linkPathname, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-6065",
3
+ "version": "0.0.0-6068",
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": "0.0.0-6065",
35
- "@docusaurus/logger": "0.0.0-6065",
36
- "@docusaurus/mdx-loader": "0.0.0-6065",
37
- "@docusaurus/theme-common": "0.0.0-6065",
38
- "@docusaurus/types": "0.0.0-6065",
39
- "@docusaurus/utils": "0.0.0-6065",
40
- "@docusaurus/utils-common": "0.0.0-6065",
41
- "@docusaurus/utils-validation": "0.0.0-6065",
34
+ "@docusaurus/core": "0.0.0-6068",
35
+ "@docusaurus/logger": "0.0.0-6068",
36
+ "@docusaurus/mdx-loader": "0.0.0-6068",
37
+ "@docusaurus/theme-common": "0.0.0-6068",
38
+ "@docusaurus/types": "0.0.0-6068",
39
+ "@docusaurus/utils": "0.0.0-6068",
40
+ "@docusaurus/utils-common": "0.0.0-6068",
41
+ "@docusaurus/utils-validation": "0.0.0-6068",
42
42
  "cheerio": "1.0.0-rc.12",
43
43
  "feed": "^4.2.2",
44
44
  "fs-extra": "^11.1.1",
@@ -62,5 +62,5 @@
62
62
  "@total-typescript/shoehorn": "^0.1.2",
63
63
  "tree-node-cli": "^1.6.0"
64
64
  },
65
- "gitHead": "6da713a524315a36515fc3e998ff1551bfa054d2"
65
+ "gitHead": "4f0bc982b589965d7238334bb9b5bf6c483cc35a"
66
66
  }
package/src/index.ts CHANGED
@@ -44,8 +44,6 @@ import type {BlogContentPaths, BlogMarkdownLoaderOptions} from './types';
44
44
  import type {LoadContext, Plugin} from '@docusaurus/types';
45
45
  import type {
46
46
  PluginOptions,
47
- BlogPostFrontMatter,
48
- BlogPostMetadata,
49
47
  Assets,
50
48
  BlogTags,
51
49
  BlogContent,
@@ -135,33 +133,26 @@ export default async function pluginContentBlog(
135
133
  // Note that metadataPath must be the same/in-sync as
136
134
  // the path from createData for each MDX.
137
135
  const aliasedPath = aliasedSitePath(mdxPath, siteDir);
138
- const metadataPath = path.join(
139
- dataDir,
140
- `${docuHash(aliasedPath)}.json`,
141
- );
142
- const metadataContent =
143
- contentHelpers.sourceToBlogPost.get(aliasedPath)!.metadata;
144
- return {
145
- metadataPath,
146
- metadataContent,
147
- };
136
+ return path.join(dataDir, `${docuHash(aliasedPath)}.json`);
148
137
  },
149
138
  // For blog posts a title in markdown is always removed
150
139
  // Blog posts title are rendered separately
151
140
  removeContentTitle: true,
152
- // Assets allow to convert some relative images paths to
153
- // require() calls
154
- // @ts-expect-error: TODO fix typing issue
155
- createAssets: ({
156
- frontMatter,
157
- metadata,
158
- }: {
159
- frontMatter: BlogPostFrontMatter;
160
- metadata: BlogPostMetadata;
161
- }): Assets => ({
162
- image: frontMatter.image,
163
- authorsImageUrls: metadata.authors.map((author) => author.imageURL),
164
- }),
141
+ // createAssets converts relative paths to require() calls
142
+ createAssets: ({filePath}: {filePath: string}): Assets => {
143
+ const blogPost = contentHelpers.sourceToBlogPost.get(
144
+ aliasedSitePath(filePath, siteDir),
145
+ )!;
146
+ if (!blogPost) {
147
+ throw new Error(`Blog post not found for filePath=${filePath}`);
148
+ }
149
+ return {
150
+ image: blogPost.metadata.frontMatter.image as string,
151
+ authorsImageUrls: blogPost.metadata.authors.map(
152
+ (author) => author.imageURL,
153
+ ),
154
+ };
155
+ },
165
156
  markdownConfig: siteConfig.markdown,
166
157
  resolveMarkdownLink: ({linkPathname, sourceFilePath}) => {
167
158
  const permalink = resolveMarkdownLinkPathname(linkPathname, {