feat: add ai roadmap slug

feat/ai-rdm-slug
Arik Chakma 7 months ago
parent 5d82c1080f
commit 73e46ad0d6
  1. 1
      src/api/ai-roadmap.ts
  2. 8
      src/components/GenerateRoadmap/GenerateRoadmap.tsx
  3. 6
      src/pages/ai/[aiRoadmapSlug].astro

@ -6,6 +6,7 @@ export type GetAIRoadmapBySlugResponse = {
term: string;
title: string;
data: string;
isAuthenticatedUser: boolean;
};
export function aiRoadmapApi(context: APIContext) {

@ -91,10 +91,15 @@ type GetAIRoadmapResponse = {
type GenerateRoadmapProps = {
roadmapId?: string;
slug?: string;
isAuthenticatedUser?: boolean;
};
export function GenerateRoadmap(props: GenerateRoadmapProps) {
const { roadmapId: defaultRoadmapId, slug: defaultRoadmapSlug } = props;
const {
roadmapId: defaultRoadmapId,
slug: defaultRoadmapSlug,
isAuthenticatedUser = isLoggedIn(),
} = props;
const roadmapContainerRef = useRef<HTMLDivElement>(null);
@ -130,7 +135,6 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) {
getOpenAIKey(),
);
const isKeyOnly = IS_KEY_ONLY_ROADMAP_GENERATION;
const isAuthenticatedUser = isLoggedIn();
const renderRoadmap = async (roadmap: string) => {
const { nodes, edges } = generateAIRoadmapFromText(roadmap);

@ -26,5 +26,9 @@ const title = roadmap?.title || 'Roadmap AI';
---
<BaseLayout title={title}>
<GenerateRoadmap roadmapId={roadmap?.id} client:load />
<GenerateRoadmap
roadmapId={roadmap?.id}
isAuthenticatedUser={roadmap?.isAuthenticatedUser}
client:load
/>
</BaseLayout>

Loading…
Cancel
Save