mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-02 05:42:41 +02:00
Add breadcrumbs and roadmap banner
This commit is contained in:
39
src/components/Breadcrumbs.astro
Normal file
39
src/components/Breadcrumbs.astro
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
import type { BreadcrumbItem } from '../lib/topic';
|
||||||
|
|
||||||
|
export interface Props {
|
||||||
|
breadcrumbs: BreadcrumbItem[];
|
||||||
|
roadmapId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { breadcrumbs, roadmapId } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<div class='py-7 pb-6 -mb-7'>
|
||||||
|
<!-- Desktop breadcrums -->
|
||||||
|
<p class='text-gray-500 container hidden sm:block'>
|
||||||
|
<a href='/roadmaps' class='hover:text-gray-800'>Roadmaps</a>
|
||||||
|
<span>·</span>
|
||||||
|
{ breadcrumbs.map((breadcrumb, counter) => {
|
||||||
|
const isLast = counter === breadcrumbs.length - 1;
|
||||||
|
|
||||||
|
if (!isLast) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<a class='hover:text-gray-800' href={breadcrumb.url}>{ breadcrumb.title }</a>
|
||||||
|
<span> · </span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <span class='text-gray-400'>{ breadcrumb.title }</span>
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Mobile breadcrums -->
|
||||||
|
<p class='container block sm:hidden'>
|
||||||
|
<a class='bg-gray-500 py-1.5 px-3 rounded-md text-white text-xs sm:text-sm font-medium hover:bg-gray-600' href={`/${roadmapId}`}>
|
||||||
|
← Back to Topics List
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
26
src/components/RoadmapBanner.astro
Normal file
26
src/components/RoadmapBanner.astro
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
import type { RoadmapFrontmatter } from '../lib/roadmap';
|
||||||
|
|
||||||
|
export interface Props {
|
||||||
|
roadmapId: string;
|
||||||
|
roadmap: RoadmapFrontmatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { roadmap, roadmapId } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<a
|
||||||
|
href={`/${roadmapId}`}
|
||||||
|
class="flex items-center justify-center bg-yellow-100 text-yellow-900 border-b py-2 sm:py-3 text-sm sm:text-md hover:bg-yellow-200"
|
||||||
|
>
|
||||||
|
<span class="container">
|
||||||
|
<span class="hidden sm:inline"
|
||||||
|
>Click to visit the interactive version of</span
|
||||||
|
>
|
||||||
|
<span class="inline sm:hidden">Visit complete</span>
|
||||||
|
|
||||||
|
<span class="sm:lowercase ml-0.5 font-medium underline underline-offset-1"
|
||||||
|
>{roadmap.featuredTitle} roadmap</span
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
</a>
|
@@ -59,7 +59,7 @@ function generateBreadcrumbs(
|
|||||||
return breadcrumbs;
|
return breadcrumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
type BreadcrumbItem = {
|
export type BreadcrumbItem = {
|
||||||
title: string;
|
title: string;
|
||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
import Breadcrumbs from '../components/Breadcrumbs.astro';
|
||||||
import MarkdownContent from '../components/MarkdownContent/MarkdownContent.astro';
|
import MarkdownContent from '../components/MarkdownContent/MarkdownContent.astro';
|
||||||
|
import RoadmapBanner from '../components/RoadmapBanner.astro';
|
||||||
import BaseLayout from '../layouts/BaseLayout.astro';
|
import BaseLayout from '../layouts/BaseLayout.astro';
|
||||||
import { getTopicFiles, TopicFileType } from '../lib/topic';
|
import { getTopicFiles, TopicFileType } from '../lib/topic';
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const topicPathMapping = await getTopicFiles();
|
const topicPathMapping = await getTopicFiles();
|
||||||
|
|
||||||
// console.log(topicPathMapping);
|
|
||||||
|
|
||||||
return Object.keys(topicPathMapping).map((topicSlug) => ({
|
return Object.keys(topicPathMapping).map((topicSlug) => ({
|
||||||
params: { topicId: topicSlug.replace(/^\//, '') },
|
params: { topicId: topicSlug.replace(/^\//, '') },
|
||||||
props: topicPathMapping[topicSlug],
|
props: topicPathMapping[topicSlug],
|
||||||
@@ -15,10 +15,13 @@ export async function getStaticPaths() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { topicId } = Astro.params;
|
const { topicId } = Astro.params;
|
||||||
const { file } = Astro.props as TopicFileType;
|
const { file, breadcrumbs, roadmapId, roadmap } = Astro.props as TopicFileType;
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout title="What is this">
|
<BaseLayout title="What is this">
|
||||||
|
<RoadmapBanner roadmapId={roadmapId} roadmap={roadmap} />
|
||||||
|
<Breadcrumbs breadcrumbs={breadcrumbs} roadmapId={roadmapId} />
|
||||||
|
|
||||||
<MarkdownContent>
|
<MarkdownContent>
|
||||||
<main id="main-content">
|
<main id="main-content">
|
||||||
<file.Content />
|
<file.Content />
|
||||||
|
Reference in New Issue
Block a user