Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the guide docs page with dynamic titles #693

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions backstage/packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ const routes = (
<HomePage />
</Route>
<Route path="/catalog" element={<CatalogIndexPage />} />
<Route path="/guide" element={<DeveloperGuidePage />} />
<Route path="/portal-docs" element={<PortalDocsPage />} />
<Route
path="/guide/:namespace/:kind/:name"
element={<DeveloperGuidePage />}
/>
<Route
path="/portal-docs/:namespace/:kind/:name"
element={<PortalDocsPage />}
/>
<Route
path="/catalog/:namespace/:kind/:name"
element={<CatalogEntityPage />}
Expand Down
29 changes: 16 additions & 13 deletions backstage/packages/app/src/components/dev-guide/GuideDocsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { PageWithHeader } from '@backstage/core-components';
import { useRouteRefParams } from '@backstage/core-plugin-api';
import { TechDocsReaderPageContent } from '@backstage/plugin-techdocs';
import { TechDocsReaderPageProvider } from '@backstage/plugin-techdocs-react';
import React from 'react';
import { rootDocsRouteRef } from '../../routes';

export const DeveloperGuidePage = () => (
<PageWithHeader title="Developer Guide" themeId="documentation">
<TechDocsReaderPageProvider
entityRef={{
kind: 'component',
namespace: 'default',
name: 'developer-guide',
}}
>
<TechDocsReaderPageContent />
</TechDocsReaderPageProvider>
</PageWithHeader>
);
// based on this /~https://github.com/backstage/backstage/blob/master/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx
export const DeveloperGuidePage = () => {
const { kind, name, namespace } = useRouteRefParams(rootDocsRouteRef);

const entityRef = { kind, name, namespace };

return (
<PageWithHeader title={name} themeId="diamond-theme">
<TechDocsReaderPageProvider entityRef={entityRef}>
<TechDocsReaderPageContent />
</TechDocsReaderPageProvider>
</PageWithHeader>
);
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { PageWithHeader } from '@backstage/core-components';
import { useRouteRefParams } from '@backstage/core-plugin-api';
import { TechDocsReaderPageContent } from '@backstage/plugin-techdocs';
import { TechDocsReaderPageProvider } from '@backstage/plugin-techdocs-react';
import React from 'react';
import { rootDocsRouteRef } from '../../routes';

export const PortalDocsPage = () => (
<PageWithHeader title="Developer Portal Docs" themeId="documentation">
<TechDocsReaderPageProvider
entityRef={{
kind: 'system',
namespace: 'default',
name: 'developer-portal',
}}
>
<TechDocsReaderPageContent />
</TechDocsReaderPageProvider>
</PageWithHeader>
);
export function PortalDocsPage() {
const { kind, name, namespace } = useRouteRefParams(rootDocsRouteRef);
const entityRef = { kind, name, namespace };
return (
<PageWithHeader title="Developer Portal Docs" themeId="documentation">
<TechDocsReaderPageProvider entityRef={entityRef}>
<TechDocsReaderPageContent />
</TechDocsReaderPageProvider>
</PageWithHeader>
);
}
14 changes: 14 additions & 0 deletions backstage/packages/app/src/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createRouteRef } from '@backstage/core-plugin-api';

export const rootRouteRef = createRouteRef({
id: 'techdocs:index-page',
});

export const rootDocsRouteRef = createRouteRef({
id: 'techdocs:reader-page',
params: ['namespace', 'kind', 'name'],
});

export const rootCatalogDocsRouteRef = createRouteRef({
id: 'techdocs:catalog-reader-view',
});
Loading