@karaoke-cms/module-tags 0.16.0 → 0.18.0
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/README.md +4 -0
- package/package.json +5 -5
- package/src/pages/index.astro +5 -6
- package/src/pages/tag-rss.ts +6 -10
- package/src/pages/tag.astro +6 -10
package/README.md
CHANGED
|
@@ -52,6 +52,10 @@ tags: [javascript, tutorial]
|
|
|
52
52
|
|
|
53
53
|
No additional frontmatter fields are added by this module.
|
|
54
54
|
|
|
55
|
+
## What's new in 0.18.0
|
|
56
|
+
|
|
57
|
+
- **Dynamic content source indexing** — the tags module now discovers and indexes all enabled content sources (blog and every active docs section) automatically, instead of querying a hardcoded blog collection. Adding or removing modules updates the tag index without any config changes.
|
|
58
|
+
|
|
55
59
|
## What's new in 0.13.1
|
|
56
60
|
|
|
57
61
|
No user-facing changes in this release.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karaoke-cms/module-tags",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"description": "Tags module for karaoke-cms — cross-collection tag index with per-tag RSS feeds",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"exports": {
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"astro": ">=6.0.0",
|
|
28
|
-
"@karaoke-cms/contracts": "^0.
|
|
29
|
-
"@karaoke-cms/astro": "^0.
|
|
28
|
+
"@karaoke-cms/contracts": "^0.18.0",
|
|
29
|
+
"@karaoke-cms/astro": "^0.18.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"astro": "^6.0.8",
|
|
33
33
|
"vitest": "^4.1.1",
|
|
34
|
-
"@karaoke-cms/
|
|
35
|
-
"@karaoke-cms/
|
|
34
|
+
"@karaoke-cms/contracts": "0.18.0",
|
|
35
|
+
"@karaoke-cms/astro": "0.18.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"test": "vitest run test/module-tags.test.js"
|
package/src/pages/index.astro
CHANGED
|
@@ -3,14 +3,13 @@ import { getCollection } from 'astro:content';
|
|
|
3
3
|
import DefaultPage from '@karaoke-cms/astro/layouts/DefaultPage.astro';
|
|
4
4
|
import { siteTitle } from 'virtual:karaoke-cms/config';
|
|
5
5
|
import { tagsMount } from 'virtual:karaoke-cms/tags-config';
|
|
6
|
-
import {
|
|
6
|
+
import { contentSources } from 'virtual:karaoke-cms/content-sources';
|
|
7
7
|
import { slugifyTag } from '../utils.js';
|
|
8
8
|
|
|
9
|
-
// Auto-discover:
|
|
10
|
-
const settled = await Promise.allSettled(
|
|
11
|
-
getCollection(
|
|
12
|
-
|
|
13
|
-
]);
|
|
9
|
+
// Auto-discover: all enabled content collections
|
|
10
|
+
const settled = await Promise.allSettled(
|
|
11
|
+
contentSources.map(s => getCollection(s.collection as any, ({ data }) => data.publish === true)),
|
|
12
|
+
);
|
|
14
13
|
const allEntries = settled.flatMap(r => r.status === 'fulfilled' ? r.value : []);
|
|
15
14
|
|
|
16
15
|
// Count occurrences of each tag across all collections
|
package/src/pages/tag-rss.ts
CHANGED
|
@@ -10,23 +10,19 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import rss from '@astrojs/rss';
|
|
12
12
|
import { getCollection } from 'astro:content';
|
|
13
|
-
import { siteTitle, siteDescription
|
|
14
|
-
import {
|
|
13
|
+
import { siteTitle, siteDescription } from 'virtual:karaoke-cms/config';
|
|
14
|
+
import { contentSources } from 'virtual:karaoke-cms/content-sources';
|
|
15
15
|
import { slugifyTag, slugToTag } from '../utils.js';
|
|
16
16
|
import type { APIRoute, GetStaticPaths } from 'astro';
|
|
17
17
|
|
|
18
18
|
async function getAllEntries() {
|
|
19
|
-
const settled = await Promise.allSettled(
|
|
20
|
-
getCollection(
|
|
21
|
-
|
|
22
|
-
]);
|
|
19
|
+
const settled = await Promise.allSettled(
|
|
20
|
+
contentSources.map(s => getCollection(s.collection as any, (e) => e.data.publish === true)),
|
|
21
|
+
);
|
|
23
22
|
return settled.flatMap(r => r.status === 'fulfilled' ? r.value : []);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const mountByCollection
|
|
27
|
-
blog: blogMount,
|
|
28
|
-
...Object.fromEntries(docsSections.map((s) => [s.collection, s.mount])),
|
|
29
|
-
};
|
|
25
|
+
const mountByCollection = Object.fromEntries(contentSources.map(s => [s.collection, s.mount]));
|
|
30
26
|
|
|
31
27
|
function entryHref(entry: { collection: string; id: string }) {
|
|
32
28
|
const mount = mountByCollection[entry.collection];
|
package/src/pages/tag.astro
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection } from 'astro:content';
|
|
3
3
|
import DefaultPage from '@karaoke-cms/astro/layouts/DefaultPage.astro';
|
|
4
|
-
import { siteTitle
|
|
4
|
+
import { siteTitle } from 'virtual:karaoke-cms/config';
|
|
5
5
|
import { tagsMount } from 'virtual:karaoke-cms/tags-config';
|
|
6
|
-
import {
|
|
6
|
+
import { contentSources } from 'virtual:karaoke-cms/content-sources';
|
|
7
7
|
import { slugifyTag, slugToTag } from '../utils.js';
|
|
8
8
|
|
|
9
9
|
export async function getStaticPaths() {
|
|
10
|
-
const settled = await Promise.allSettled(
|
|
11
|
-
getCollection(
|
|
12
|
-
|
|
13
|
-
]);
|
|
10
|
+
const settled = await Promise.allSettled(
|
|
11
|
+
contentSources.map(s => getCollection(s.collection as any, ({ data }) => data.publish === true)),
|
|
12
|
+
);
|
|
14
13
|
const allEntries = settled.flatMap(r => r.status === 'fulfilled' ? r.value : []);
|
|
15
14
|
|
|
16
15
|
const tags = new Set<string>();
|
|
@@ -33,10 +32,7 @@ const { tag } = Astro.params;
|
|
|
33
32
|
const { originalTag, entries } = Astro.props;
|
|
34
33
|
|
|
35
34
|
// Map collection name → mount path for correct href generation
|
|
36
|
-
const mountByCollection
|
|
37
|
-
blog: blogMount,
|
|
38
|
-
...Object.fromEntries(docsSections.map(s => [s.collection, s.mount])),
|
|
39
|
-
};
|
|
35
|
+
const mountByCollection = Object.fromEntries(contentSources.map(s => [s.collection, s.mount]));
|
|
40
36
|
|
|
41
37
|
function href(entry: { collection: string; id: string }) {
|
|
42
38
|
const mount = mountByCollection[entry.collection];
|