From e20054e5ecbb68161068cb293f8e5776c26d35b6 Mon Sep 17 00:00:00 2001 From: carlosallexandre Date: Tue, 18 Feb 2025 17:55:27 -0300 Subject: [PATCH] fix(core): remove empty index page to prevent blank docs page This removes the empty markdown file that were previously added by `ensureAstroCollectionNotEmpty` when no index page was specified by the user. This introduce `default-docs.mdx` as fallback to prevent blank /docs page. This approach ensures a better UX without redirecting to the first collection item, as an initial empty project may not have any items to navigate to. Closes #1130. --- default-files-for-collections/pages.md | 7 - .../src/components/DocsNavigation.astro | 145 ------------------ .../src/layouts/CustomDocsPageLayout.astro | 131 ---------------- eventcatalog/src/layouts/PlainPage.astro | 29 ---- .../[type]/[id]/[version]/spec/index.astro | 1 - eventcatalog/src/pages/docs/_default-docs.mdx | 24 +++ eventcatalog/src/pages/docs/index.astro | 31 ++-- src/catalog-to-astro-content-directory.js | 1 - 8 files changed, 37 insertions(+), 332 deletions(-) delete mode 100644 default-files-for-collections/pages.md delete mode 100644 eventcatalog/src/components/DocsNavigation.astro delete mode 100644 eventcatalog/src/layouts/CustomDocsPageLayout.astro delete mode 100644 eventcatalog/src/layouts/PlainPage.astro create mode 100644 eventcatalog/src/pages/docs/_default-docs.mdx diff --git a/default-files-for-collections/pages.md b/default-files-for-collections/pages.md deleted file mode 100644 index 9eff3ed0..00000000 --- a/default-files-for-collections/pages.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -id: index -slug: index -hidden: true ---- - - \ No newline at end of file diff --git a/eventcatalog/src/components/DocsNavigation.astro b/eventcatalog/src/components/DocsNavigation.astro deleted file mode 100644 index b72062d3..00000000 --- a/eventcatalog/src/components/DocsNavigation.astro +++ /dev/null @@ -1,145 +0,0 @@ ---- -import { getCommands } from '@utils/commands'; -import { getDomains } from '@utils/collections/domains'; -import { getEvents } from '@utils/events'; -import { getServices } from '@utils/collections/services'; -import { getFlows } from '@utils/collections/flows'; -import { getTeams } from '@utils/teams'; -import { getUsers } from '@utils/users'; -import config, { type CatalogConfig } from '@utils/eventcatalog-config/catalog'; -import { buildUrl } from '@utils/url-builder'; -import { getQueries } from '@utils/queries'; - -const events = await getEvents({ getAllVersions: false }); -const commands = await getCommands({ getAllVersions: false }); -const queries = await getQueries({ getAllVersions: false }); -const services = await getServices({ getAllVersions: false }); -const domains = await getDomains({ getAllVersions: false }); -const flows = await getFlows({ getAllVersions: false }); -const teams = await getTeams(); -const users = await getUsers(); - -const messages = [...events, ...commands, ...queries]; - -// @ts-ignore for large catalogs https://github.com/event-catalog/eventcatalog/issues/552 -const allData = [...domains, ...services, ...messages, ...flows, ...teams, ...users]; - -const eventCatalogConfig = config as CatalogConfig; -const { - services: servicesConfig, - domains: domainsConfig, - messages: messagesConfig, - flows: flowsConfig, - teams: teamsConfig, - users: usersConfig, - showPageHeadings = true, -} = eventCatalogConfig?.docs?.sidebar || {}; - -const getConfigValue = (obj: any, key: string, defaultValue: any) => { - return obj?.[key] ?? defaultValue; -}; - -const visibleCollections: { [key: string]: boolean } = { - events: getConfigValue(messagesConfig, 'visible', true), - commands: getConfigValue(messagesConfig, 'visible', true), - domains: getConfigValue(domainsConfig, 'visible', true), - flows: getConfigValue(flowsConfig, 'visible', true), - services: getConfigValue(servicesConfig, 'visible', true), - teams: getConfigValue(teamsConfig, 'visible', true), - users: getConfigValue(usersConfig, 'visible', true), -}; - -const fetchHeadings = allData.map(async (item) => { - const renderHeadings = showPageHeadings; - const headings = renderHeadings ? await item.render() : { headings: [] }; - return { - ...item, - headings: headings.headings, - }; -}); - -const withHeadings = await Promise.all(fetchHeadings); - -const sideNav = withHeadings.reduce((acc, item) => { - const title = item.collection === 'events' || item.collection === 'commands' ? 'Messages' : item.collection; - - const group = acc[title] || []; - - const navigationItem = { - label: item.data.name, - version: item.collection === 'teams' || item.collection === 'users' ? null : item.data.version, - items: item.collection === 'users' ? [] : item.headings, - visible: visibleCollections[item.collection], - // @ts-ignore - href: item.data.version - ? // @ts-ignore - buildUrl(`/docs/${item.collection}/${item.data.id}/${item.data.version}`) - : buildUrl(`/docs/${item.collection}/${item.data.id}`), - }; - - group.push(navigationItem); - - return { - ...acc, - [title]: group, - }; -}, {} as any); - -const currentPath = Astro.url.pathname; ---- - -
- { - Object.keys(sideNav).map((key) => { - const collection = sideNav[key]; - if (collection[0] && collection[0].visible === false) return null; - return ( - - ); - }) - } -
- - diff --git a/eventcatalog/src/layouts/CustomDocsPageLayout.astro b/eventcatalog/src/layouts/CustomDocsPageLayout.astro deleted file mode 100644 index 64e9c05b..00000000 --- a/eventcatalog/src/layouts/CustomDocsPageLayout.astro +++ /dev/null @@ -1,131 +0,0 @@ ---- -interface Props { - title: string; -} - -import Footer from '@layouts/Footer.astro'; -import Header from '@components/Header.astro'; -import SideBar from '@components/DocsNavigation.astro'; -import { buildUrl } from '@utils/url-builder'; ---- - - - - - - - - - - EventCatalog - - -
-
- -
- - -
-
-
-
-
-

