@eventcatalog/core 2.20.2 → 2.21.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.
@@ -6,9 +6,10 @@ import type { CollectionMessageTypes } from '@types';
6
6
  import * as path from 'path';
7
7
  import VersionList from '@components/Lists/VersionList.astro';
8
8
  import { buildUrl } from '@utils/url-builder';
9
- import { FileDownIcon, ScrollText, Workflow } from 'lucide-react';
9
+ import { FileDownIcon, ScrollText, Workflow, RssIcon } from 'lucide-react';
10
10
  import RepositoryList from '@components/Lists/RepositoryList.astro';
11
11
  import { getOwner } from '@utils/collections/owners';
12
+ import config from '@config';
12
13
 
13
14
  interface Props {
14
15
  message: CollectionEntry<CollectionMessageTypes>;
@@ -86,6 +87,8 @@ const getConsumerEmptyMessage = (type: string) => {
86
87
 
87
88
  const type = getType(message.collection);
88
89
 
90
+ const isRSSEnabled = config.rss?.enabled;
91
+
89
92
  // @ts-ignore
90
93
  const publicPath = message?.catalog?.publicPath;
91
94
  const schemaFilePath = message?.data?.schemaPath;
@@ -145,6 +148,22 @@ const schemaURL = path.join(publicPath, schemaFilePath || '');
145
148
  )
146
149
  }
147
150
 
151
+ {
152
+ isRSSEnabled && (
153
+ <div class="mx-auto pb-8 w-full max-w-lg divide-y divide-white/5 rounded-xl bg-white/5">
154
+ <span class="text-sm text-black group-data-[hover]:text-black/80 capitalize">{type} RSS Feed</span>
155
+ <ul role="list" class="space-y-2 mt-2">
156
+ <li class="has-tooltip rounded-md text-gray-600 group px-1 w-full hover:bg-gradient-to-l hover:from-purple-500 hover:to-purple-700 hover:text-white hover:font-normal ">
157
+ <a class={`flex items-center space-x-2`} target="_blank" href={buildUrl(`/rss/${message.collection}/rss.xml`)}>
158
+ <RssIcon className="h-4 w-4 text-gray-800 group-hover:text-white" strokeWidth={1} />
159
+ <span class="font-light text-sm truncate">RSS Feed</span>
160
+ </a>
161
+ </li>
162
+ </ul>
163
+ </div>
164
+ )
165
+ }
166
+
148
167
  <div class="space-y-2">
149
168
  {
150
169
  message?.data?.schemaPath && (
@@ -7,8 +7,9 @@ import VersionList from '@components/Lists/VersionList.astro';
7
7
  import { buildUrl } from '@utils/url-builder';
8
8
  import { getOwner } from '@utils/collections/owners';
9
9
  import type { CollectionEntry } from 'astro:content';
10
- import { ScrollText, Workflow, FileDownIcon, Code, Link } from 'lucide-react';
10
+ import { ScrollText, Workflow, FileDownIcon, Code, Link, RssIcon } from 'lucide-react';
11
11
  import { join } from 'node:path';
12
+ import config from '@config';
12
13
 
13
14
  interface Props {
14
15
  service: CollectionEntry<'services'>;
@@ -50,6 +51,8 @@ const ownersList = filteredOwners.map((o) => ({
50
51
  href: buildUrl(`/docs/${o.collection}/${o.data.id}`),
51
52
  }));
52
53
 
54
+ const isRSSEnabled = config.rss?.enabled;
55
+
53
56
  // @ts-ignore
54
57
  const publicPath = service?.catalog?.publicPath;
55
58
  const schemaFilePath = service?.data?.schemaPath;
@@ -89,6 +92,22 @@ const schemaURL = join(publicPath, schemaFilePath || '');
89
92
  )
90
93
  }
91
94
 
95
+ {
96
+ isRSSEnabled && (
97
+ <div class="mx-auto pb-8 w-full max-w-lg divide-y divide-white/5 rounded-xl bg-white/5">
98
+ <span class="text-sm text-black group-data-[hover]:text-black/80 capitalize">Services RSS Feed</span>
99
+ <ul role="list" class="space-y-2 mt-2">
100
+ <li class="has-tooltip rounded-md text-gray-600 group px-1 w-full hover:bg-gradient-to-l hover:from-purple-500 hover:to-purple-700 hover:text-white hover:font-normal ">
101
+ <a class={`flex items-center space-x-2`} target="_blank" href={buildUrl(`/rss/services/rss.xml`)}>
102
+ <RssIcon className="h-4 w-4 text-gray-800 group-hover:text-white" strokeWidth={1} />
103
+ <span class="font-light text-sm truncate">RSS</span>
104
+ </a>
105
+ </li>
106
+ </ul>
107
+ </div>
108
+ )
109
+ }
110
+
92
111
  <div class="space-y-2">
93
112
  {
94
113
  service?.data?.schemaPath && (
@@ -0,0 +1,79 @@
1
+ import rss from '@astrojs/rss';
2
+ import { getCollection } from 'astro:content';
3
+ import { statSync } from 'fs';
4
+ import { buildUrl } from '@utils/url-builder';
5
+ import config from '@config';
6
+
7
+ const isRSSEnabled = config.rss?.enabled;
8
+ const rssLimit = config.rss?.limit || 15;
9
+
10
+ const collections = ['events', 'services', 'domains', 'commands', 'flows', 'all'];
11
+
12
+ export function getStaticPaths() {
13
+ return collections.map((collection) => ({
14
+ params: { resource: collection },
15
+ }));
16
+ }
17
+
18
+ export async function GET(context) {
19
+ if (!isRSSEnabled) {
20
+ return new Response('RSS is not enabled for this EventCatalog.', { status: 404 });
21
+ }
22
+
23
+ const collection = context.params.resource;
24
+ let items = [];
25
+
26
+ if (collection === 'all') {
27
+ const events = await getCollection('events');
28
+ const services = await getCollection('services');
29
+ const domains = await getCollection('domains');
30
+ const commands = await getCollection('commands');
31
+ const flows = await getCollection('flows');
32
+ items = [...events, ...services, ...domains, ...commands, ...flows];
33
+ } else {
34
+ items = await getCollection(collection);
35
+ }
36
+
37
+ // console.log(events);
38
+
39
+ const rssItems = items
40
+ .map((event) => {
41
+ const pathToFile = event.data.pathToFile;
42
+
43
+ // Get file stats to access modified date
44
+ const stats = statSync(pathToFile);
45
+ return {
46
+ ...event,
47
+ modifiedDate: stats.mtime,
48
+ };
49
+ })
50
+ .sort((a, b) => b.modifiedDate - a.modifiedDate) // Sort in descending order (newest first)
51
+ .slice(0, rssLimit); // Only take the first 10 items
52
+
53
+ return rss({
54
+ // `<title>` field in output xml
55
+ title:
56
+ collection === 'all'
57
+ ? 'Documented resources in EventCatalog'
58
+ : `${collection.charAt(0).toUpperCase() + collection.slice(1)}`,
59
+ stylesheet: '/rss.xsl',
60
+ // `<description>` field in output xml
61
+ description: collection === 'all' ? 'Documented resources in EventCatalog' : `Documented ${collection} in EventCatalog`,
62
+ // Pull in your project "site" from the endpoint context
63
+ // https://docs.astro.build/en/reference/api-reference/#site
64
+ site: context.site,
65
+ // Array of `<item>`s in output xml
66
+ // See "Generating items" section for examples using content collections and glob imports
67
+ items: rssItems.map((event) => ({
68
+ title: event.data.name,
69
+ link: buildUrl(`/docs/${collection}/${event.data.id}/${event.data.version}`),
70
+ pubDate: event.modifiedDate,
71
+ description: event.data.summary,
72
+ // Optional: Include modified date in the RSS feed
73
+ lastBuildDate: items.find((item) => item.id === event.id)?.modifiedDate,
74
+ // categories: event.data.badges,
75
+ })),
76
+ // (optional) inject custom xml
77
+ customData: `<language>en-us</language>`,
78
+ });
79
+ }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.20.2",
9
+ "version": "2.21.0",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -21,10 +21,11 @@
21
21
  "default-files-for-collections/"
22
22
  ],
23
23
  "dependencies": {
24
- "@astrojs/markdown-remark": "^6.0.1",
25
- "@astrojs/mdx": "^4.0.5",
26
- "@astrojs/react": "^4.1.3",
27
- "@astrojs/tailwind": "^5.1.4",
24
+ "@astrojs/markdown-remark": "^6.1.0",
25
+ "@astrojs/mdx": "^4.0.8",
26
+ "@astrojs/react": "^4.2.0",
27
+ "@astrojs/rss": "^4.0.11",
28
+ "@astrojs/tailwind": "^6.0.0",
28
29
  "@asyncapi/avro-schema-parser": "^3.0.24",
29
30
  "@asyncapi/parser": "^3.4.0",
30
31
  "@asyncapi/react-component": "^2.4.3",
@@ -36,7 +37,7 @@
36
37
  "@tailwindcss/typography": "^0.5.13",
37
38
  "@tanstack/react-table": "^8.17.3",
38
39
  "@xyflow/react": "^12.3.6",
39
- "astro": "^5.1.5",
40
+ "astro": "^5.2.5",
40
41
  "astro-expressive-code": "^0.40.1",
41
42
  "astro-pagefind": "^1.6.0",
42
43
  "astro-seo": "^0.8.4",