22import { getChangelogs , type GetChangelogsOptions } from " ~/util/changelog" ;
33import { reference } from " astro:content" ;
44import { z } from " astro:schema" ;
5- import { getCollection } from " astro:content" ;
5+ import { getCollection , render } from " astro:content" ;
6+ import { slug } from " github-slugger" ;
7+ import { LinkButton } from " @astrojs/starlight/components" ;
68
7- const props = z .object ({
8- products: z .array (reference (" products" )),
9- }).or (z .object ({
10- area: z .string ()
11- }));
9+ const props = z
10+ .object ({
11+ product: reference (" products" ),
12+ })
13+ .or (
14+ z .object ({
15+ area: z .string (),
16+ }),
17+ );
1218
1319const input = await props .parseAsync (Astro .props );
1420
1521let filter: GetChangelogsOptions [" filter" ];
22+ let rss: string ;
23+
24+ if (" product" in input ) {
25+ rss = ` /changelog/rss/${input .product }.xml ` ;
1626
17- if (" products" in input ) {
1827 filter = (e ) => {
19- return e .data .products .some ((x ) => input . products . some (( y ) => x . id === y . id ))
20- }
28+ return e .data .products .some (({ id } ) => id === input . product . id );
29+ };
2130} else {
31+ rss = ` /changelog/rss/${slug (input .area )}.xml ` ;
32+
2233 const products = await getCollection (" products" , (e ) => {
2334 return e .data .product .group === input .area ;
2435 });
2536
2637 filter = (e ) => {
27- return e .data .products .some ((x ) => products .some ((y ) => x .id === y .id ))
28- }
38+ return e .data .products .some ((x ) => products .some ((y ) => x .id === y .id ));
39+ };
2940}
3041
3142const changelogs = await getChangelogs ({ filter });
3243---
3344
45+ <LinkButton href ={ rss } target =" _blank" >Subscribe to RSS</LinkButton >
46+
3447{
35- changelogs .map ((entry ) => (
36- <h3 >{ entry .data .date .toISOString ().slice (0 , 10 )} </h3 >
37- <h4 >{ entry .data .description } </h4 >
38- <p >For more information, refer to the <a href = { ` /changelog/${entry .id } ` } >dedicated changelog post</a >.</p >
39- ))
40- }
48+ changelogs .map (async (entry ) => {
49+ const { Content } = await render (entry );
50+ return <Content />;
51+ })
52+ }
0 commit comments