astro-accelerator-utils 0.0.3 → 0.0.4

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.
@@ -0,0 +1 @@
1
+ export type Frontmatter = Record<string, any>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- import type { Site } from './Site';
2
1
  export type { Site } from './Site';
3
- type FrontMatter = Record<string, any>;
4
- export declare function formatDate(frontmatter: FrontMatter, lang: string, site: Site): string;
5
- export declare function formatModifiedDate(frontmatter: FrontMatter, lang: string, site: Site): string;
6
- export declare function addSlashToUrl(url: URL): URL;
7
- export declare function addSlashToAddress(address: string | undefined, site: Site): string;
2
+ export { formatDate, formatModifiedDate } from './lib/dates';
3
+ export { addSlashToAddress, addSlashToUrl } from './lib/urls';
package/dist/index.js CHANGED
@@ -1,39 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSlashToAddress = exports.addSlashToUrl = exports.formatModifiedDate = exports.formatDate = void 0;
4
- /* Date Formats */
5
- function formatDate(frontmatter, lang, site) {
6
- var _a;
7
- const date = (_a = frontmatter.pubDate) !== null && _a !== void 0 ? _a : '';
8
- if (date) {
9
- return new Date(date).toLocaleDateString(lang, site.dateOptions);
10
- }
11
- return '';
12
- }
13
- exports.formatDate = formatDate;
14
- function formatModifiedDate(frontmatter, lang, site) {
15
- var _a;
16
- const date = (_a = frontmatter.modDate) !== null && _a !== void 0 ? _a : '';
17
- if (date) {
18
- return new Date(date).toLocaleDateString(lang, site.dateOptions);
19
- }
20
- return '';
21
- }
22
- exports.formatModifiedDate = formatModifiedDate;
23
- /* URL Formats */
24
- function addSlashToUrl(url) {
25
- url.pathname += url.pathname.endsWith('/') ? '' : '/';
26
- return url;
27
- }
28
- exports.addSlashToUrl = addSlashToUrl;
29
- function addSlashToAddress(address, site) {
30
- if (!address) {
31
- address = '/';
32
- }
33
- if (address.indexOf('://') > -1) {
34
- return address;
35
- }
36
- const url = addSlashToUrl(new URL(address, site.url));
37
- return url.pathname + url.search;
38
- }
39
- exports.addSlashToAddress = addSlashToAddress;
3
+ exports.addSlashToUrl = exports.addSlashToAddress = exports.formatModifiedDate = exports.formatDate = void 0;
4
+ var dates_1 = require("./lib/dates");
5
+ Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return dates_1.formatDate; } });
6
+ Object.defineProperty(exports, "formatModifiedDate", { enumerable: true, get: function () { return dates_1.formatModifiedDate; } });
7
+ var urls_1 = require("./lib/urls");
8
+ Object.defineProperty(exports, "addSlashToAddress", { enumerable: true, get: function () { return urls_1.addSlashToAddress; } });
9
+ Object.defineProperty(exports, "addSlashToUrl", { enumerable: true, get: function () { return urls_1.addSlashToUrl; } });
@@ -0,0 +1,6 @@
1
+ import type { Site } from '../Site';
2
+ import type { Frontmatter } from '../Frontmatter';
3
+ export type { Site } from '../Site';
4
+ export type { Frontmatter as FrontMatter } from '../Frontmatter';
5
+ export declare function formatDate(frontmatter: Frontmatter, lang: string, site: Site): string;
6
+ export declare function formatModifiedDate(frontmatter: Frontmatter, lang: string, site: Site): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatModifiedDate = exports.formatDate = void 0;
4
+ function formatDate(frontmatter, lang, site) {
5
+ var _a;
6
+ const date = (_a = frontmatter.pubDate) !== null && _a !== void 0 ? _a : '';
7
+ if (date) {
8
+ return new Date(date).toLocaleDateString(lang, site.dateOptions);
9
+ }
10
+ return '';
11
+ }
12
+ exports.formatDate = formatDate;
13
+ function formatModifiedDate(frontmatter, lang, site) {
14
+ var _a;
15
+ const date = (_a = frontmatter.modDate) !== null && _a !== void 0 ? _a : '';
16
+ if (date) {
17
+ return new Date(date).toLocaleDateString(lang, site.dateOptions);
18
+ }
19
+ return '';
20
+ }
21
+ exports.formatModifiedDate = formatModifiedDate;
@@ -0,0 +1,4 @@
1
+ import type { Site } from '../Site';
2
+ export type { Site } from '../Site';
3
+ export declare function addSlashToUrl(url: URL): URL;
4
+ export declare function addSlashToAddress(address: string | undefined, site: Site): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSlashToAddress = exports.addSlashToUrl = void 0;
4
+ function addSlashToUrl(url) {
5
+ url.pathname += url.pathname.endsWith('/') ? '' : '/';
6
+ return url;
7
+ }
8
+ exports.addSlashToUrl = addSlashToUrl;
9
+ function addSlashToAddress(address, site) {
10
+ if (!address) {
11
+ address = '/';
12
+ }
13
+ if (address.indexOf('://') > -1) {
14
+ return address;
15
+ }
16
+ const url = addSlashToUrl(new URL(address, site.url));
17
+ return url.pathname + url.search;
18
+ }
19
+ exports.addSlashToAddress = addSlashToAddress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {