Skip to content

Commit e060403

Browse files
committed
include demos and deprecated
1 parent 7db63cc commit e060403

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/content.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function defineContent(contentObj: CollectionDefinition) {
1414
return
1515
}
1616

17-
// Todo: expand to cover deprecated & demos tabs (look in filepath, or enforce tab in frontmatter for nonstandard tabs)
17+
// Todo: expand for other packages that remain under the react umbrella (Table, CodeEditor, etc)
1818
const tabMap: any = {
1919
'react-component-docs': 'react',
2020
'core-component-docs': 'html'
@@ -27,7 +27,7 @@ function defineContent(contentObj: CollectionDefinition) {
2727
section: z.string(),
2828
subsection: z.string().optional(),
2929
title: z.string().optional(),
30-
tab: z.string().optional().default(tabMap[name])
30+
tab: z.string().optional().default(tabMap[name]),
3131
// package: z.string().optional().default(packageName as string)
3232
}),
3333
})

src/content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ export const content = [
22
{ base: 'textContent', pattern: '*.md', name: "textContent" },
33
{
44
"packageName":"@patternfly/react-core",
5-
"pattern":"**/components/**/*.md",
5+
"pattern":"**/examples/**/*.md", // had to update the pattern to bring in demos docs
66
"name":"react-component-docs"
77
},
88
{
99
"packageName":"@patternfly/patternfly",
10-
"pattern":"**/components/**/*.md",
10+
"pattern":"**/examples/**/*.md", // had to update the pattern to bring in demos docs
1111
"name":"core-component-docs"
1212
}
1313
]

src/pages/[section]/[page]/[...tab].astro

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@ export async function getStaticPaths() {
1111
1212
const flatCol = collections.flat().map((entry) => {
1313
// Build tabs dictionary
14+
let tab = entry.data.tab;
15+
if(tab === 'react' || tab === 'html') { // if tab is default repo value, check for demos/deprecated
16+
if(entry.id.includes('demos')) {
17+
tab = `${tab}-demos`;
18+
} else if (entry.id.includes('deprecated')) {
19+
tab = `${tab}-deprecated`;
20+
}
21+
}
22+
1423
// if no dictionary entry exists, and tab data exists
15-
if(componentTabs[entry.data.id] === undefined && entry.data.tab) {
16-
componentTabs[entry.data.id] = [entry.data.tab];
24+
if(componentTabs[entry.data.id] === undefined && tab) {
25+
componentTabs[entry.data.id] = [tab];
1726
// if dictionary entry & tab data exists, and entry does not include tab
18-
} else if (componentTabs[entry.data.id] && entry.data.tab && !componentTabs[entry.data.id].includes(entry.data.tab)) {
19-
componentTabs[entry.data.id] = [...componentTabs[entry.data.id], entry.data.tab];
27+
} else if (componentTabs[entry.data.id] && tab && !componentTabs[entry.data.id].includes(tab)) {
28+
componentTabs[entry.data.id] = [...componentTabs[entry.data.id], tab];
2029
}
2130
2231
return {
23-
params: { page: kebabCase(entry.data.id), section: entry.data.section, tab: entry.data.tab },
32+
params: { page: kebabCase(entry.data.id), section: entry.data.section, tab },
2433
props: { entry, title: entry.data.title, component: entry.data.id, package: entry.data.package },
2534
}
2635
})
@@ -72,13 +81,11 @@ const currentPath = Astro.url.pathname;
7281
</Title>
7382
)
7483
}
75-
HELLO TAB
76-
<!-- {console.log(entry, id, componentTabs[id], currentPath)} -->
7784
{componentTabs[id] && (
7885
<PageSection id="ws-sticky-nav-tabs" stickyOnBreakpoint={{ default: 'top' }} type="tabs">
7986
<div class="pf-v6-c-tabs pf-m-page-insets pf-m-no-border-bottom">
8087
<ul class="pf-v6-c-tabs__list">
81-
{componentTabs[id].map((tab: string, index: number) => ( // TODO: sort tabs array to standard
88+
{componentTabs[id].map((tab: string) => (
8289
// eslint-disable-next-line react/jsx-key
8390
<li
8491
class={`pf-v6-c-tabs__item${currentPath === `/${section}/${kebabCase(id)}/${tab}` ? ' pf-m-current' : ''}`}

0 commit comments

Comments
 (0)