@brillout/docpress 0.8.11 → 0.8.13
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/Layout.tsx +2 -0
- package/MenuModal.tsx +2 -5
- package/config/resolveHeadingsData.ts +2 -6
- package/dist/Layout.d.ts +11 -0
- package/dist/Layout.js +235 -0
- package/dist/Links.d.ts +6 -0
- package/dist/Links.js +58 -0
- package/dist/MenuModal.d.ts +7 -0
- package/dist/MenuModal.js +123 -0
- package/dist/autoScrollNav.d.ts +3 -0
- package/dist/autoScrollNav.js +35 -0
- package/dist/components/EditPageNote.d.ts +7 -0
- package/dist/components/EditPageNote.js +11 -0
- package/dist/config/resolveHeadingsData.d.ts +0 -1
- package/dist/config/resolveHeadingsData.js +2 -6
- package/dist/config/resolvePageContext.d.ts +0 -1
- package/dist/docsearch/SearchLink.d.ts +4 -0
- package/dist/docsearch/SearchLink.js +26 -0
- package/dist/docsearch/toggleDocsearchModal.d.ts +4 -0
- package/dist/docsearch/toggleDocsearchModal.js +26 -0
- package/dist/navigation/Navigation.d.ts +2 -1
- package/dist/navigation/Navigation.js +69 -38
- package/dist/renderer/determineColumnEntries.d.ts +3 -0
- package/dist/renderer/{getStyleColumnLayout.js → determineColumnEntries.js} +16 -64
- package/dist/utils/PassTrough.d.ts +3 -0
- package/dist/utils/PassTrough.js +6 -0
- package/dist/utils/getViewportWidth.d.ts +1 -0
- package/dist/utils/getViewportWidth.js +4 -0
- package/navigation/Navigation.css +2 -1
- package/navigation/Navigation.tsx +94 -63
- package/package.json +1 -1
- package/renderer/{getStyleColumnLayout.ts → determineColumnEntries.ts} +20 -90
- package/renderer/onRenderHtml.tsx +0 -4
- package/utils/getViewportWidth.ts +4 -0
- package/dist/renderer/getStyleColumnLayout.d.ts +0 -7
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { determineColumnLayoutEntries }
|
|
1
|
+
export { determineColumnEntries }
|
|
3
2
|
|
|
4
|
-
//
|
|
5
|
-
// - https://
|
|
6
|
-
// - https://stackoverflow.com/questions/25446921/get-flexbox-column-wrap-to-use-full-width-and-minimize-height
|
|
7
|
-
// - https://stackoverflow.com/questions/74873283/how-to-create-a-css-grid-with-3-columns-having-column-flow
|
|
8
|
-
// - https://stackoverflow.com/questions/50693793/3-columns-grid-top-to-bottom-using-grid-css
|
|
9
|
-
// - https://stackoverflow.com/questions/9119347/html-css-vertical-flow-layout-columnar-style-how-to-implement
|
|
10
|
-
// - https://stackoverflow.com/questions/27119691/how-to-start-a-new-column-in-flex-column-wrap-layout
|
|
11
|
-
// - https://stackoverflow.com/questions/45264354/is-it-possible-to-place-more-than-one-element-into-a-css-grid-cell-without-overl/49047281#49047281
|
|
3
|
+
// A CSS-only solution doesn't seem to exist.
|
|
4
|
+
// - https://github.com/brillout/docpress/blob/2e41d8b9df098ff8312b02f7e9d41a202548e2b9/src/renderer/getStyleColumnLayout.ts#L4-L26
|
|
12
5
|
|
|
13
6
|
import { type NavItemAll } from '../navigation/Navigation'
|
|
14
|
-
import { css } from '../utils/css'
|
|
15
7
|
import { assert, assertUsage, isBrowser } from '../utils/server'
|
|
16
8
|
assert(!isBrowser())
|
|
17
|
-
const columnWidthMin = 300
|
|
18
|
-
const columnWidthMax = 350
|
|
19
9
|
|
|
20
10
|
type NavItemWithLength = NavItemAll & { numberOfHeadings: number | null }
|
|
21
|
-
function
|
|
11
|
+
function determineColumnEntries(navItems: NavItemAll[]): undefined {
|
|
22
12
|
const navItemsWithLength: NavItemWithLength[] = navItems.map((navItem) => ({
|
|
23
13
|
...navItem,
|
|
24
14
|
numberOfHeadings: navItem.level === 1 || navItem.level === 4 ? 0 : null,
|
|
@@ -46,8 +36,9 @@ function determineColumnLayoutEntries(navItems: NavItemAll[]): { columnLayouts:
|
|
|
46
36
|
}
|
|
47
37
|
})
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
type ColumnEntry = { navItemLeader: NavItemAll; numberOfEntries: number }
|
|
40
|
+
const columnLayouts: ColumnEntry[][] = []
|
|
41
|
+
let columnEntries: ColumnEntry[] = []
|
|
51
42
|
let isFullWidth: boolean | undefined
|
|
52
43
|
navItemsWithLength.forEach((navItem, i) => {
|
|
53
44
|
let isFullWidthBegin = false
|
|
@@ -56,8 +47,8 @@ function determineColumnLayoutEntries(navItems: NavItemAll[]): { columnLayouts:
|
|
|
56
47
|
isFullWidth = !!navItem.menuModalFullWidth
|
|
57
48
|
if (isFullWidth) isFullWidthBegin = true
|
|
58
49
|
if (isFullWidthPrevious !== undefined && isFullWidthPrevious !== isFullWidth) {
|
|
59
|
-
columnLayouts.push(
|
|
60
|
-
|
|
50
|
+
columnLayouts.push(columnEntries)
|
|
51
|
+
columnEntries = []
|
|
61
52
|
}
|
|
62
53
|
}
|
|
63
54
|
const navItemPrevious = navItemsWithLength[i - 1]
|
|
@@ -82,85 +73,24 @@ function determineColumnLayoutEntries(navItems: NavItemAll[]): { columnLayouts:
|
|
|
82
73
|
assert(navItemNext.numberOfHeadings)
|
|
83
74
|
numberOfHeadings = navItemNext.numberOfHeadings
|
|
84
75
|
}
|
|
85
|
-
|
|
86
|
-
navItems[i].isColumnLayoutElement = true
|
|
76
|
+
columnEntries.push({ navItemLeader: navItems[i], numberOfEntries: numberOfHeadings })
|
|
87
77
|
}
|
|
88
78
|
})
|
|
89
|
-
|
|
79
|
+
assert(columnEntries!)
|
|
80
|
+
columnLayouts.push(columnEntries)
|
|
90
81
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
'\n' +
|
|
97
|
-
css`
|
|
98
|
-
.column-layout-entry {
|
|
99
|
-
break-before: avoid;
|
|
100
|
-
}
|
|
101
|
-
`
|
|
102
|
-
style += '\n'
|
|
103
|
-
columnLayouts.forEach((columns, i) => {
|
|
104
|
-
for (let numberOfColumns = columns.length; numberOfColumns >= 1; numberOfColumns--) {
|
|
105
|
-
let styleGivenNumberOfColumns: string[] = []
|
|
106
|
-
styleGivenNumberOfColumns.push(
|
|
107
|
-
css`
|
|
108
|
-
.column-layout-${i} {
|
|
109
|
-
column-count: ${numberOfColumns};
|
|
110
|
-
max-width: min(100%, ${columnWidthMax * numberOfColumns}px);
|
|
111
|
-
}
|
|
112
|
-
`,
|
|
82
|
+
columnLayouts.forEach((columnEntries) => {
|
|
83
|
+
for (let numberOfColumns = columnEntries.length; numberOfColumns >= 1; numberOfColumns--) {
|
|
84
|
+
const columnsIdMap = determineColumns(
|
|
85
|
+
columnEntries.map((columnEntry) => columnEntry.numberOfEntries),
|
|
86
|
+
numberOfColumns,
|
|
113
87
|
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!columnBreakPoint) return
|
|
118
|
-
styleGivenNumberOfColumns.push(
|
|
119
|
-
css`
|
|
120
|
-
.column-layout-${i} .column-layout-entry:nth-child(${columnUngroupedId + 1}) {
|
|
121
|
-
break-before: column;
|
|
122
|
-
padding-top: 36px;
|
|
123
|
-
}
|
|
124
|
-
`,
|
|
125
|
-
)
|
|
88
|
+
columnEntries.forEach((columnEntry, i) => {
|
|
89
|
+
columnEntry.navItemLeader.isColumnEntry ??= {}
|
|
90
|
+
columnEntry.navItemLeader.isColumnEntry[numberOfColumns] = columnsIdMap[i]
|
|
126
91
|
})
|
|
127
|
-
{
|
|
128
|
-
assert(styleGivenNumberOfColumns.length > 0)
|
|
129
|
-
const getMaxWidth = (columns: number) => (columns + 1) * columnWidthMin - 1
|
|
130
|
-
const isFirst = numberOfColumns === 1
|
|
131
|
-
const isLast = numberOfColumns === columns.length
|
|
132
|
-
const query = [
|
|
133
|
-
!isFirst && `(min-width: ${getMaxWidth(numberOfColumns - 1) + 1}px)`,
|
|
134
|
-
!isLast && `(max-width: ${getMaxWidth(numberOfColumns)}px)`,
|
|
135
|
-
]
|
|
136
|
-
.filter(Boolean)
|
|
137
|
-
.join(' and ')
|
|
138
|
-
if (query) {
|
|
139
|
-
styleGivenNumberOfColumns = [`@container ${query} {`, ...styleGivenNumberOfColumns, `}`]
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
style += styleGivenNumberOfColumns.join('\n') + '\n'
|
|
143
92
|
}
|
|
144
93
|
})
|
|
145
|
-
return style
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function determineColumnBreakPoints(columnsIdMap: number[]): boolean[] {
|
|
149
|
-
assert(columnsIdMap[0] === 0)
|
|
150
|
-
let columnGroupedIdBefore = 0
|
|
151
|
-
const columnBreakPoints = columnsIdMap.map((columnGroupedId) => {
|
|
152
|
-
assert(
|
|
153
|
-
[
|
|
154
|
-
//
|
|
155
|
-
columnGroupedIdBefore,
|
|
156
|
-
columnGroupedIdBefore + 1,
|
|
157
|
-
].includes(columnGroupedId),
|
|
158
|
-
)
|
|
159
|
-
const val = columnGroupedId !== columnGroupedIdBefore
|
|
160
|
-
columnGroupedIdBefore = columnGroupedId
|
|
161
|
-
return val
|
|
162
|
-
})
|
|
163
|
-
return columnBreakPoints
|
|
164
94
|
}
|
|
165
95
|
|
|
166
96
|
function determineColumns(columnsUnmerged: number[], numberOfColumns: number): number[] {
|
|
@@ -6,7 +6,6 @@ import { assert } from '../utils/server'
|
|
|
6
6
|
import type { PageContextResolved } from '../config/resolvePageContext'
|
|
7
7
|
import { getPageElement } from './getPageElement'
|
|
8
8
|
import type { OnRenderHtmlAsync } from 'vike/types'
|
|
9
|
-
import { getStyleColumnLayout } from './getStyleColumnLayout'
|
|
10
9
|
|
|
11
10
|
const onRenderHtml: OnRenderHtmlAsync = async (
|
|
12
11
|
pageContext,
|
|
@@ -16,8 +15,6 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
|
|
|
16
15
|
|
|
17
16
|
const page = getPageElement(pageContext, pageContextResolved)
|
|
18
17
|
|
|
19
|
-
const styleMenuModalLayout = getStyleColumnLayout(pageContextResolved.columnLayouts)
|
|
20
|
-
|
|
21
18
|
const descriptionTag = pageContextResolved.isLandingPage
|
|
22
19
|
? dangerouslySkipEscape(`<meta name="description" content="${pageContextResolved.meta.tagline}" />`)
|
|
23
20
|
: ''
|
|
@@ -33,7 +30,6 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
|
|
|
33
30
|
${descriptionTag}
|
|
34
31
|
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
|
|
35
32
|
${getOpenGraphTags(pageContext.urlPathname, pageContextResolved.documentTitle, pageContextResolved.meta)}
|
|
36
|
-
<style>${dangerouslySkipEscape(styleMenuModalLayout)}</style>
|
|
37
33
|
<meta name="docsearch:category" content="${pageContextResolved.activeCategory}" />
|
|
38
34
|
</head>
|
|
39
35
|
<body>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { getStyleColumnLayout };
|
|
2
|
-
export { determineColumnLayoutEntries };
|
|
3
|
-
import { type NavItemAll } from '../navigation/Navigation';
|
|
4
|
-
declare function determineColumnLayoutEntries(navItems: NavItemAll[]): {
|
|
5
|
-
columnLayouts: number[][];
|
|
6
|
-
};
|
|
7
|
-
declare function getStyleColumnLayout(columnLayouts: number[][]): string;
|