EventCatalog

-
-
-

- Welcome to EventCatalog. -

-

- This open-source project is designed to help you and your teams bring discoverability and clarity to your - event-driven architectures (EDA). -

-

- To get started you can read the following guides: -

-

-

Join the community

-

- Got questions about EventCatalog? Feature requests or need support? Join our community on Discord. -

-

Enterprise support

-

- Using EventCatalog and needs enterprise support? Work with us, find out what we offer on our enterprise page. -

-
-
- -
-
-
-
- - -
-
-
-
- - - - diff --git a/eventcatalog/src/layouts/PlainPage.astro b/eventcatalog/src/layouts/PlainPage.astro deleted file mode 100644 index 136d2b2d..00000000 --- a/eventcatalog/src/layouts/PlainPage.astro +++ /dev/null @@ -1,29 +0,0 @@ ---- -interface Props { - title: string; - description?: string; -} - -const { title, description } = Astro.props; - -import Header from '@components/Header.astro'; -import SEO from '@components/Seo.astro'; ---- - - - - - - - -
-
- -
-
- -
-
-
- - diff --git a/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/index.astro b/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/index.astro index 35a41b2f..d25de9cb 100644 --- a/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/index.astro +++ b/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/index.astro @@ -4,7 +4,6 @@ import * as path from 'path'; import fs from 'node:fs'; import type { CollectionTypes, PageTypes } from '@types'; -import PlainPage from '@layouts/PlainPage.astro'; import { DocumentMinusIcon } from '@heroicons/react/24/outline'; import { buildUrl } from '@utils/url-builder'; import { pageDataLoader } from '@utils/page-loaders/page-data-loader'; diff --git a/eventcatalog/src/pages/docs/_default-docs.mdx b/eventcatalog/src/pages/docs/_default-docs.mdx new file mode 100644 index 00000000..46458aa8 --- /dev/null +++ b/eventcatalog/src/pages/docs/_default-docs.mdx @@ -0,0 +1,24 @@ +# **EventCatalog** + +Welcome to [EventCatalog](https://www.eventcatalog.dev/). + +This open-source project is designed to help you and your teams bring discoverability and clarity to your event-driven architectures (EDA). + +To get started you can read the following guides: + +- [Getting started with EventCatalog](https://eventcatalog.dev/docs/development/getting-started/introduction) +- [Creating domains](https://eventcatalog.dev/docs/development/guides/domains/adding-domains) +- [Creating services](https://eventcatalog.dev/docs/development/guides/services/adding-services) +- [Creating commands](https://eventcatalog.dev/docs/development/guides/messages/commands/introduction) +- [Creating events](https://eventcatalog.dev/docs/development/guides/messages/events/introduction) +- [Assigning owners to resources](https://eventcatalog.dev/docs/owners) +- [Using components in your pages (Schemas, OpenAPI, etc)](https://eventcatalog.dev/docs/development/components/using-components) +- [Deploying and hosting your EventCatalog](https://eventcatalog.dev/docs/development/deployment) + +### **Join the community** + +Got questions about EventCatalog? Feature requests or need support? [Join our community on Discord.](https://discord.gg/3rjaZMmrAm) + +### **Enterprise support** + +Using EventCatalog and needs enterprise support? Work with us, find out what we offer on our [enterprise page](https://eventcatalog.dev/enterprise). diff --git a/eventcatalog/src/pages/docs/index.astro b/eventcatalog/src/pages/docs/index.astro index cf404247..1ed1eb24 100644 --- a/eventcatalog/src/pages/docs/index.astro +++ b/eventcatalog/src/pages/docs/index.astro @@ -1,6 +1,5 @@ --- import Footer from '@layouts/Footer.astro'; -import DefaultDocsLandingPage from '@layouts/CustomDocsPageLayout.astro'; import components from '@components/MDX/page-components'; import { getIndexPage } from '@utils/pages'; import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro'; @@ -11,24 +10,20 @@ let CustomContent = null; if (page) { const { Content } = await page.render(); CustomContent = Content; +} else { + CustomContent = await import('./_default-docs.mdx').then((mod) => mod.default); } --- -{ - CustomContent && ( - -
-
-
-
- -
-
-
+ +
+
+
+
+
-
-
- ) -} - -{!CustomContent && } +
+ +
+
diff --git a/src/catalog-to-astro-content-directory.js b/src/catalog-to-astro-content-directory.js index ca555966..f50687bf 100644 --- a/src/catalog-to-astro-content-directory.js +++ b/src/catalog-to-astro-content-directory.js @@ -49,7 +49,6 @@ const ensureAstroCollectionNotEmpty = async (astroDir) => { 'teams', 'domains', 'flows', - 'pages', 'changelogs', 'queries', 'channels',