astro-accelerator-utils 0.1.19 → 0.1.21
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/lib/footerMenu.d.mts +6 -3
- package/lib/footerMenu.mjs +16 -18
- package/package.json +1 -1
package/lib/footerMenu.d.mts
CHANGED
|
@@ -21,27 +21,30 @@ export function getMenu(currentUrl: URL, _: TranslationProvider, translations: a
|
|
|
21
21
|
* @param {TranslationProvider} _
|
|
22
22
|
* @param {any} translations
|
|
23
23
|
* @param {Site} site
|
|
24
|
+
* @param {TaxonomyList} entries
|
|
24
25
|
* @returns {Promise<NavPage[]>}
|
|
25
26
|
*/
|
|
26
|
-
export function getCategories(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any): Promise<NavPage[]>;
|
|
27
|
+
export function getCategories(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any, entries: TaxonomyList): Promise<NavPage[]>;
|
|
27
28
|
/**
|
|
28
29
|
*
|
|
29
30
|
* @param {TaxonomyLinks} links
|
|
30
31
|
* @param {TranslationProvider} _
|
|
31
32
|
* @param {any} translations
|
|
32
33
|
* @param {Site} site
|
|
34
|
+
* @param {TaxonomyList} entries
|
|
33
35
|
* @returns {Promise<NavPage[]>}
|
|
34
36
|
*/
|
|
35
|
-
export function getTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any): Promise<NavPage[]>;
|
|
37
|
+
export function getTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any, entries: TaxonomyList): Promise<NavPage[]>;
|
|
36
38
|
/**
|
|
37
39
|
*
|
|
38
40
|
* @param {TaxonomyLinks} links
|
|
39
41
|
* @param {TranslationProvider} _
|
|
40
42
|
* @param {any} translations
|
|
41
43
|
* @param {Site} site
|
|
44
|
+
* @param {TaxonomyList} entries
|
|
42
45
|
* @returns {Promise<NavPage[]>}
|
|
43
46
|
*/
|
|
44
|
-
export function getTopTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any): Promise<NavPage[]>;
|
|
47
|
+
export function getTopTags(links: TaxonomyLinks, _: TranslationProvider, translations: any, site: any, entries: TaxonomyList): Promise<NavPage[]>;
|
|
45
48
|
export type NavPage = import("../types/NavPage").NavPage;
|
|
46
49
|
export type Site = import("../types/Astro").Site;
|
|
47
50
|
export type Entry = import("../types/Translations").Entry;
|
package/lib/footerMenu.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Cache } from './v1/cache.mjs';
|
|
2
2
|
import { Navigation } from './v1/navigation.mjs';
|
|
3
3
|
import { Posts } from './v1/posts.mjs';
|
|
4
|
+
import { Taxonomy } from './v1/taxonomy.mjs'
|
|
4
5
|
import { UrlFormatter } from './v1/urls.mjs';
|
|
5
6
|
|
|
6
|
-
import * as Taxonomy from './taxonomy.mjs';
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* @typedef { import("../types/NavPage").NavPage } NavPage
|
|
10
9
|
* @typedef { import("../types/Astro").Site } Site
|
|
@@ -27,8 +26,10 @@ export async function getMenu (currentUrl, _, translations, site, menu) {
|
|
|
27
26
|
const cache = new Cache(site.cacheMaxAge);
|
|
28
27
|
const posts = new Posts(cache);
|
|
29
28
|
const urlFormatter = new UrlFormatter(site.url);
|
|
29
|
+
const taxonomy = new Taxonomy(cache, posts, urlFormatter);
|
|
30
30
|
const navigation = new Navigation(posts, urlFormatter);
|
|
31
|
-
const links =
|
|
31
|
+
const links = taxonomy.links(translations, _, site.subfolder);
|
|
32
|
+
const entries = taxonomy.getTaxonomy();
|
|
32
33
|
|
|
33
34
|
/** @type {NavPage[]} */
|
|
34
35
|
let pages = [];
|
|
@@ -40,19 +41,19 @@ export async function getMenu (currentUrl, _, translations, site, menu) {
|
|
|
40
41
|
} else {
|
|
41
42
|
switch (item) {
|
|
42
43
|
case 'tags':
|
|
43
|
-
const tags = await getTags(links, _, translations, site);
|
|
44
|
+
const tags = await getTags(links, _, translations, site, entries);
|
|
44
45
|
for (let j = 0; j < tags.length; j++) {
|
|
45
46
|
pages.push(tags[j]);
|
|
46
47
|
}
|
|
47
48
|
break;
|
|
48
49
|
case 'toptags':
|
|
49
|
-
const toptags = await getTopTags(links, _, translations, site);
|
|
50
|
+
const toptags = await getTopTags(links, _, translations, site, entries);
|
|
50
51
|
for (let j = 0; j < toptags.length; j++) {
|
|
51
52
|
pages.push(toptags[j]);
|
|
52
53
|
}
|
|
53
54
|
break;
|
|
54
55
|
case 'categories':
|
|
55
|
-
const categories = await getCategories(links, _, translations, site);
|
|
56
|
+
const categories = await getCategories(links, _, translations, site, entries);
|
|
56
57
|
for (let j = 0; j < categories.length; j++) {
|
|
57
58
|
pages.push(categories[j]);
|
|
58
59
|
}
|
|
@@ -72,9 +73,10 @@ export async function getMenu (currentUrl, _, translations, site, menu) {
|
|
|
72
73
|
* @param {TranslationProvider} _
|
|
73
74
|
* @param {any} translations
|
|
74
75
|
* @param {Site} site
|
|
76
|
+
* @param {TaxonomyList} entries
|
|
75
77
|
* @returns {Promise<NavPage[]>}
|
|
76
78
|
*/
|
|
77
|
-
export async function getCategories (links, _, translations, site) {
|
|
79
|
+
export async function getCategories (links, _, translations, site, entries) {
|
|
78
80
|
|
|
79
81
|
const category = _(translations.articles.category) ?? 'category';
|
|
80
82
|
const categoryTitle = _(translations.articles.category_title) ?? 'Categories';
|
|
@@ -82,8 +84,6 @@ export async function getCategories (links, _, translations, site) {
|
|
|
82
84
|
|
|
83
85
|
let order = 0;
|
|
84
86
|
|
|
85
|
-
const taxonomy = await Taxonomy.getTaxonomy();
|
|
86
|
-
|
|
87
87
|
/** @type {NavPage[]} */
|
|
88
88
|
const pageHierarchy = [{
|
|
89
89
|
title: categoryTitle,
|
|
@@ -91,7 +91,7 @@ export async function getCategories (links, _, translations, site) {
|
|
|
91
91
|
ariaCurrent: false,
|
|
92
92
|
isOpen: false,
|
|
93
93
|
order: 1,
|
|
94
|
-
children:
|
|
94
|
+
children: entries.categories.map(item => {
|
|
95
95
|
return {
|
|
96
96
|
title: item.title,
|
|
97
97
|
url: links.getCategoryLink(item.title),
|
|
@@ -112,9 +112,10 @@ export async function getCategories (links, _, translations, site) {
|
|
|
112
112
|
* @param {TranslationProvider} _
|
|
113
113
|
* @param {any} translations
|
|
114
114
|
* @param {Site} site
|
|
115
|
+
* @param {TaxonomyList} entries
|
|
115
116
|
* @returns {Promise<NavPage[]>}
|
|
116
117
|
*/
|
|
117
|
-
export async function getTags (links, _, translations, site) {
|
|
118
|
+
export async function getTags (links, _, translations, site, entries) {
|
|
118
119
|
|
|
119
120
|
const tag = _(translations.articles.tag) ?? 'tag';
|
|
120
121
|
const tagTitle = _(translations.articles.tag_title) ?? 'Tags';
|
|
@@ -122,8 +123,6 @@ export async function getTags (links, _, translations, site) {
|
|
|
122
123
|
|
|
123
124
|
let order = 0;
|
|
124
125
|
|
|
125
|
-
const taxonomy = await Taxonomy.getTaxonomy();
|
|
126
|
-
|
|
127
126
|
/** @type {NavPage[]} */
|
|
128
127
|
const pageHierarchy = [{
|
|
129
128
|
title: tagTitle,
|
|
@@ -131,7 +130,7 @@ export async function getTags (links, _, translations, site) {
|
|
|
131
130
|
ariaCurrent: false,
|
|
132
131
|
isOpen: false,
|
|
133
132
|
order: 1,
|
|
134
|
-
children:
|
|
133
|
+
children: entries.tags.map(item => {
|
|
135
134
|
return {
|
|
136
135
|
title: item.title,
|
|
137
136
|
url: links.getTagLink(item.title),
|
|
@@ -152,9 +151,10 @@ export async function getTags (links, _, translations, site) {
|
|
|
152
151
|
* @param {TranslationProvider} _
|
|
153
152
|
* @param {any} translations
|
|
154
153
|
* @param {Site} site
|
|
154
|
+
* @param {TaxonomyList} entries
|
|
155
155
|
* @returns {Promise<NavPage[]>}
|
|
156
156
|
*/
|
|
157
|
-
export async function getTopTags (links, _, translations, site) {
|
|
157
|
+
export async function getTopTags (links, _, translations, site, entries) {
|
|
158
158
|
|
|
159
159
|
const tag = _(translations.articles.tag) ?? 'tag';
|
|
160
160
|
const tagTitle = _(translations.articles.tag_title) ?? 'Tags';
|
|
@@ -162,8 +162,6 @@ export async function getTopTags (links, _, translations, site) {
|
|
|
162
162
|
|
|
163
163
|
let order = 0;
|
|
164
164
|
|
|
165
|
-
const taxonomy = await Taxonomy.getTaxonomy();
|
|
166
|
-
|
|
167
165
|
/** @type {NavPage[]} */
|
|
168
166
|
const pageHierarchy = [{
|
|
169
167
|
title: tagTitle,
|
|
@@ -171,7 +169,7 @@ export async function getTopTags (links, _, translations, site) {
|
|
|
171
169
|
ariaCurrent: false,
|
|
172
170
|
isOpen: false,
|
|
173
171
|
order: 1,
|
|
174
|
-
children:
|
|
172
|
+
children: entries.topTags.map(item => {
|
|
175
173
|
return {
|
|
176
174
|
title: item.title,
|
|
177
175
|
url: links.getTagLink(item.title),
|