astro-accelerator-utils 0.1.8 → 0.1.11

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.
@@ -69,7 +69,7 @@ export function isNavPage (item) {
69
69
  export async function getNavigation (currentUrl, site) {
70
70
 
71
71
  const key = 'Navigation__getNavigation';
72
- const posts = new Posts();
72
+ const posts = new Posts(cache);
73
73
 
74
74
  /** @type {NavPage[]} */
75
75
  let pageHierarchy = cache.getItem(key);
@@ -156,6 +156,10 @@ export async function getBreadcrumbs (currentUrl, site) {
156
156
  const allPages = await getPages();
157
157
 
158
158
  const pathParts = currentUrl.pathname.split('/');
159
+
160
+ if (site.subfolder.length > 0) {
161
+ pathParts.shift();
162
+ }
159
163
 
160
164
  /** @type {NavPage[]} */
161
165
  const navPages = [];
@@ -11,7 +11,6 @@ export class Posts {
11
11
  constructor(cache: Cache, fetchAll?: () => MarkdownInstance[]);
12
12
  cache: import("./cache.mjs").Cache;
13
13
  fetchAll: () => any;
14
- allPosts: any[];
15
14
  /**
16
15
  * Gets all markdown posts in the site
17
16
  * @returns {MarkdownInstance[]}
package/lib/v1/posts.mjs CHANGED
@@ -12,8 +12,9 @@ export class Posts {
12
12
  constructor(cache, fetchAll) {
13
13
  /* istanbul ignore next */
14
14
  this.cache = cache;
15
- this.fetchAll = fetchAll ?? function() { return import.meta.glob("/src/pages/**/*.md", { eager: true }); }
16
- this.allPosts = [];
15
+ this.fetchAll = fetchAll ?? function() {
16
+ return import.meta.glob("/src/pages/**/*.md", { eager: true });
17
+ }
17
18
  }
18
19
 
19
20
  /**
@@ -21,7 +22,7 @@ export class Posts {
21
22
  * @returns {MarkdownInstance[]}
22
23
  */
23
24
  all () {
24
- const key = 'cache-posts.all()';
25
+ const key = 'v1_posts.all';
25
26
 
26
27
  return this.cache.get(key, () => {
27
28
  const pageImportResult = this.fetchAll();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.1.8",
3
+ "version": "0.1.11",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -1 +1,29 @@
1
- export type Frontmatter = Record<string, any>;
1
+ export interface Frontmatter {
2
+ layout: string;
3
+ title: string;
4
+ subtitle?: string;
5
+ pubDate: Date;
6
+ modDate?: Date;
7
+ tags?: string[];
8
+ id?: string;
9
+ authors?: string[];
10
+ keywords?: string;
11
+ description?: string;
12
+ summary?: string;
13
+ categories?: string[];
14
+ navTitle?: string;
15
+ navSection?: string;
16
+ navOrder?: number;
17
+ bannerImage?: {
18
+ src: string;
19
+ alt: string;
20
+ };
21
+ dir?: 'ltr' | 'rtl';
22
+ lang?: string;
23
+ paged?: boolean;
24
+ navSearch?: boolean;
25
+ navSitemap?: boolean;
26
+ navMenu?: boolean;
27
+ robots?: string;
28
+ redirect?: string;
29
+ }