@patternfly/documentation-framework 1.6.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/components/sideNav/sideNav.js +10 -3
- package/package.json +2 -2
- package/routes.js +19 -4
- package/scripts/md/parseMD.js +11 -1
- package/templates/mdx.js +10 -2
- package/templates/patternfly-docs/content/extensions/extension/design-guidelines/design-guidelines.md +2 -0
- package/templates/patternfly-docs/content/extensions/extension/examples/basic.md +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 1.8.0 (2023-02-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **docs:** enabled manual ordering of sidenav ([#3403](https://github.com/patternfly/patternfly-org/issues/3403)) ([b630ed9](https://github.com/patternfly/patternfly-org/commit/b630ed9e7062e1302d58793bfec65d49da7764d3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# 1.7.0 (2023-02-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **docs:** customize tabs with optional tabText frontmatter ([#3394](https://github.com/patternfly/patternfly-org/issues/3394)) ([093c6c7](https://github.com/patternfly/patternfly-org/commit/093c6c77053f544605d40f8918dc5621829ac7c3))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## 1.6.1 (2023-02-09)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @patternfly/documentation-framework
|
|
@@ -12,6 +12,8 @@ const getIsActive = (location, section, subsection = null) => {
|
|
|
12
12
|
return location.pathname.startsWith(`${process.env.pathPrefix}${slug}`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const defaultValue = 50;
|
|
16
|
+
|
|
15
17
|
const NavItem = ({ text, href }) => {
|
|
16
18
|
const isMobileView = window.innerWidth < Number.parseInt(globalBreakpointXl.value, 10);
|
|
17
19
|
return (
|
|
@@ -67,9 +69,14 @@ const ExpandableNav = ({groupedRoutes, location, section, subsection = null}) =>
|
|
|
67
69
|
}}
|
|
68
70
|
>
|
|
69
71
|
{Object.entries(routes || {})
|
|
70
|
-
.filter(([id,
|
|
71
|
-
.map(([id, { slug, isSubsection = false }]) => ({ text: id, href: slug, isSubsection }))
|
|
72
|
-
.sort(({
|
|
72
|
+
.filter(([id, navObj]) => !Boolean(navObj.hideNavItem) && (Object.entries(navObj).length > 0))
|
|
73
|
+
.map(([id, { slug, isSubsection = false, sortValue = defaultValue, subsectionSortValue = defaultValue }]) => ({ text: id, href: slug, isSubsection, sortValue: (isSubsection ? subsectionSortValue : sortValue) }))
|
|
74
|
+
.sort(({text: text1, sortValue: sortValue1}, {text: text2, sortValue: sortValue2}) => {
|
|
75
|
+
if (sortValue1 === sortValue2) {
|
|
76
|
+
return text1.localeCompare(text2);
|
|
77
|
+
}
|
|
78
|
+
return sortValue1 > sortValue2 ? 1 : -1;
|
|
79
|
+
})
|
|
73
80
|
.map(navObj => navObj.isSubsection
|
|
74
81
|
? ExpandableNav({groupedRoutes, location, section, subsection: navObj.text})
|
|
75
82
|
: NavItem(navObj)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/documentation-framework",
|
|
3
3
|
"description": "A framework to build documentation for PatternFly.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"author": "Red Hat",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"react": "^16.8.0 || ^17.0.0",
|
|
85
85
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "473ad9370d5a4d48fdfe1c061e723a0911f3ac33"
|
|
88
88
|
}
|
package/routes.js
CHANGED
|
@@ -9,6 +9,8 @@ const routes = {
|
|
|
9
9
|
...generatedRoutes
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
const defaultOrder = 50;
|
|
13
|
+
|
|
12
14
|
for (let route in routes) {
|
|
13
15
|
const pageData = routes[route];
|
|
14
16
|
if (pageData.SyncComponent) {
|
|
@@ -28,7 +30,7 @@ const isNull = o => o === null || o === undefined;
|
|
|
28
30
|
const groupedRoutes = Object.entries(routes)
|
|
29
31
|
.filter(([_slug, { id, section }]) => !isNull(id) && !isNull(section))
|
|
30
32
|
.reduce((accum, [slug, pageData]) => {
|
|
31
|
-
const { section, subsection = null, id, title, source, katacodaLayout, hideNavItem, relPath } = pageData;
|
|
33
|
+
const { section, subsection = null, id, title, source, katacodaLayout, hideNavItem, relPath, sortValue = null, subsectionSortValue = null } = pageData;
|
|
32
34
|
pageData.slug = slug;
|
|
33
35
|
// add section to groupedRoutes obj if not yet created
|
|
34
36
|
accum[section] = accum[section] || {};
|
|
@@ -42,7 +44,9 @@ const groupedRoutes = Object.entries(routes)
|
|
|
42
44
|
sources: [],
|
|
43
45
|
katacodaLayout,
|
|
44
46
|
hideNavItem,
|
|
45
|
-
relPath
|
|
47
|
+
relPath,
|
|
48
|
+
...(sortValue && { sortValue }),
|
|
49
|
+
...(subsectionSortValue && { subsectionSortValue })
|
|
46
50
|
}
|
|
47
51
|
// add page to groupedRoutes obj section or subsection
|
|
48
52
|
if (subsection) {
|
|
@@ -52,10 +56,21 @@ const groupedRoutes = Object.entries(routes)
|
|
|
52
56
|
// add page to subsection
|
|
53
57
|
accum[section][subsection][id] = accum[section][subsection][id] || data;
|
|
54
58
|
accum[section][subsection][id].sources.push(pageData);
|
|
59
|
+
// nav item ordering
|
|
60
|
+
if (sortValue) {
|
|
61
|
+
accum[section][subsection].sortValue = sortValue;
|
|
62
|
+
}
|
|
63
|
+
if (subsectionSortValue) {
|
|
64
|
+
accum[section][subsection].subsectionSortValue = subsectionSortValue;
|
|
65
|
+
}
|
|
55
66
|
} else {
|
|
56
67
|
// add page to section
|
|
57
68
|
accum[section][id] = accum[section][id] || data;
|
|
58
69
|
accum[section][id].sources.push(pageData);
|
|
70
|
+
// nav item ordering
|
|
71
|
+
if (sortValue) {
|
|
72
|
+
accum[section][id].sortValue = sortValue;
|
|
73
|
+
}
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
return accum;
|
|
@@ -73,7 +88,6 @@ const sourceOrder = {
|
|
|
73
88
|
'design-guidelines': 99,
|
|
74
89
|
'accessibility': 100
|
|
75
90
|
};
|
|
76
|
-
const defaultOrder = 50;
|
|
77
91
|
|
|
78
92
|
const sortSources = ({ source: s1 }, { source: s2 }) => {
|
|
79
93
|
const s1Index = sourceOrder[s1] || defaultOrder;
|
|
@@ -108,7 +122,8 @@ Object.entries(groupedRoutes)
|
|
|
108
122
|
// Loop through each page in expandable subsection
|
|
109
123
|
if (pageData.isSubsection) {
|
|
110
124
|
Object.entries(pageData).map(([section, ids]) => {
|
|
111
|
-
|
|
125
|
+
// only push nested page objects
|
|
126
|
+
if (ids && ids?.id) {
|
|
112
127
|
pageDataArr.push(ids);
|
|
113
128
|
}
|
|
114
129
|
})
|
package/scripts/md/parseMD.js
CHANGED
|
@@ -85,6 +85,7 @@ function toReactComponent(mdFilePath, source, buildMode) {
|
|
|
85
85
|
section: frontmatter.section || '',
|
|
86
86
|
subsection: frontmatter.subsection || '',
|
|
87
87
|
source,
|
|
88
|
+
tabName: frontmatter.tabName || null,
|
|
88
89
|
slug,
|
|
89
90
|
sourceLink: frontmatter.sourceLink || `https://github.com/patternfly/${
|
|
90
91
|
sourceRepo}/blob/main/${
|
|
@@ -126,6 +127,12 @@ function toReactComponent(mdFilePath, source, buildMode) {
|
|
|
126
127
|
if (frontmatter.hideNavItem) {
|
|
127
128
|
pageData.hideNavItem = frontmatter.hideNavItem;
|
|
128
129
|
}
|
|
130
|
+
if (frontmatter.sortValue) {
|
|
131
|
+
pageData.sortValue = frontmatter.sortValue;
|
|
132
|
+
}
|
|
133
|
+
if (frontmatter.subsectionSortValue) {
|
|
134
|
+
pageData.subsectionSortValue = frontmatter.subsectionSortValue;
|
|
135
|
+
}
|
|
129
136
|
})
|
|
130
137
|
// Delete HTML comments
|
|
131
138
|
.use(require('./remove-comments'))
|
|
@@ -266,8 +273,11 @@ function sourceMDFile(file, source, buildMode) {
|
|
|
266
273
|
section: pageData.section,
|
|
267
274
|
subsection: pageData.subsection,
|
|
268
275
|
source: pageData.source,
|
|
276
|
+
tabName: pageData.tabName,
|
|
269
277
|
...(pageData.katacodaLayout && { katacodaLayout: pageData.katacodaLayout }),
|
|
270
|
-
...(pageData.hideNavItem && { hideNavItem: pageData.hideNavItem })
|
|
278
|
+
...(pageData.hideNavItem && { hideNavItem: pageData.hideNavItem }),
|
|
279
|
+
...(pageData.sortValue && { sortValue: pageData.sortValue }),
|
|
280
|
+
...(pageData.subsectionSortValue && { subsectionSortValue: pageData.subsectionSortValue })
|
|
271
281
|
};
|
|
272
282
|
}
|
|
273
283
|
}
|
package/templates/mdx.js
CHANGED
|
@@ -121,7 +121,15 @@ export const MDXTemplate = ({
|
|
|
121
121
|
id,
|
|
122
122
|
componentsData
|
|
123
123
|
}) => {
|
|
124
|
-
|
|
124
|
+
// Build obj mapping source names to text displayed on tabs
|
|
125
|
+
const tabNames = sources.reduce((acc, curSrc) => {
|
|
126
|
+
const { source, tabName } = curSrc;
|
|
127
|
+
// use tabName for tab name if present, otherwise default to source
|
|
128
|
+
const tabLinkText = tabName || capitalize(source.replace('html', 'HTML').replace(/-/g, ' '));
|
|
129
|
+
acc[source] = tabLinkText;
|
|
130
|
+
return acc;
|
|
131
|
+
}, {});
|
|
132
|
+
const sourceKeys = Object.keys(tabNames);
|
|
125
133
|
const isSinglePage = sourceKeys.length === 1;
|
|
126
134
|
|
|
127
135
|
let isDevResources, isComponent, isExtension, isChart, isDemo, isLayout, isUtility;
|
|
@@ -223,7 +231,7 @@ export const MDXTemplate = ({
|
|
|
223
231
|
onClick={() => trackEvent('tab_click', 'click_event', source.toUpperCase())}
|
|
224
232
|
>
|
|
225
233
|
<Link className="pf-c-tabs__link" to={`${path}${index === 0 ? '' : '/' + source}`}>
|
|
226
|
-
{
|
|
234
|
+
{tabNames[source]}
|
|
227
235
|
</Link>
|
|
228
236
|
</li>
|
|
229
237
|
))}
|
|
@@ -7,6 +7,8 @@ section: extensions
|
|
|
7
7
|
id: My extension
|
|
8
8
|
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
|
|
9
9
|
source: design-guidelines
|
|
10
|
+
# Optional custom text to display in tab in place of source
|
|
11
|
+
tabName: My custom tab-name
|
|
10
12
|
---
|
|
11
13
|
|
|
12
14
|
Design guidelines intro
|
|
@@ -7,6 +7,8 @@ section: extensions
|
|
|
7
7
|
id: My extension
|
|
8
8
|
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
|
|
9
9
|
source: react
|
|
10
|
+
# Optional custom text to display in tab in place of source
|
|
11
|
+
tabName: My custom tab-name
|
|
10
12
|
# If you use typescript, the name of the interface to display props for
|
|
11
13
|
# These are found through the sourceProps function provdided in patternfly-docs.source.js
|
|
12
14
|
# Can also pass object { component: string, source: string } allowing to specify the source
|