-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
validated-patterns
content (#2666)
* created new validated patterns page based on waf content * remove debug msg * replace placeholders * Add not found to validated patterns content Co-authored-by: Heat Hamilton <[email protected]> * Apply suggestions from code review Co-authored-by: Heat Hamilton <[email protected]> * Update src/content/validated-patterns/index.json Co-authored-by: Heat Hamilton <[email protected]> * make image optional for hero * make image optional for hero --------- Co-authored-by: Heat Hamilton <[email protected]>
- Loading branch information
1 parent
633c4a6
commit e913afc
Showing
34 changed files
with
959 additions
and
22 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
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
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
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,12 @@ | ||
{ | ||
"sidebarCategories": [], | ||
"landingPage": { | ||
"hero": { | ||
"heading": "Validated Patterns" | ||
}, | ||
"overview": { | ||
"heading": "What are Validated Patterns?", | ||
"body": "HashiCorp Validated Patterns provide prescriptive guidance on integrating HashiCorp and partner technologies." | ||
} | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"slug": "validated-patterns", | ||
"name": "Validated Patterns" | ||
} |
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
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
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
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
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,72 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import { getCollectionsBySection } from 'lib/learn-client/api/collection' | ||
import { | ||
Collection as ApiCollection, | ||
TutorialLite as ApiTutorialLite, | ||
} from 'lib/learn-client/types' | ||
import { splitProductFromFilename } from 'views/tutorial-view/utils' | ||
import ValidatedPatternsTutorialView from 'views/validated-patterns/tutorial-view' | ||
import { getValidatedPatternsTutorialViewProps } from 'views/validated-patterns/tutorial-view/server' | ||
import validatedPatternsData from 'data/validated-patterns.json' | ||
import { ValidatedPatternsTutorialViewProps } from 'views/validated-patterns/types' | ||
import { GetStaticPropsContext } from 'next' | ||
import { getStaticPathsFromAnalytics } from 'lib/get-static-paths-from-analytics' | ||
|
||
export async function getStaticProps({ | ||
params, | ||
}: GetStaticPropsContext<{ tutorialSlug: [string, string] }>): Promise< | ||
{ props: ValidatedPatternsTutorialViewProps } | { notFound: boolean } | ||
> { | ||
return { notFound: true } | ||
const props = await getValidatedPatternsTutorialViewProps(params.tutorialSlug) | ||
|
||
// If the tutorial doesn't exist, hit the 404 | ||
if (!props) { | ||
return { notFound: true } | ||
} | ||
return props | ||
} | ||
|
||
export async function getStaticPaths() { | ||
const allCollections = await getCollectionsBySection(validatedPatternsData.slug) | ||
let paths = [] | ||
allCollections.forEach((c: ApiCollection) => { | ||
const collectionSlug = splitProductFromFilename(c.slug) | ||
c.tutorials.forEach(({ slug }: { slug: ApiTutorialLite['slug'] }) => | ||
paths.push({ | ||
params: { | ||
tutorialSlug: [collectionSlug, splitProductFromFilename(slug)], | ||
}, | ||
}) | ||
) | ||
}) | ||
|
||
// For hashicorp/tutorials PR previews, skip the call to determine paths | ||
// from analytics, and statically build all paths. | ||
if (process.env.HASHI_ENV === 'tutorials-preview') { | ||
return { | ||
paths: paths, | ||
fallback: false, | ||
} | ||
} | ||
|
||
try { | ||
paths = await getStaticPathsFromAnalytics({ | ||
param: 'tutorialSlug', | ||
limit: __config.learn.max_static_paths ?? 0, | ||
pathPrefix: `/validated-patterns`, | ||
validPaths: paths, | ||
}) | ||
} catch { | ||
// In the case of an error, fallback to using the base list of generated paths to ensure we do _some_ form of static generation | ||
paths = paths.slice(0, __config.learn.max_static_paths ?? 0) | ||
} | ||
|
||
return { paths, fallback: 'blocking' } | ||
} | ||
|
||
export default ValidatedPatternsTutorialView |
Oops, something went wrong.