diff --git a/content/copilot/example-prompts-for-github-copilot-chat/index.md b/content/copilot/example-prompts-for-github-copilot-chat/index.md index 2b385faae1..cd2a76c6f6 100644 --- a/content/copilot/example-prompts-for-github-copilot-chat/index.md +++ b/content/copilot/example-prompts-for-github-copilot-chat/index.md @@ -14,4 +14,11 @@ children: - /documenting-code - /testing-code - /security-analysis +spotlight: + - article: /testing-code/generate-unit-tests + image: /assets/images/copilot-landing/generating_unit_tests.png + - article: /refactoring-code/improving-code-readability-and-maintainability + image: /assets/images/copilot-landing/improving_code_readability.png + - article: /debugging-errors/debugging-invalid-json + image: /assets/images/copilot-landing/debugging_invalid_json.png --- diff --git a/src/frame/components/context/CategoryLandingContext.tsx b/src/frame/components/context/CategoryLandingContext.tsx index 3434ae772b..003ff974ff 100644 --- a/src/frame/components/context/CategoryLandingContext.tsx +++ b/src/frame/components/context/CategoryLandingContext.tsx @@ -5,7 +5,7 @@ import { FeaturedLink, getFeaturedLinksFromReq, } from 'src/landings/components/ProductLandingContext' -import { TocItem } from '#src/landings/types.ts' +import { TocItem, Spotlight } from '#src/landings/types.ts' export type CategoryLandingContextT = { title: string @@ -18,6 +18,7 @@ export type CategoryLandingContextT = { renderedPage: string currentLearningTrack?: LearningTrack currentLayout: string + currentSpotlight: Array } export const CategoryLandingContext = createContext(null) @@ -48,5 +49,6 @@ export const getCategoryLandingContextFromRequest = (req: any): CategoryLandingC renderedPage: req.context.renderedPage, currentLearningTrack: req.context.currentLearningTrack, currentLayout: req.context.currentLayoutName, + currentSpotlight: req.context.page.spotlight, } } diff --git a/src/frame/lib/frontmatter.js b/src/frame/lib/frontmatter.js index 5e7c855ca3..ceb9726c1b 100644 --- a/src/frame/lib/frontmatter.js +++ b/src/frame/lib/frontmatter.js @@ -262,6 +262,22 @@ export const schema = { octicon: { type: 'string', }, + spotlight: { + type: 'array', + minItems: 3, + maxItems: 3, + items: { + type: 'object', + properties: { + article: { + type: 'string', + }, + image: { + type: 'string', + }, + }, + }, + }, // END category landing tags }, } diff --git a/src/landings/components/CategoryLanding.tsx b/src/landings/components/CategoryLanding.tsx index 8dac7779ef..98b4191909 100644 --- a/src/landings/components/CategoryLanding.tsx +++ b/src/landings/components/CategoryLanding.tsx @@ -8,14 +8,12 @@ import { DefaultLayout } from 'src/frame/components/DefaultLayout' import { ArticleTitle } from 'src/frame/components/article/ArticleTitle' import { Lead } from 'src/frame/components/ui/Lead' import { useCategoryLandingContext } from 'src/frame/components/context/CategoryLandingContext' -import { ClientSideRedirects } from 'src/rest/components/ClientSideRedirects' -import { RestRedirect } from 'src/rest/components/RestRedirect' import { Breadcrumbs } from 'src/frame/components/page-header/Breadcrumbs' import { ArticleCardItems } from 'src/landings/types' export const CategoryLanding = () => { const router = useRouter() - const { title, intro, tocItems } = useCategoryLandingContext() + const { title, intro, tocItems, currentSpotlight } = useCategoryLandingContext() // tocItems contains directories and its children, we only want the child articles const onlyFlatItems: ArticleCardItems = tocItems.flatMap((item) => item.childTocItems || []) @@ -72,11 +70,6 @@ export const CategoryLanding = () => { } return ( - {router.route === '/[versionId]/rest/[category]' && } - {/* Doesn't matter *where* this is included because it will - never render anything. It always just return null. */} - -
@@ -86,36 +79,39 @@ export const CategoryLanding = () => {

Spotlight

-
- -
-
- -
-
- -
+ { + // The articles in the spotlight should be contained within the page's children. If not, we throw. + currentSpotlight.map((spotlightItem, index) => { + const matchedItem = onlyFlatItems.find((item) => + item.fullPath.endsWith(spotlightItem.article), + ) + if ( + !matchedItem || + !matchedItem.title || + !matchedItem.intro || + !matchedItem.fullPath + ) { + throw new Error( + `Couldn't find the articles defined in the spotlight region defined for ${router.asPath}. Check that page's spotlight frontmater property.`, + ) + } + + // A missing image is possible, in that case the CookBookArticleCard component can handle a placeholder at a future iteration. + return ( +
+ +
+ ) + }) + }
diff --git a/src/landings/types.ts b/src/landings/types.ts index b38c9e66db..a768528c72 100644 --- a/src/landings/types.ts +++ b/src/landings/types.ts @@ -27,3 +27,8 @@ export type TocItem = BaseTocItem & { } export type ArticleCardItems = ChildTocItem[] + +export type Spotlight = { + article: string + image: string +}