astro-accelerator-utils 0.3.52 → 0.3.53

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.
@@ -8,6 +8,7 @@ export class Accelerator {
8
8
  constructor(site: Site);
9
9
  cacheMaxAge: number;
10
10
  dateOptions: Intl.DateTimeFormatOptions;
11
+ shortDateOptions: any;
11
12
  siteUrl: string;
12
13
  subfolder: string;
13
14
  useTrailingUrlSlash: boolean;
@@ -9,6 +9,7 @@ import { Taxonomy } from './taxonomy.mjs';
9
9
  import { UrlFormatter } from './urls.mjs';
10
10
  import { Statistics } from './statistics.mjs';
11
11
  import { StatisticsStub } from './statistics-stub.mjs';
12
+ import { getTextOfJSDocComment } from 'typescript';
12
13
 
13
14
  /**
14
15
  * @typedef { import("../../types/Site").Site } Site
@@ -21,6 +22,7 @@ export class Accelerator {
21
22
  constructor(site) {
22
23
  this.cacheMaxAge = site.cacheMaxAge;
23
24
  this.dateOptions = site.dateOptions;
25
+ this.shortDateOptions = site.shortDateOptions;
24
26
  this.siteUrl = site.url;
25
27
  this.subfolder = site.subfolder;
26
28
  this.useTrailingUrlSlash = site.useTrailingUrlSlash;
@@ -36,7 +38,7 @@ export class Accelerator {
36
38
  }
37
39
 
38
40
  get dateFormatter() {
39
- return new DateFormatter(this.dateOptions)
41
+ return new DateFormatter(this.dateOptions, this.shortDateOptions)
40
42
  }
41
43
 
42
44
  get markdown() {
@@ -5,9 +5,11 @@ export class DateFormatter {
5
5
  /**
6
6
  * Constructor
7
7
  * @param {Intl.DateTimeFormatOptions} dateOptions
8
+ * @param {Intl.DateTimeFormatOptions} shortDateOptions
8
9
  */
9
- constructor(dateOptions: Intl.DateTimeFormatOptions);
10
+ constructor(dateOptions: Intl.DateTimeFormatOptions, shortDateOptions: Intl.DateTimeFormatOptions);
10
11
  dateOptions: Intl.DateTimeFormatOptions;
12
+ shortDateOptions: Intl.DateTimeFormatOptions;
11
13
  /**
12
14
  * Returns the formatted pubDate
13
15
  * @param {string | Date} date
@@ -15,5 +17,12 @@ export class DateFormatter {
15
17
  * @returns {string}
16
18
  */
17
19
  formatDate(date: string | Date, lang: string): string;
20
+ /**
21
+ * Returns the formatted pubDate
22
+ * @param {string | Date} date
23
+ * @param {string} lang
24
+ * @returns {string}
25
+ */
26
+ formatShortDate(date: string | Date, lang: string): string;
18
27
  }
19
28
  export type Site = any;
package/lib/v1/dates.mjs CHANGED
@@ -6,9 +6,11 @@ export class DateFormatter {
6
6
  /**
7
7
  * Constructor
8
8
  * @param {Intl.DateTimeFormatOptions} dateOptions
9
+ * @param {Intl.DateTimeFormatOptions} shortDateOptions
9
10
  */
10
- constructor(dateOptions) {
11
+ constructor(dateOptions, shortDateOptions) {
11
12
  this.dateOptions = dateOptions;
13
+ this.shortDateOptions = shortDateOptions;
12
14
  }
13
15
 
14
16
  /**
@@ -24,4 +26,18 @@ export class DateFormatter {
24
26
 
25
27
  return '';
26
28
  }
29
+
30
+ /**
31
+ * Returns the formatted pubDate
32
+ * @param {string | Date} date
33
+ * @param {string} lang
34
+ * @returns {string}
35
+ */
36
+ formatShortDate(date, lang) {
37
+ if (date) {
38
+ return new Date(date).toLocaleDateString(lang, this.shortDateOptions);
39
+ }
40
+
41
+ return '';
42
+ }
27
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.3.52",
3
+ "version": "0.3.53",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -5,6 +5,7 @@ export interface Frontmatter {
5
5
  subtitle?: string;
6
6
  pubDate: Date;
7
7
  modDate?: Date;
8
+ readingTime?: number;
8
9
  tags?: string[];
9
10
  id?: string;
10
11
  authors?: string[];