astro-accelerator-utils 0.1.21 → 0.1.22

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/index.d.mts CHANGED
@@ -9,5 +9,4 @@ import { Taxonomy } from "./lib/v1/taxonomy.mjs";
9
9
  import { UrlFormatter } from "./lib/v1/urls.mjs";
10
10
  import * as PostFiltering from "./lib/postFiltering.mjs";
11
11
  import * as PostOrdering from "./lib/postOrdering.mjs";
12
- import * as FooterMenu from "./lib/footerMenu.mjs";
13
- export { Authors, Cache, DateFormatter, Markdown, Navigation, Paging, Posts, Taxonomy, UrlFormatter, PostFiltering, PostOrdering, FooterMenu };
12
+ export { Authors, Cache, DateFormatter, Markdown, Navigation, Paging, Posts, Taxonomy, UrlFormatter, PostFiltering, PostOrdering };
package/index.mjs CHANGED
@@ -10,7 +10,6 @@ import { UrlFormatter } from './lib/v1/urls.mjs';
10
10
 
11
11
  import * as PostFiltering from './lib/postFiltering.mjs';
12
12
  import * as PostOrdering from './lib/postOrdering.mjs';
13
- import * as FooterMenu from './lib/footerMenu.mjs';
14
13
 
15
14
  export {
16
15
  Authors,
@@ -23,6 +22,5 @@ export {
23
22
  Taxonomy,
24
23
  UrlFormatter,
25
24
  PostFiltering,
26
- PostOrdering,
27
- FooterMenu
25
+ PostOrdering
28
26
  };
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * @typedef { import("./posts.mjs").Posts } Posts
3
+ * @typedef { import("./taxonomy.mjs").Taxonomy } Taxonomy
4
+ * @typedef { import("./urls.mjs").UrlFormatter } UrlFormatter
2
5
  * @typedef { import("../../types/Astro").MarkdownInstance } MarkdownInstance
3
6
  * @typedef { import("../../types/NavPage").NavPage } NavPage
4
7
  */
@@ -7,10 +10,12 @@ export class Navigation {
7
10
  * Constructor
8
11
  * @param {Posts} posts
9
12
  * @param {UrlFormatter} urlFormatter
13
+ * @param {Taxonomy} taxonomy
10
14
  */
11
- constructor(posts: Posts, urlFormatter: UrlFormatter);
12
- posts: Posts;
13
- urlFormatter: UrlFormatter;
15
+ constructor(posts: Posts, urlFormatter: UrlFormatter, taxonomy: Taxonomy);
16
+ posts: import("./posts.mjs").Posts;
17
+ urlFormatter: import("./urls.mjs").UrlFormatter;
18
+ taxonomy: import("./taxonomy.mjs").Taxonomy;
14
19
  /**
15
20
  * Returns a list of breadcrumbs
16
21
  * @param {URL} currentUrl
@@ -32,6 +37,46 @@ export class Navigation {
32
37
  * @returns {NavPage[]}
33
38
  */
34
39
  autoMenu(subfolder: string): NavPage[];
40
+ /**
41
+ *
42
+ * @param {URL} currentUrl
43
+ * @param {TranslationProvider} _
44
+ * @param {any} translations
45
+ * @param {string} subfolder
46
+ * @param {(NavPage | 'categories' | 'tags' | 'toptags')[]} menu
47
+ * @returns {NavPage[]}
48
+ */
49
+ footer(currentUrl: URL, _: TranslationProvider, translations: any, subfolder: string, menu: (NavPage | 'categories' | 'tags' | 'toptags')[]): NavPage[];
50
+ /**
51
+ *
52
+ * @param {TaxonomyLinks} links
53
+ * @param {TranslationProvider} _
54
+ * @param {any} translations
55
+ * @param {string} subfolder
56
+ * @param {TaxonomyList} entries
57
+ * @returns {NavPage[]}
58
+ */
59
+ getCategories(links: TaxonomyLinks, _: TranslationProvider, translations: any, subfolder: string, entries: TaxonomyList): NavPage[];
60
+ /**
61
+ *
62
+ * @param {TaxonomyLinks} links
63
+ * @param {TranslationProvider} _
64
+ * @param {any} translations
65
+ * @param {string} subfolder
66
+ * @param {TaxonomyList} entries
67
+ * @returns {NavPage[]}
68
+ */
69
+ getTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, subfolder: string, entries: TaxonomyList): NavPage[];
70
+ /**
71
+ *
72
+ * @param {TaxonomyLinks} links
73
+ * @param {TranslationProvider} _
74
+ * @param {any} translations
75
+ * @param {string} subfolder
76
+ * @param {TaxonomyList} entries
77
+ * @returns {NavPage[]}
78
+ */
79
+ getTopTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, subfolder: string, entries: TaxonomyList): NavPage[];
35
80
  /**
36
81
  * Walks a NavPage tree to set current page
37
82
  * @param {NavPage[]} pages
@@ -58,5 +103,8 @@ export class Navigation {
58
103
  */
