Skip to content

Commit

Permalink
feat: use tutorial short name - breadcrumb, tutorial sidebar, sitemap (
Browse files Browse the repository at this point in the history
…#2046)

* update types

* add to breadcrumb

* type and formatting

* Adds to sitemap
  • Loading branch information
kendallstrautman authored Jul 17, 2023
1 parent bd1a456 commit cfdebc2
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/learn-client/api/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface ApiTutorial extends ContentBaseModel, DefaultCollection {
hands_on_lab_provider: HandsOnLabProviderOption | null
products_used: ApiProductsUsed[] // Returns empty array if no products used
variants: ApiTutorialVariant[]
short_name: string
}

// Everything in base ApiTutorial, except content
Expand Down
2 changes: 2 additions & 0 deletions src/lib/learn-client/api/collection/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function formatToTutorialLite(
const {
id,
name,
short_name,
slug,
description,
read_time,
Expand All @@ -71,6 +72,7 @@ export function formatToTutorialLite(
return {
id,
name,
shortName: short_name || name,
slug,
description,
readTime: read_time,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/learn-client/api/tutorial/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function formatTutorialData(
id,
slug,
name,
short_name,
description,
content,
default_collection_id,
Expand All @@ -66,6 +67,7 @@ export function formatTutorialData(
id,
slug,
name,
shortName: short_name || name,
description,
content,
collectionCtx,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/learn-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Tutorial {
id?: ApiTutorial['id'] // uuid
slug: identifier
name: string
shortName: string
description: string
content: string // mdx content
collectionCtx: CollectionCtxLite
Expand Down Expand Up @@ -73,6 +74,7 @@ export interface TutorialLite
Tutorial,
| 'id'
| 'name'
| 'shortName'
| 'slug'
| 'description'
| 'readTime'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function formatSitemapCollection(
tutorials: collection.tutorials.map((t: ClientTutorialLite) => ({
id: t.id,
slug: t.slug,
name: t.name,
name: t.shortName || t.name,
})),
}
}
2 changes: 1 addition & 1 deletion src/views/tutorial-view/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function getTutorialPageProps(
filename: collection.filename,
},
tutorial: {
name: fullTutorialData.name,
name: fullTutorialData.shortName,
filename: tutorialReference.filename,
},
}),
Expand Down
1 change: 1 addition & 0 deletions src/views/tutorial-view/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface TutorialData
ClientTutorial,
| 'id'
| 'name'
| 'shortName'
| 'slug'
| 'readTime'
| 'productsUsed'
Expand Down
2 changes: 1 addition & 1 deletion src/views/tutorial-view/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function formatTutorialToMenuItem(
return {
tutorialId: tutorial.id,
collectionId: collection.id,
text: tutorial.name,
text: tutorial.shortName,
href: path,
isActive: path === currentPathWithoutVariant,
}
Expand Down

1 comment on commit cfdebc2

@vercel
Copy link

@vercel vercel bot commented on cfdebc2 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.