mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
docs: indent ToC based on heading levels (#475)
This commit is contained in:
@@ -13,12 +13,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.inner {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
@@ -27,7 +21,6 @@
|
|||||||
border-left: 1px solid transparent;
|
border-left: 1px solid transparent;
|
||||||
padding: 8px var(--mantine-spacing-md);
|
padding: 8px var(--mantine-spacing-md);
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
padding-left: calc(1 * var(--mantine-spacing-lg));
|
|
||||||
border-top-right-radius: var(--mantine-radius-sm);
|
border-top-right-radius: var(--mantine-radius-sm);
|
||||||
border-bottom-right-radius: var(--mantine-radius-sm);
|
border-bottom-right-radius: var(--mantine-radius-sm);
|
||||||
|
|
||||||
@@ -72,6 +65,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inner {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
margin-left: var(--mantine-spacing-md);
|
margin-left: var(--mantine-spacing-md);
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ export function TableOfContents(): JSX.Element | null {
|
|||||||
key={heading.id}
|
key={heading.id}
|
||||||
component="a"
|
component="a"
|
||||||
fz="sm"
|
fz="sm"
|
||||||
px={8}
|
|
||||||
w="fit-content"
|
w="fit-content"
|
||||||
py={4}
|
py={4}
|
||||||
className={classes.link}
|
className={classes.link}
|
||||||
@@ -108,7 +107,9 @@ export function TableOfContents(): JSX.Element | null {
|
|||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
handleHeadingClick(e, heading.id)
|
handleHeadingClick(e, heading.id)
|
||||||
}}
|
}}
|
||||||
__vars={{ '--toc-link-offset': `${heading.depth - 1}` }}
|
style={{
|
||||||
|
paddingLeft: `calc(${heading.order - 1} * var(--mantine-spacing-md))`,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{heading.content}
|
{heading.content}
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Component inspired by: https://github.com/mantinedev/mantine/tree/master/apps/mantine.dev/src/components/TableOfContents
|
* Component inspired by: https://github.com/mantinedev/mantine/tree/master/apps/mantine.dev/src/components/TableOfContents
|
||||||
*/
|
*/
|
||||||
export interface Heading {
|
export interface Heading {
|
||||||
depth: number
|
order: number
|
||||||
content: string
|
content: string
|
||||||
id: string
|
id: string
|
||||||
getNode: () => HTMLHeadingElement
|
getNode: () => HTMLHeadingElement
|
||||||
@@ -23,11 +23,11 @@ function getHeadingsData(headings: Array<HTMLHeadingElement>): Array<Heading> {
|
|||||||
const result: Array<Heading> = []
|
const result: Array<Heading> = []
|
||||||
|
|
||||||
for (const heading of headings) {
|
for (const heading of headings) {
|
||||||
const depth = parseInt(heading.getAttribute('data-order') || '1', 10)
|
const order = parseInt(heading.getAttribute('data-order') || '1', 10)
|
||||||
|
|
||||||
if (depth <= 3 && heading.id) {
|
if (order <= 3 && heading.id) {
|
||||||
result.push({
|
result.push({
|
||||||
depth,
|
order,
|
||||||
content: getCleanedText(heading),
|
content: getCleanedText(heading),
|
||||||
id: heading.id,
|
id: heading.id,
|
||||||
getNode: () =>
|
getNode: () =>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ Useful for extending vite's functionality
|
|||||||
|
|
||||||
The following options configure the server.
|
The following options configure the server.
|
||||||
|
|
||||||
### server.host
|
### `server.host`
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
- Default: `'localhost'`
|
- Default: `'localhost'`
|
||||||
|
|||||||
Reference in New Issue
Block a user