astro-accelerator-utils 0.0.1 → 0.0.3
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/dist/Site.d.ts +34 -0
- package/dist/Site.js +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +22 -5
- package/package.json +2 -2
package/dist/Site.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Site = {
|
|
2
|
+
url: string;
|
|
3
|
+
dateOptions: Intl.DateTimeFormatOptions;
|
|
4
|
+
subfolder: string;
|
|
5
|
+
feedUrl: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
defaultLanguage: string;
|
|
9
|
+
themeColor: string;
|
|
10
|
+
owner: string;
|
|
11
|
+
default: {
|
|
12
|
+
lang: string;
|
|
13
|
+
locale: string;
|
|
14
|
+
dir: string;
|
|
15
|
+
};
|
|
16
|
+
search: {
|
|
17
|
+
fallbackUrl: 'https://www.google.com/search' | string;
|
|
18
|
+
fallbackSite: 'q' | string;
|
|
19
|
+
fallbackQuery: 'q' | string;
|
|
20
|
+
};
|
|
21
|
+
pageSize: number;
|
|
22
|
+
pageLinks: number;
|
|
23
|
+
rssLimit: number;
|
|
24
|
+
featureFlags: {
|
|
25
|
+
codeBlocks: 'copy'[];
|
|
26
|
+
figures: 'enlarge'[];
|
|
27
|
+
youTubeLinks: 'embed'[];
|
|
28
|
+
};
|
|
29
|
+
images: {
|
|
30
|
+
contentSize: string;
|
|
31
|
+
listerSize: string;
|
|
32
|
+
authorSize: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
package/dist/Site.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Site } from './Site';
|
|
2
|
+
export type { Site } from './Site';
|
|
1
3
|
type FrontMatter = Record<string, any>;
|
|
2
|
-
type Site = {
|
|
3
|
-
dateOptions: Intl.DateTimeFormatOptions;
|
|
4
|
-
};
|
|
5
4
|
export declare function formatDate(frontmatter: FrontMatter, lang: string, site: Site): string;
|
|
6
5
|
export declare function formatModifiedDate(frontmatter: FrontMatter, lang: string, site: Site): string;
|
|
7
|
-
export
|
|
6
|
+
export declare function addSlashToUrl(url: URL): URL;
|
|
7
|
+
export declare function addSlashToAddress(address: string | undefined, site: Site): string;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
exports.formatModifiedDate = exports.formatDate = void 0;
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addSlashToAddress = exports.addSlashToUrl = exports.formatModifiedDate = exports.formatDate = void 0;
|
|
4
|
+
/* Date Formats */
|
|
5
5
|
function formatDate(frontmatter, lang, site) {
|
|
6
6
|
var _a;
|
|
7
|
-
|
|
7
|
+
const date = (_a = frontmatter.pubDate) !== null && _a !== void 0 ? _a : '';
|
|
8
8
|
if (date) {
|
|
9
9
|
return new Date(date).toLocaleDateString(lang, site.dateOptions);
|
|
10
10
|
}
|
|
@@ -13,10 +13,27 @@ function formatDate(frontmatter, lang, site) {
|
|
|
13
13
|
exports.formatDate = formatDate;
|
|
14
14
|
function formatModifiedDate(frontmatter, lang, site) {
|
|
15
15
|
var _a;
|
|
16
|
-
|
|
16
|
+
const date = (_a = frontmatter.modDate) !== null && _a !== void 0 ? _a : '';
|
|
17
17
|
if (date) {
|
|
18
18
|
return new Date(date).toLocaleDateString(lang, site.dateOptions);
|
|
19
19
|
}
|
|
20
20
|
return '';
|
|
21
21
|
}
|
|
22
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;
|