59
104
  popMatchingPage(allPages: MarkdownInstance[], search: string): import("../../types/Astro").MarkdownInstance;
60
105
  }
106
+ export type Posts = import("./posts.mjs").Posts;
107
+ export type Taxonomy = import("./taxonomy.mjs").Taxonomy;
108
+ export type UrlFormatter = import("./urls.mjs").UrlFormatter;
61
109
  export type MarkdownInstance = import("../../types/Astro").MarkdownInstance;
62
110
  export type NavPage = import("../../types/NavPage").NavPage;
@@ -1,6 +1,9 @@
1
1
  import * as PostFiltering from '../postFiltering.mjs';
2
2
 
3
3
  /**
4
+ * @typedef { import("./posts.mjs").Posts } Posts
5
+ * @typedef { import("./taxonomy.mjs").Taxonomy } Taxonomy
6
+ * @typedef { import("./urls.mjs").UrlFormatter } UrlFormatter
4
7
  * @typedef { import("../../types/Astro").MarkdownInstance } MarkdownInstance
5
8
  * @typedef { import("../../types/NavPage").NavPage } NavPage
6
9
  */
@@ -10,11 +13,12 @@ export class Navigation {
10
13
  * Constructor
11
14
  * @param {Posts} posts
12
15
  * @param {UrlFormatter} urlFormatter
16
+ * @param {Taxonomy} taxonomy
13
17
  */
14
- constructor(posts, urlFormatter) {
15
- /* istanbul ignore next */
18
+ constructor(posts, urlFormatter, taxonomy) {
16
19
  this.posts = posts;
17
20
  this.urlFormatter = urlFormatter;
21
+ this.taxonomy = taxonomy;
18
22
  }
19
23
 
20
24
  /**
@@ -23,31 +27,31 @@ export class Navigation {
23
27
  * @param {string} subfolder
24
28
  * @returns {NavPage[]}
25
29
  */
26
- breadcrumbs (currentUrl, subfolder) {
30
+ breadcrumbs(currentUrl, subfolder) {
27
31
  const allPages = this.posts.all();
28
32
 
29
33
  const pathParts = currentUrl.pathname.split('/');
30
-
34
+
31
35
  if (subfolder.length > 0) {
32
36
  // Running in a subfolder
33
37
  pathParts.shift();
34
38
  }
35
-
39
+
36
40
  /** @type {NavPage[]} */
37
41
  const navPages = [];
38
42
  let path = '';
39
-
43
+
40
44
  pathParts.forEach((part) => {
41
45
  path += part.length > 0 ? '/' + part : '';
42
46
  const match = this.popMatchingPage(allPages, path);
43
-
47
+
44
48
  if (match) {
45
49
  navPages.push(this.mapNavPage(match));
46
50
  }
47
51
  });
48
-
52
+
49
53
  this.setCurrentPage(navPages, currentUrl);
50
-
54
+
51
55
  return navPages;
52
56
  }
53
57
 
@@ -58,19 +62,19 @@ export class Navigation {
58
62
  * @param {(NavPage | 'auto')[]} menu
59
63
  * @returns {NavPage[]}
60
64
  */
61
- menu (currentUrl, subfolder, menu) {
62
- const pages = [];
63
- for (let i = 0; i < menu.length; i++) {
64
- const item = menu[i];
65
- if (this.isNavPage(item)) {
66
- pages.push(item);
67
- } else {
68
- const p = this.autoMenu(subfolder);
69
- for (let j = 0; j < p.length; j++) {
70
- pages.push(p[j]);
71
- }
65
+ menu(currentUrl, subfolder, menu) {
66
+ const pages = [];
67
+ for (let i = 0; i < menu.length; i++) {
68
+ const item = menu[i];
69
+ if (this.isNavPage(item)) {
70
+ pages.push(item);
71
+ } else {
72
+ const p = this.autoMenu(subfolder);
73
+ for (let j = 0; j < p.length; j++) {
74
+ pages.push(p[j]);
72
75
  }
73
76
  }
77
+ }
74
78
 
75
79
  this.setCurrentPage(pages, currentUrl);
76
80
 
@@ -82,7 +86,7 @@ export class Navigation {
82
86
  * @param {string} subfolder
83
87
  * @returns {NavPage[]}
84
88
  */
85
- autoMenu (subfolder) {
89
+ autoMenu(subfolder) {
86
90
  const allPages = this.posts
87
91
  .all()
88
92
  .filter(PostFiltering.showInMenu);
@@ -94,7 +98,7 @@ export class Navigation {
94
98
  const pageHierarchy = topLevelPages
95
99
  .map(p => this.mapNavPage(p))
96
100
  .sort((a, b) => a.order - b.order);
97
-
101
+
98
102
  /** @type {NavPage[]} */
99
103
  const pageList = allPages.map(p => this.mapNavPage(p));
100
104
 
@@ -123,19 +127,191 @@ export class Navigation {
123
127
  return pageHierarchy;
124
128
  }
125
129
 
130
+ /**
131
+ *
132
+ * @param {URL} currentUrl
133
+ * @param {TranslationProvider} _
134
+ * @param {any} translations
135
+ * @param {string} subfolder
136
+ * @param {(NavPage | 'categories' | 'tags' | 'toptags')[]} menu
137
+ * @returns {NavPage[]}
138
+ */
139
+ footer(currentUrl, _, translations, subfolder, menu) {
140
+
141
+ // const cache = new Cache(site.cacheMaxAge);
142
+ // const posts = new Posts(cache);
143
+ // const urlFormatter = new UrlFormatter(site.url);
144
+ // const taxonomy = new Taxonomy(cache, posts, urlFormatter);
145
+ // const navigation = new Navigation(posts, urlFormatter);
146
+ const links = this.taxonomy.links(translations, _, subfolder);
147
+ const entries = this.taxonomy.getTaxonomy();
148
+
149
+ /** @type {NavPage[]} */
150
+ let pages = [];
151
+
152
+ for (let i = 0; i < menu.length; i++) {
153
+ const item = menu[i];
154
+ if (this.isNavPage(item)) {
155
+ pages.push(item);
156
+ } else {
157
+ switch (item) {
158
+ case 'tags':
159
+ const tags = this.getTags(links, _, translations, subfolder, entries);
160
+ for (let j = 0; j < tags.length; j++) {
161
+ pages.push(tags[j]);
162
+ }
163
+ break;
164
+ case 'toptags':
165
+ const toptags = this.getTopTags(links, _, translations, subfolder, entries);
166
+ for (let j = 0; j < toptags.length; j++) {
167
+ pages.push(toptags[j]);
168
+ }
169
+ break;
170
+ case 'categories':
171
+ const categories = this.getCategories(links, _, translations, subfolder, entries);
172
+ for (let j = 0; j < categories.length; j++) {
173
+ pages.push(categories[j]);
174
+ }
175
+ break;
176
+ }
177
+ }
178
+ }
179
+
180
+ this.setCurrentPage(pages, currentUrl);
181
+
182
+ return pages;
183
+ }
184
+
185
+ /**
186
+ *
187
+ * @param {TaxonomyLinks} links
188
+ * @param {TranslationProvider} _
189
+ * @param {any} translations
190
+ * @param {string} subfolder
191
+ * @param {TaxonomyList} entries
192
+ * @returns {NavPage[]}
193
+ */
194
+ getCategories(links, _, translations, subfolder, entries) {
195
+
196
+ const category = _(translations.articles.category) ?? 'category';
197
+ const categoryTitle = _(translations.articles.category_title) ?? 'Categories';
198
+ const categoryLink = `${subfolder}/${category}/`;
199
+
200
+ let order = 0;
201
+
202
+ /** @type {NavPage[]} */
203
+ const pageHierarchy = [{
204
+ title: categoryTitle,
205
+ url: categoryLink,
206
+ ariaCurrent: false,
207
+ isOpen: false,
208
+ order: 1,
209
+ children: entries.categories.map(item => {
210
+ return {
211
+ title: item.title,
212
+ url: links.getCategoryLink(item.title),
213
+ ariaCurrent: false,
214
+ isOpen: false,
215
+ order: ++order,
216
+ children: []
217
+ };
218
+ })
219
+ }];
220
+
221
+ return pageHierarchy;
222
+ }
223
+
224
+ /**
225
+ *
226
+ * @param {TaxonomyLinks} links
227
+ * @param {TranslationProvider} _
228
+ * @param {any} translations
229
+ * @param {string} subfolder
230
+ * @param {TaxonomyList} entries
231
+ * @returns {NavPage[]}
232
+ */
233
+ getTags(links, _, translations, subfolder, entries) {
234
+
235
+ const tag = _(translations.articles.tag) ?? 'tag';
236
+ const tagTitle = _(translations.articles.tag_title) ?? 'Tags';
237
+ const tagLink = `${subfolder}/${tag}/`;
238
+
239
+ let order = 0;
240
+
241
+ /** @type {NavPage[]} */
242
+ const pageHierarchy = [{
243
+ title: tagTitle,
244
+ url: tagLink,
245
+ ariaCurrent: false,
246
+ isOpen: false,
247
+ order: 1,
248
+ children: entries.tags.map(item => {
249
+ return {
250
+ title: item.title,
251
+ url: links.getTagLink(item.title),
252
+ ariaCurrent: false,
253
+ isOpen: false,
254
+ order: ++order,
255
+ children: []
256
+ };
257
+ })
258
+ }];
259
+
260
+ return pageHierarchy;
261
+ }
262
+
263
+ /**
264
+ *
265
+ * @param {TaxonomyLinks} links
266
+ * @param {TranslationProvider} _
267
+ * @param {any} translations
268
+ * @param {string} subfolder
269
+ * @param {TaxonomyList} entries
270
+ * @returns {NavPage[]}
271
+ */
272
+ getTopTags(links, _, translations, subfolder, entries) {
273
+
274
+ const tag = _(translations.articles.tag) ?? 'tag';
275
+ const tagTitle = _(translations.articles.tag_title) ?? 'Tags';
276
+ const tagLink = `${subfolder}/${tag}/`;
277
+
278
+ let order = 0;
279
+
280
+ /** @type {NavPage[]} */
281
+ const pageHierarchy = [{
282
+ title: tagTitle,
283
+ url: tagLink,
284
+ ariaCurrent: false,
285
+ isOpen: false,
286
+ order: 1,
287
+ children: entries.topTags.map(item => {
288
+ return {
289
+ title: item.title,
290
+ url: links.getTagLink(item.title),
291
+ ariaCurrent: false,
292
+ isOpen: false,
293
+ order: ++order,
294
+ children: []
295
+ };
296
+ })
297
+ }];
298
+
299
+ return pageHierarchy;
300
+ }
301
+
126
302
 
127
303
  /**
128
304
  * Walks a NavPage tree to set current page
129
305
  * @param {NavPage[]} pages
130
306
  * @param {URL} currentUrl
131
307
  */
132
- setCurrentPage (pages, currentUrl) {
308
+ setCurrentPage(pages, currentUrl) {
133
309
  pages.forEach(p => {
134
310
  p.isOpen = currentUrl.pathname.startsWith(p.url);
135
311
  p.ariaCurrent = p.url == currentUrl.pathname
136
312
  ? 'page'
137
313
  : false;
138
-
314
+
139
315
  if (p.children) {
140
316
  this.setCurrentPage(p.children, currentUrl);
141
317
  }
@@ -147,23 +323,23 @@ export class Navigation {
147
323
  * @param {MarkdownInstance} page
148
324
  * @returns {NavPage}
149
325
  */
150
- mapNavPage (page) {
151
- let url = page.url == null || (page.url ?? '').length == 0
326
+ mapNavPage(page) {
327
+ let url = page.url == null || (page.url ?? '').length == 0
152
328
  ? '/'
153
329
  : page.url;
154
-
330
+
155
331
  // Send visitors straight to the first page
156
332
  if (page.frontmatter.paged) {
157
333
  url += '/1/';
158
334
  }
159
-
335
+
160
336
  url = this.urlFormatter.addSlashToAddress(url);
161
-
337
+
162
338
  if (page.frontmatter.layout == 'src/layouts/Redirect.astro') {
163
339
  // Skips past the redirect
164
340
  url = page.frontmatter.redirect;
165
341
  }
166
-
342
+
167
343
  /** @type {NavPage} */
168
344
  const entry = {
169
345
  section: page.frontmatter.navSection ?? page.frontmatter.navTitle ?? page.frontmatter.title,
@@ -175,7 +351,7 @@ export class Navigation {
175
351
  isOpen: false,
176
352
  ariaCurrent: false
177
353
  }
178
-
354
+
179
355
  return entry;
180
356
  }
181
357
 
@@ -185,11 +361,11 @@ export class Navigation {
185
361
  * @param {NavPage | 'auto' | 'tags' | 'toptags' | 'categories'} item
186
362
  * @returns {item is NavPage}
187
363
  */
188
- isNavPage (item) {
364
+ isNavPage(item) {
189
365
  if (typeof item === 'string' && ['auto', 'tags', 'toptags', 'categories'].includes(item)) {
190
366
  return false;
191
367
  }
192
-
368
+
193
369
  return true;
194
370
  }
195
371
 
@@ -199,22 +375,22 @@ export class Navigation {
199
375
  * @param {string} search
200
376
  * @returns
201
377
  */
202
- popMatchingPage (allPages, search) {
378
+ popMatchingPage(allPages, search) {
203
379
  const numberToRemove = 1;
204
380
  let indexToRemove = -1;
205
381
  let match = null;
206
-
382
+
207
383
  for (let i = 0; i < allPages.length; i++) {
208
384
  if (allPages[i].url == search) {
209
385
  indexToRemove = i;
210
386
  match = allPages[i];
211
387
  }
212
388
  }
213
-
389
+
214
390
  if (match) {
215
391
  allPages.splice(indexToRemove, numberToRemove);
216
392
  }
217
-
393
+
218
394
  return match;
219
- }
395
+ }
220
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -1,52 +0,0 @@
1
- /**
2
- * @typedef { import("../types/NavPage").NavPage } NavPage
3
- * @typedef { import("../types/Astro").Site } Site
4
- * @typedef { import("../types/Translations").Entry } Entry
5
- * @typedef { import("../types/Translations").TranslationProvider } TranslationProvider
6
- * @typedef { import("../types/Taxonomy").TaxonomyLinks } TaxonomyLinks
7
- */
8
- /**
9
- *
10
- * @param {URL} currentUrl
11
- * @param {TranslationProvider} _
12
- * @param {any} translations
13
- * @param {Site} site
14
- * @param {(NavPage | 'categories' | 'tags' | 'toptags')[]} menu
15
- * @returns {Promise<NavPage[]>}
16
- */
17
- export function getMenu(currentUrl: URL, _: TranslationProvider, translations: any, site: any, menu: (NavPage | 'categories' | 'tags' | 'toptags')[]): Promise<NavPage[]>;
18
- /**
19
- *
20
- * @param {TaxonomyLinks} links
21
- * @param {TranslationProvider} _
22
- * @param {any} translations
23
- * @param {Site} site
24
- * @param {TaxonomyList} entries
25
- * @returns {Promise<NavPage[]>}
26
- */
27
- export function getCategories(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any, entries: TaxonomyList): Promise<NavPage[]>;
28
- /**
29
- *
30
- * @param {TaxonomyLinks} links
31
- * @param {TranslationProvider} _
32
- * @param {any} translations
33
- * @param {Site} site
34
- * @param {TaxonomyList} entries
35
- * @returns {Promise<NavPage[]>}
36
- */
37
- export function getTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any, entries: TaxonomyList): Promise<NavPage[]>;
38
- /**
39
- *
40
- * @param {TaxonomyLinks} links
41
- * @param {TranslationProvider} _
42
- * @param {any} translations
43
- * @param {Site} site
44
- * @param {TaxonomyList} entries
45
- * @returns {Promise<NavPage[]>}
46
- */
47
- export function getTopTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any, entries: TaxonomyList): Promise<NavPage[]>;
48
- export type NavPage = import("../types/NavPage").NavPage;
49
- export type Site = import("../types/Astro").Site;
50
- export type Entry = import("../types/Translations").Entry;
51
- export type TranslationProvider = import("../types/Translations").TranslationProvider;
52
- export type TaxonomyLinks = import("../types/Taxonomy").TaxonomyLinks;
@@ -1,185 +0,0 @@
1
- import { Cache } from './v1/cache.mjs';
2
- import { Navigation } from './v1/navigation.mjs';
3
- import { Posts } from './v1/posts.mjs';
4
- import { Taxonomy } from './v1/taxonomy.mjs'
5
- import { UrlFormatter } from './v1/urls.mjs';
6
-
7
- /**
8
- * @typedef { import("../types/NavPage").NavPage } NavPage
9
- * @typedef { import("../types/Astro").Site } Site
10
- * @typedef { import("../types/Translations").Entry } Entry
11
- * @typedef { import("../types/Translations").TranslationProvider } TranslationProvider
12
- * @typedef { import("../types/Taxonomy").TaxonomyLinks } TaxonomyLinks
13
- */
14
-
15
- /**
16
- *
17
- * @param {URL} currentUrl
18
- * @param {TranslationProvider} _
19
- * @param {any} translations
20
- * @param {Site} site
21
- * @param {(NavPage | 'categories' | 'tags' | 'toptags')[]} menu
22
- * @returns {Promise<NavPage[]>}
23
- */
24
- export async function getMenu (currentUrl, _, translations, site, menu) {
25
-
26
- const cache = new Cache(site.cacheMaxAge);
27
- const posts = new Posts(cache);
28
- const urlFormatter = new UrlFormatter(site.url);
29
- const taxonomy = new Taxonomy(cache, posts, urlFormatter);
30
- const navigation = new Navigation(posts, urlFormatter);
31
- const links = taxonomy.links(translations, _, site.subfolder);
32
- const entries = taxonomy.getTaxonomy();
33
-
34
- /** @type {NavPage[]} */
35
- let pages = [];
36
-
37
- for (let i = 0; i < menu.length; i++) {
38
- const item = menu[i];
39
- if (navigation.isNavPage(item)) {
40
- pages.push(item);
41
- } else {
42
- switch (item) {
43
- case 'tags':
44
- const tags = await getTags(links, _, translations, site, entries);
45
- for (let j = 0; j < tags.length; j++) {
46
- pages.push(tags[j]);
47
- }
48
- break;
49
- case 'toptags':
50
- const toptags = await getTopTags(links, _, translations, site, entries);
51
- for (let j = 0; j < toptags.length; j++) {
52
- pages.push(toptags[j]);
53
- }
54
- break;
55
- case 'categories':
56
- const categories = await getCategories(links, _, translations, site, entries);
57
- for (let j = 0; j < categories.length; j++) {
58
- pages.push(categories[j]);
59
- }
60
- break;
61
- }
62
- }
63
- }
64
-
65
- navigation.setCurrentPage(pages, currentUrl);
66
-
67
- return pages;
68
- }
69
-
70
- /**
71
- *
72
- * @param {TaxonomyLinks} links
73
- * @param {TranslationProvider} _
74
- * @param {any} translations
75
- * @param {Site} site
76
- * @param {TaxonomyList} entries
77
- * @returns {Promise<NavPage[]>}
78
- */
79
- export async function getCategories (links, _, translations, site, entries) {
80
-
81
- const category = _(translations.articles.category) ?? 'category';
82
- const categoryTitle = _(translations.articles.category_title) ?? 'Categories';
83
- const categoryLink = `${site.subfolder}/${category}/`;
84
-
85
- let order = 0;
86
-
87
- /** @type {NavPage[]} */
88
- const pageHierarchy = [{
89
- title: categoryTitle,
90
- url: categoryLink,
91
- ariaCurrent: false,
92
- isOpen: false,
93
- order: 1,
94
- children: entries.categories.map(item => {
95
- return {
96
- title: item.title,
97
- url: links.getCategoryLink(item.title),
98
- ariaCurrent: false,
99
- isOpen: false,
100
- order: ++order,
101
- children: []
102
- };
103
- })
104
- }];
105
-
106
- return pageHierarchy;
107
- }
108
-
109
- /**
110
- *
111
- * @param {TaxonomyLinks} links
112
- * @param {TranslationProvider} _
113
- * @param {any} translations
114
- * @param {Site} site
115
- * @param {TaxonomyList} entries
116
- * @returns {Promise<NavPage[]>}
117
- */
118
- export async function getTags (links, _, translations, site, entries) {
119
-
120
- const tag = _(translations.articles.tag) ?? 'tag';
121
- const tagTitle = _(translations.articles.tag_title) ?? 'Tags';
122
- const tagLink = `${site.subfolder}/${tag}/`;
123
-
124
- let order = 0;
125
-
126
- /** @type {NavPage[]} */
127
- const pageHierarchy = [{
128
- title: tagTitle,
129
- url: tagLink,
130
- ariaCurrent: false,
131
- isOpen: false,
132
- order: 1,
133
- children: entries.tags.map(item => {
134
- return {
135
- title: item.title,
136
- url: links.getTagLink(item.title),
137
- ariaCurrent: false,
138
- isOpen: false,
139
- order: ++order,
140
- children: []
141
- };
142
- })
143
- }];
144
-
145
- return pageHierarchy;
146
- }
147
-
148
- /**
149
- *
150
- * @param {TaxonomyLinks} links
151
- * @param {TranslationProvider} _
152
- * @param {any} translations
153
- * @param {Site} site
154
- * @param {TaxonomyList} entries
155
- * @returns {Promise<NavPage[]>}
156
- */
157
- export async function getTopTags (links, _, translations, site, entries) {
158
-
159
- const tag = _(translations.articles.tag) ?? 'tag';
160
- const tagTitle = _(translations.articles.tag_title) ?? 'Tags';
161
- const tagLink = `${site.subfolder}/${tag}/`;
162
-
163
- let order = 0;
164
-
165
- /** @type {NavPage[]} */
166
- const pageHierarchy = [{
167
- title: tagTitle,
168
- url: tagLink,
169
- ariaCurrent: false,
170
- isOpen: false,
171
- order: 1,
172
- children: entries.topTags.map(item => {
173
- return {
174
- title: item.title,
175
- url: links.getTagLink(item.title),
176
- ariaCurrent: false,
177
- isOpen: false,
178
- order: ++order,
179
- children: []
180
- };
181
- })
182
- }];
183
-
184
- return pageHierarchy;
185
- }
@@ -1,6 +0,0 @@
1
- export interface Entry {
2
- [key: string]: string;
3
- }
4
- export interface TranslationProvider {
5
- (entry: Entry): string;
6
- }