-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb4ef2e
commit d0b6c7b
Showing
9 changed files
with
331 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
apps/total-typescript/src/app/book/_components/chapter-resource-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
apps/total-typescript/src/app/book/_components/chapters-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as React from 'react' | ||
import {getBook} from '@/lib/book' | ||
import {MenubarItem} from '@skillrecordings/ui/primitives/menubar' | ||
import Link from 'next/link' | ||
import {cn} from '@skillrecordings/ui/utils/cn' | ||
import {findIndex} from 'lodash' | ||
|
||
export const ChaptersList: React.FC<{currentChapterSlug: string}> = async ({ | ||
currentChapterSlug, | ||
}) => { | ||
const book = await getBook('total-typescript') | ||
const currentChapterIndex = findIndex(book?.chapters, (chapter) => { | ||
return chapter.slug.current === currentChapterSlug | ||
}) | ||
|
||
return book?.chapters ? ( | ||
<> | ||
{book.chapters.map((chapter, i) => { | ||
const isActive = i === currentChapterIndex | ||
|
||
return ( | ||
<MenubarItem asChild key={chapter.slug.current}> | ||
<Link | ||
href={`/book/${chapter.slug.current}/${chapter.firstResource.slug.current}`} | ||
className={cn('', { | ||
underline: isActive, | ||
})} | ||
> | ||
{i + 1}. {chapter.title} | ||
</Link> | ||
</MenubarItem> | ||
) | ||
})} | ||
</> | ||
) : null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.