Skip to content

Commit

Permalink
chore: remove tutorials from sentinel spike (#2250)
Browse files Browse the repository at this point in the history
* chore: add place-hold.it to img domains

* chore: avoid tutorials link for Sentinel for now

* chore: rm tutorials top nav link for Sentinel

* chore: rm tutorial icon card for Sentinel

* chore: fix comment quotes for consistency

* chore: rm place-hold images, use dato placeholders

* chore: rm tutorial resource link, add types

* docs: clarify ResourceNav type comment

* style: refactor for fewer loc change
  • Loading branch information
zchsh authored Dec 4, 2023
1 parent 71995ab commit 8958453
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,15 @@ export function getNavItems(currentProduct: ProductData): NavItem[] {

/**
* Tutorials
*
* Note: we exclude Sentinel, as it does not have tutorials yet.
*/
items.push({
label: 'Tutorials',
url: `/${currentProduct.slug}/tutorials`,
})
if (currentProduct.slug !== 'sentinel') {
items.push({
label: 'Tutorials',
url: `/${currentProduct.slug}/tutorials`,
})
}

/**
* Documentation categories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ export const generateProductLandingSidebarMenuItems = (
menuItems.push(introNavItem)
}

menuItems.push(
...[
{
title: 'Tutorials',
fullPath: `/${product.slug}/tutorials`,
},
...docsItems,
]
)
// Add a "Tutorials" link for all products except sentinel
if (product.slug !== 'sentinel') {
menuItems.push({
title: 'Tutorials',
fullPath: `/${product.slug}/tutorials`,
})
}

// Add "Documentation" item links for all products
menuItems.push(...docsItems)

if (getIsEnabledProductIntegrations(product.slug)) {
menuItems.push({
Expand Down
43 changes: 32 additions & 11 deletions src/components/sidebar/helpers/generate-resources-nav-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ import {
VALID_PRODUCT_SLUGS_FOR_FILTERING,
} from 'views/tutorial-library/constants'

/**
* Note: these ResourceNav types could probably be abstracted up or lifted out,
* but for now, since the functions here had very little type information,
* felt pragmatic to declare them just for this file.
*/

type ResourceNavLink = {
title: string
href: string
}
type ResourceNavHeading = {
heading: string
}
type ResourceNavItem = ResourceNavLink | ResourceNavHeading

const DEFAULT_COMMUNITY_FORUM_LINK = 'https://discuss.hashicorp.com/'
const DEFAULT_GITHUB_LINK = 'https://github.com/hashicorp'
const DEFAULT_SUPPORT_LINK = 'https://www.hashicorp.com/customer-success'
Expand Down Expand Up @@ -46,7 +61,9 @@ const GITHUB_LINKS_BY_PRODUCT_SLUG: { [key in ProductSlug]: string } = {
* `src/content` directory, and it has the correct data structure, the specified
* nav items will be appended to the Resources section.
*/
const generateAdditionalResources = (productSlug?: ProductSlug) => {
function generateAdditionalResources(
productSlug?: ProductSlug
): ResourceNavItem[] {
if (productSlug) {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand All @@ -64,7 +81,7 @@ const generateAdditionalResources = (productSlug?: ProductSlug) => {
* Return a link to the Tutorials Library with filters applied
* that correspond to that product.
*/
function getTutorialLibraryUrl(productSlug?: ProductSlug) {
function getTutorialLibraryUrl(productSlug?: ProductSlug): string {
const baseUrl = '/tutorials/library'
if (!productSlug) {
return baseUrl
Expand All @@ -88,10 +105,7 @@ function getTutorialLibraryUrl(productSlug?: ProductSlug) {
* If the given product does not have a certifications page,
* we return an empty array.
*/
function getCertificationsLink(productSlug?: ProductSlug): {
title: string
href: string
}[] {
function getCertificationsLink(productSlug?: ProductSlug): ResourceNavLink[] {
// If this product does not have a certifications link, return an empty array
const programSlug = certificationProgramSlugMap[productSlug]
if (!programSlug) {
Expand All @@ -109,15 +123,22 @@ function getCertificationsLink(productSlug?: ProductSlug): {
* Generates the sidebar nav items for the Resources section of the sidebar.
* Optionally accepts a Product slug for customization of links.
*/
const generateResourcesNavItems = (productSlug?: ProductSlug) => {
function generateResourcesNavItems(
productSlug?: ProductSlug
): ResourceNavItem[] {
const additionalResources = generateAdditionalResources(productSlug)

return [
{ heading: 'Resources' },
{
title: 'Tutorial Library',
href: getTutorialLibraryUrl(productSlug),
},
...(productSlug !== 'sentinel'
? [
{
// Add a "Tutorials" link for all products except Sentinel
title: 'Tutorial Library',
href: getTutorialLibraryUrl(productSlug),
},
]
: []),
...getCertificationsLink(productSlug),
{
title: 'Community Forum',
Expand Down
6 changes: 3 additions & 3 deletions src/content/sentinel/product-landing.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"hero": {
"heading": "Enforce policy as code for HashiCorp products",
"image": "https://place-hold.it/600x320"
"image": "https://www.datocms-assets.com/2885/1701706791-sentinel-landing-placeholder.png"
},
"overview": {
"heading": "What is Sentinel?",
Expand All @@ -11,8 +11,8 @@
"url": "/sentinel/intro/what"
},
"image": {
"light": "https://place-hold.it/680x250",
"dark": "https://place-hold.it/680x250"
"light": "https://www.datocms-assets.com/2885/1701706795-what-is-sentinel-placeholder.png",
"dark": "https://www.datocms-assets.com/2885/1701706795-what-is-sentinel-placeholder.png"
}
},
"get_started": {
Expand Down
29 changes: 15 additions & 14 deletions src/views/product-landing/helpers/get-icon-cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ export function getIconCards(product: ProductData) {
})
}

iconCards.push(
...[
{
icon: <IconLearn16 />,
text: 'Tutorials',
url: `/${product.slug}/tutorials`,
},
{
icon: <IconDocs16 />,
text: 'Documentation',
url: `/${product.slug}/docs`,
},
]
)
// Add a "Tutorials" link for all products except sentinel
if (product.slug !== 'sentinel') {
iconCards.push({
icon: <IconLearn16 />,
text: 'Tutorials',
url: `/${product.slug}/tutorials`,
})
}

// Add a "Documentation" link for all products
iconCards.push({
icon: <IconDocs16 />,
text: 'Documentation',
url: `/${product.slug}/docs`,
})

// Add Integrations card if it's enabled for this product
if (getIsEnabledProductIntegrations(product.slug)) {
Expand Down

1 comment on commit 8958453

@vercel
Copy link

@vercel vercel bot commented on 8958453 Dec 4, 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.