mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-25 21:09:06 +02:00
Add subgroups to docs utils nav
This commit is contained in:
@@ -117,25 +117,27 @@
|
|||||||
icon_color: red
|
icon_color: red
|
||||||
pages:
|
pages:
|
||||||
- title: API
|
- title: API
|
||||||
- title: Align content
|
|
||||||
- title: Align items
|
|
||||||
- title: Align self
|
|
||||||
- title: Aspect ratio
|
- title: Aspect ratio
|
||||||
- title: Background
|
- title: Background
|
||||||
- title: Border
|
- title: Border
|
||||||
- title: Border radius
|
- title: Border radius
|
||||||
- title: Colors
|
- title: Colors
|
||||||
- title: Display
|
- title: Display
|
||||||
- title: Flex
|
- group: Flex & Grid
|
||||||
|
pages:
|
||||||
|
- title: Align content
|
||||||
|
- title: Align items
|
||||||
|
- title: Align self
|
||||||
|
- title: Flex
|
||||||
|
- title: Justify content
|
||||||
|
- title: Justify items
|
||||||
|
- title: Place items
|
||||||
- title: Float
|
- title: Float
|
||||||
- title: Interactions
|
- title: Interactions
|
||||||
- title: Justify content
|
|
||||||
- title: Justify items
|
|
||||||
- title: Link
|
- title: Link
|
||||||
- title: Object fit
|
- title: Object fit
|
||||||
- title: Opacity
|
- title: Opacity
|
||||||
- title: Overflow
|
- title: Overflow
|
||||||
- title: Place items
|
|
||||||
- title: Position
|
- title: Position
|
||||||
- title: Shadows
|
- title: Shadows
|
||||||
- title: Sizing
|
- title: Sizing
|
||||||
|
@@ -29,8 +29,50 @@ const sidebar = getData('sidebar')
|
|||||||
{group.title}
|
{group.title}
|
||||||
</strong>
|
</strong>
|
||||||
<ul class="list-unstyled fw-normal pb-2 small">
|
<ul class="list-unstyled fw-normal pb-2 small">
|
||||||
{group.pages?.map((page) => {
|
{group.pages?.map((item: any) => {
|
||||||
const docSlug = getSlug(page.title)
|
// Handle sub-groups
|
||||||
|
if (item.group && item.pages) {
|
||||||
|
return (
|
||||||
|
<li class="mb-2">
|
||||||
|
<div class="bd-links-subgroup fw-semibold mt-3">
|
||||||
|
{item.group}
|
||||||
|
</div>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
{item.pages.map((page: any) => {
|
||||||
|
const docSlug = getSlug(page.title)
|
||||||
|
const unversionedPageSlug = `${groupSlug}/${docSlug}`
|
||||||
|
|
||||||
|
const url = `/docs/${getConfig().docs_version}/${unversionedPageSlug}`
|
||||||
|
const active = Astro.params.slug === unversionedPageSlug
|
||||||
|
|
||||||
|
const generatedPage = docsPages.find((page) => page.slug === unversionedPageSlug)
|
||||||
|
|
||||||
|
// This test should not be necessary, see comments for `getSlug()` in `src/libs/utils.ts`.
|
||||||
|
if (!generatedPage) {
|
||||||
|
throw new Error(
|
||||||
|
`The page '${page.title}' referenced in 'site/data/sidebar.yml' does not exist at '${url}'.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href={url}
|
||||||
|
class:list={['bd-links-link d-inline-block rounded', { active }]}
|
||||||
|
aria-current={active ? 'page' : undefined}
|
||||||
|
>
|
||||||
|
{page.title}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle regular pages
|
||||||
|
const docSlug = getSlug(item.title)
|
||||||
const unversionedPageSlug = `${groupSlug}/${docSlug}`
|
const unversionedPageSlug = `${groupSlug}/${docSlug}`
|
||||||
|
|
||||||
const url = `/docs/${getConfig().docs_version}/${unversionedPageSlug}`
|
const url = `/docs/${getConfig().docs_version}/${unversionedPageSlug}`
|
||||||
@@ -41,7 +83,7 @@ const sidebar = getData('sidebar')
|
|||||||
// This test should not be necessary, see comments for `getSlug()` in `src/libs/utils.ts`.
|
// This test should not be necessary, see comments for `getSlug()` in `src/libs/utils.ts`.
|
||||||
if (!generatedPage) {
|
if (!generatedPage) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The page '${page.title}' referenced in 'site/data/sidebar.yml' does not exist at '${url}'.`
|
`The page '${item.title}' referenced in 'site/data/sidebar.yml' does not exist at '${url}'.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +94,7 @@ const sidebar = getData('sidebar')
|
|||||||
class:list={['bd-links-link d-inline-block rounded', { active }]}
|
class:list={['bd-links-link d-inline-block rounded', { active }]}
|
||||||
aria-current={active ? 'page' : undefined}
|
aria-current={active ? 'page' : undefined}
|
||||||
>
|
>
|
||||||
{page.title}
|
{item.title}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
@@ -82,7 +82,11 @@ const dataDefinitions = {
|
|||||||
icon_color: z.string().optional(),
|
icon_color: z.string().optional(),
|
||||||
pages: z
|
pages: z
|
||||||
.object({
|
.object({
|
||||||
title: z.string()
|
title: z.string().optional(),
|
||||||
|
group: z.string().optional(),
|
||||||
|
pages: z.object({
|
||||||
|
title: z.string()
|
||||||
|
}).array().optional()
|
||||||
})
|
})
|
||||||
.array()
|
.array()
|
||||||
.optional()
|
.optional()
|
||||||
@@ -117,7 +121,7 @@ let data = new Map<DataType, z.infer<DataSchema>>()
|
|||||||
export function getData<TType extends DataType>(type: TType): z.infer<(typeof dataDefinitions)[TType]> {
|
export function getData<TType extends DataType>(type: TType): z.infer<(typeof dataDefinitions)[TType]> {
|
||||||
if (data.has(type)) {
|
if (data.has(type)) {
|
||||||
// Returns the data if it has already been loaded.
|
// Returns the data if it has already been loaded.
|
||||||
return data.get(type)
|
return data.get(type) as z.infer<(typeof dataDefinitions)[TType]>
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataPath = `./site/data/${type}.yml`
|
const dataPath = `./site/data/${type}.yml`
|
||||||
@@ -127,7 +131,7 @@ export function getData<TType extends DataType>(type: TType): z.infer<(typeof da
|
|||||||
const rawData = yaml.load(fs.readFileSync(dataPath, 'utf8'))
|
const rawData = yaml.load(fs.readFileSync(dataPath, 'utf8'))
|
||||||
|
|
||||||
// Parse the data using the data schema to validate its content and get back a fully typed data object.
|
// Parse the data using the data schema to validate its content and get back a fully typed data object.
|
||||||
const parsedData = dataDefinitions[type].parse(rawData)
|
const parsedData = dataDefinitions[type].parse(rawData) as z.infer<(typeof dataDefinitions)[TType]>
|
||||||
|
|
||||||
// Cache the data.
|
// Cache the data.
|
||||||
data.set(type, parsedData)
|
data.set(type, parsedData)
|
||||||
|
@@ -28,6 +28,11 @@
|
|||||||
color: var(--bs-emphasis-color);
|
color: var(--bs-emphasis-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bd-links-subgroup {
|
||||||
|
margin-left: 1.625rem;
|
||||||
|
color: var(--bs-emphasis-color);
|
||||||
|
}
|
||||||
|
|
||||||
.bd-links-nav {
|
.bd-links-nav {
|
||||||
// @include media-breakpoint-down(lg) {
|
// @include media-breakpoint-down(lg) {
|
||||||
// font-size: .875rem;
|
// font-size: .875rem;
|
||||||
|
Reference in New Issue
Block a user