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