Skip to content

Commit 98febf0

Browse files
committed
Full DocLinkCreator class rework - useLink Hook
1 parent 3d87613 commit 98febf0

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/context/FrontendConfigContext.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ export enum Landscape {
99
Local = 'LOCAL',
1010
}
1111

12-
interface FrontendConfigContextType extends FrontendConfig {
13-
links: DocLinkCreator;
14-
}
15-
16-
export const FrontendConfigContext =
17-
createContext<FrontendConfigContextType | null>(null);
12+
export const FrontendConfigContext = createContext<FrontendConfig | null>(null);
1813

1914
const fetchPromise = fetch('/frontend-config.json')
2015
.then((res) => res.json())
@@ -58,6 +53,7 @@ const FrontendConfigSchema = z.object({
5853
backendUrl: z.string(),
5954
gatewayUrl: z.string(),
6055
documentationBaseUrl: z.string(),
56+
githubBaseUrl: z.string(),
6157
oidcConfig: OidcConfigSchema,
6258
landscape: z.optional(z.nativeEnum(Landscape)),
6359
});

src/lib/shared/links.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useFrontendConfig } from '../../context/FrontendConfigContext';
22

33
export function useLink() {
4-
const { documentationBaseUrl } = useFrontendConfig();
4+
const { documentationBaseUrl, githubBaseUrl } = useFrontendConfig();
55

6-
if (!documentationBaseUrl) {
6+
if (!documentationBaseUrl || !githubBaseUrl) {
77
throw new Error('useLink must be used within a FrontendConfigProvider');
88
}
9-
109
const createLink = (path: string) => `${documentationBaseUrl}${path}`;
10+
const createGithubLink = (path: string) => `${githubBaseUrl}${path}`;
1111

1212
return {
1313
documentationHomepage: createLink('/'),
@@ -20,5 +20,6 @@ export function useLink() {
2020
mcpCreationGuide: createLink(
2121
'/docs/managed-control-planes/get-started/get-started-mcp#5-create-managedcontrolplane',
2222
),
23+
githubIssuesSupportTicket: createGithubLink('/support/issues/new'),
2324
};
2425
}

0 commit comments

Comments
 (0)