@docusaurus/plugin-content-docs 0.0.0-5158 → 0.0.0-5163

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/docs.js +16 -3
  2. package/package.json +9 -9
  3. package/src/docs.ts +20 -3
package/lib/docs.js CHANGED
@@ -151,6 +151,21 @@ async function doProcessDocMetadata({ docFile, versionMetadata, context, options
151
151
  return undefined;
152
152
  }
153
153
  const draft = isDraftForEnvironment({ env, frontMatter });
154
+ const formatDate = (locale, date, calendar) => {
155
+ try {
156
+ return new Intl.DateTimeFormat(locale, {
157
+ day: 'numeric',
158
+ month: 'short',
159
+ year: 'numeric',
160
+ timeZone: 'UTC',
161
+ calendar,
162
+ }).format(date);
163
+ }
164
+ catch (err) {
165
+ logger_1.default.error `Can't format docs lastUpdatedAt date "${String(date)}"`;
166
+ throw err;
167
+ }
168
+ };
154
169
  // Assign all of object properties during instantiation (if possible) for
155
170
  // NodeJS optimization.
156
171
  // Adding properties to object after instantiation will cause hidden
@@ -171,9 +186,7 @@ async function doProcessDocMetadata({ docFile, versionMetadata, context, options
171
186
  lastUpdatedBy: lastUpdate.lastUpdatedBy,
172
187
  lastUpdatedAt: lastUpdate.lastUpdatedAt,
173
188
  formattedLastUpdatedAt: lastUpdate.lastUpdatedAt
174
- ? new Intl.DateTimeFormat(i18n.currentLocale, {
175
- calendar: i18n.localeConfigs[i18n.currentLocale].calendar,
176
- }).format(lastUpdate.lastUpdatedAt * 1000)
189
+ ? formatDate(i18n.currentLocale, new Date(lastUpdate.lastUpdatedAt * 1000), i18n.localeConfigs[i18n.currentLocale].calendar)
177
190
  : undefined,
178
191
  sidebarPosition,
179
192
  frontMatter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-5158",
3
+ "version": "0.0.0-5163",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@docusaurus/core": "0.0.0-5158",
38
- "@docusaurus/logger": "0.0.0-5158",
39
- "@docusaurus/mdx-loader": "0.0.0-5158",
40
- "@docusaurus/module-type-aliases": "0.0.0-5158",
41
- "@docusaurus/types": "0.0.0-5158",
42
- "@docusaurus/utils": "0.0.0-5158",
43
- "@docusaurus/utils-validation": "0.0.0-5158",
37
+ "@docusaurus/core": "0.0.0-5163",
38
+ "@docusaurus/logger": "0.0.0-5163",
39
+ "@docusaurus/mdx-loader": "0.0.0-5163",
40
+ "@docusaurus/module-type-aliases": "0.0.0-5163",
41
+ "@docusaurus/types": "0.0.0-5163",
42
+ "@docusaurus/utils": "0.0.0-5163",
43
+ "@docusaurus/utils-validation": "0.0.0-5163",
44
44
  "@types/react-router-config": "^5.0.6",
45
45
  "combine-promises": "^1.1.0",
46
46
  "fs-extra": "^10.1.0",
@@ -67,5 +67,5 @@
67
67
  "engines": {
68
68
  "node": ">=16.14"
69
69
  },
70
- "gitHead": "ea859210885e381b9d02e36c92ae36b261792d13"
70
+ "gitHead": "bc7415921af946bcf7412dc86387f3688229614b"
71
71
  }
package/src/docs.ts CHANGED
@@ -270,6 +270,21 @@ async function doProcessDocMetadata({
270
270
 
271
271
  const draft = isDraftForEnvironment({env, frontMatter});
272
272
 
273
+ const formatDate = (locale: string, date: Date, calendar: string): string => {
274
+ try {
275
+ return new Intl.DateTimeFormat(locale, {
276
+ day: 'numeric',
277
+ month: 'short',
278
+ year: 'numeric',
279
+ timeZone: 'UTC',
280
+ calendar,
281
+ }).format(date);
282
+ } catch (err) {
283
+ logger.error`Can't format docs lastUpdatedAt date "${String(date)}"`;
284
+ throw err;
285
+ }
286
+ };
287
+
273
288
  // Assign all of object properties during instantiation (if possible) for
274
289
  // NodeJS optimization.
275
290
  // Adding properties to object after instantiation will cause hidden
@@ -290,9 +305,11 @@ async function doProcessDocMetadata({
290
305
  lastUpdatedBy: lastUpdate.lastUpdatedBy,
291
306
  lastUpdatedAt: lastUpdate.lastUpdatedAt,
292
307
  formattedLastUpdatedAt: lastUpdate.lastUpdatedAt
293
- ? new Intl.DateTimeFormat(i18n.currentLocale, {
294
- calendar: i18n.localeConfigs[i18n.currentLocale]!.calendar,
295
- }).format(lastUpdate.lastUpdatedAt * 1000)
308
+ ? formatDate(
309
+ i18n.currentLocale,
310
+ new Date(lastUpdate.lastUpdatedAt * 1000),
311
+ i18n.localeConfigs[i18n.currentLocale]!.calendar,
312
+ )
296
313
  : undefined,
297
314
  sidebarPosition,
298
315
  frontMatter,