Skip to content

Commit

Permalink
Support category, complexity, and industry for Copilot Cookbook landi…
Browse files Browse the repository at this point in the history
…ng page (#53072)
  • Loading branch information
hectorsector authored Nov 13, 2024
1 parent 4f19ff3 commit eb28c13
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/frame/components/context/CategoryLandingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export type TocItem = {
fullPath: string
title: string
intro: string
octicon?: string
category?: string[]
complexity?: string[]
industry?: string[]
}>
}

Expand Down
14 changes: 14 additions & 0 deletions src/frame/lib/frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ export const schema = {
type: 'string',
enum: ['audit-logs', 'codeql-cli', 'github-apps', 'graphql', 'rest', 'webhooks'],
},
// START category-landing tags
category: {
type: 'array',
},
complexity: {
type: 'array',
},
industry: {
type: 'array',
},
octicon: {
type: 'string',
},
// END category landing tags
},
}

Expand Down
8 changes: 8 additions & 0 deletions src/frame/middleware/context/generic-toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ async function getTocItems(node: Tree, context: Context, opts: Options): Promise
node.childPages.filter(filterHidden).map(async (child) => {
const { page } = child
const title = await page.renderProp('rawTitle', context, { textOnly: true })
const octicon = page.octicon ? page.octicon : null
const category = page.category ? page.category : null
const complexity = page.complexity ? page.complexity : null
const industry = page.industry ? page.industry : null
let intro = null
if (opts.renderIntros) {
intro = ''
Expand Down Expand Up @@ -152,6 +156,10 @@ async function getTocItems(node: Tree, context: Context, opts: Options): Promise
title,
fullPath,
intro,
octicon,
category,
complexity,
industry,
childTocItems,
} as ToC
}),
Expand Down
11 changes: 10 additions & 1 deletion src/landings/components/CategoryLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ export const CategoryLanding = () => {
<ul className="clearfix gutter-md-spacious">
{onlyFlatItems.map((item, index) => (
<li key={index} className="col-md-4 col-sm-12 list-style-none float-left p-4">
<CookBookArticleCard title={item.title} description={item.intro} />
<CookBookArticleCard
title={item.title}
description={item.intro}
icon={item.octicon}
tags={[
...(item.industry || []),
...(item.category || []),
...(item.complexity || []),
]}
/>
</li>
))}
</ul>
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ export type Page = {
effectiveDate?: string
fullTitle?: string
render: (context: Context) => Promise<string>
octicon?: string
category?: string[]
complexity?: string[]
industry?: string[]
}

type ChangeLog = {
Expand Down

0 comments on commit eb28c13

Please sign in to comment.