astro-accelerator-utils 0.0.6 → 0.0.7

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/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export type { Site } from './types/Site';
2
1
  export type { Frontmatter } from './types/Frontmatter';
2
+ export type { PagePredicate } from './types/PagePredicate';
3
+ export type { Site } from './types/Site';
3
4
  export { getCachePath, getItem, getItemPath, setItem } from './lib/Cache';
4
5
  export { formatDate, formatModifiedDate } from './lib/dates';
5
6
  export { isAuthor, isListable, isSearch, showInMenu, showInSearch, showInSitemap } from './lib/postFiltering';
6
7
  export { sortByModDate, sortByPubDate, sortByPubDateDesc } from './lib/postOrdering';
8
+ export { getPages } from './lib/postQueries';
7
9
  export { addSlashToAddress, addSlashToUrl } from './lib/urls';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSlashToUrl = exports.addSlashToAddress = exports.sortByPubDateDesc = exports.sortByPubDate = exports.sortByModDate = exports.showInSitemap = exports.showInSearch = exports.showInMenu = exports.isSearch = exports.isListable = exports.isAuthor = exports.formatModifiedDate = exports.formatDate = exports.setItem = exports.getItemPath = exports.getItem = exports.getCachePath = void 0;
3
+ exports.addSlashToUrl = exports.addSlashToAddress = exports.getPages = exports.sortByPubDateDesc = exports.sortByPubDate = exports.sortByModDate = exports.showInSitemap = exports.showInSearch = exports.showInMenu = exports.isSearch = exports.isListable = exports.isAuthor = exports.formatModifiedDate = exports.formatDate = exports.setItem = exports.getItemPath = exports.getItem = exports.getCachePath = void 0;
4
4
  var Cache_1 = require("./lib/Cache");
5
5
  Object.defineProperty(exports, "getCachePath", { enumerable: true, get: function () { return Cache_1.getCachePath; } });
6
6
  Object.defineProperty(exports, "getItem", { enumerable: true, get: function () { return Cache_1.getItem; } });
@@ -20,6 +20,8 @@ var postOrdering_1 = require("./lib/postOrdering");
20
20
  Object.defineProperty(exports, "sortByModDate", { enumerable: true, get: function () { return postOrdering_1.sortByModDate; } });
21
21
  Object.defineProperty(exports, "sortByPubDate", { enumerable: true, get: function () { return postOrdering_1.sortByPubDate; } });
22
22
  Object.defineProperty(exports, "sortByPubDateDesc", { enumerable: true, get: function () { return postOrdering_1.sortByPubDateDesc; } });
23
+ var postQueries_1 = require("./lib/postQueries");
24
+ Object.defineProperty(exports, "getPages", { enumerable: true, get: function () { return postQueries_1.getPages; } });
23
25
  var urls_1 = require("./lib/urls");
24
26
  Object.defineProperty(exports, "addSlashToAddress", { enumerable: true, get: function () { return urls_1.addSlashToAddress; } });
25
27
  Object.defineProperty(exports, "addSlashToUrl", { enumerable: true, get: function () { return urls_1.addSlashToUrl; } });
@@ -1 +1,3 @@
1
- export declare function globTest(): any;
1
+ import { Markdown } from "../types/Markdown";
2
+ import { PagePredicate } from "../types/PagePredicate";
3
+ export declare function getPages(fetchPages: () => Record<string, any>, filter?: PagePredicate | null): Promise<Markdown<Record<string, any>>[]>;
@@ -1,21 +1,29 @@
1
1
  "use strict";
2
- // export type PagePredicate = (value: MarkdownInstance<Record<string, any>>, index: number, array: MarkdownInstance<Record<string, any>>[]) => boolean;
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
3
11
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.globTest = void 0;
5
- // export async function getPages (filter?: PagePredicate | null): Promise<MarkdownInstance<Record<string,any>>[]> {
6
- // const key = 'PageQueries__getPages';
7
- // let allPages: MarkdownInstance<Record<string,any>>[] = await getItem(key);
8
- // if (allPages == null) {
9
- // const pageImportResult = import.meta.glob("../../../pages/**/*.md", { eager: true });
10
- // allPages = Object.values(pageImportResult) as MarkdownInstance<Record<string,any>>[];
11
- // await setItem(key, allPages);
12
- // }
13
- // if (filter == null) {
14
- // return allPages;
15
- // }
16
- // return allPages.filter(filter);
17
- // }
18
- function globTest() {
19
- return import.meta.glob("../../../../src/pages/**/*.md", { eager: true });
12
+ exports.getPages = void 0;
13
+ const Cache_1 = require("./Cache");
14
+ function getPages(fetchPages, filter) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const key = 'PageQueries__getPages';
17
+ let allPages = yield (0, Cache_1.getItem)(key);
18
+ if (allPages == null) {
19
+ const pageImportResult = fetchPages();
20
+ allPages = Object.values(pageImportResult);
21
+ yield (0, Cache_1.setItem)(key, allPages);
22
+ }
23
+ if (filter == null) {
24
+ return allPages;
25
+ }
26
+ return allPages.filter(filter);
27
+ });
20
28
  }
21
- exports.globTest = globTest;
29
+ exports.getPages = getPages;
@@ -0,0 +1,2 @@
1
+ import { Markdown } from "./Markdown";
2
+ export type PagePredicate = (value: Markdown<Record<string, any>>, index: number, array: Markdown<Record<string, any>>[]) => boolean;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {