mirror of
https://github.com/SrIzan10/starlight-typedoc.git
synced 2026-05-01 11:05:15 +00:00
fix: fixes an issue preventing to use badges with generated sidebar groups
This commit is contained in:
@@ -30,7 +30,7 @@ export default defineConfig({
|
||||
sidebar: [
|
||||
{
|
||||
label: 'Bar Content',
|
||||
items: [barTypeDocSidebarGroup],
|
||||
items: [{ ...barTypeDocSidebarGroup, badge: 'generated' }],
|
||||
},
|
||||
{
|
||||
label: 'Foo Content',
|
||||
|
||||
@@ -43,7 +43,7 @@ export function getSidebarFromReflections(
|
||||
|
||||
function replaceSidebarGroupPlaceholder(group: SidebarManualGroup): SidebarGroup {
|
||||
if (group.label === sidebarGroupPlaceholder.label) {
|
||||
return sidebarGroup
|
||||
return group.badge ? { ...sidebarGroup, badge: group.badge } : sidebarGroup
|
||||
}
|
||||
|
||||
if (isSidebarManualGroup(group)) {
|
||||
@@ -252,6 +252,13 @@ interface SidebarManualGroup {
|
||||
collapsed?: boolean
|
||||
items: (LinkItem | SidebarGroup)[]
|
||||
label: string
|
||||
badge?:
|
||||
| string
|
||||
| {
|
||||
text: string
|
||||
variant: 'note' | 'danger' | 'success' | 'caution' | 'tip' | 'default'
|
||||
}
|
||||
| undefined
|
||||
}
|
||||
|
||||
interface LinkItem {
|
||||
|
||||
@@ -75,7 +75,7 @@ export class DocPage {
|
||||
for (const category of await list.locator('> li > details').all()) {
|
||||
items.push({
|
||||
collapsed: !(await category.getAttribute('open')),
|
||||
label: await category.locator(`> summary > div > span`).textContent(),
|
||||
label: await category.locator(`> summary > div > span:not(.sl-badge)`).textContent(),
|
||||
items: await this.#getTypeDocSidebarChildrenItems(category.locator('> ul')),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,3 +42,11 @@ test('should generate the proper items for for multiple plugins with different c
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
test('should support having a badge', async ({ docPage }) => {
|
||||
docPage.useMultiplePlugins()
|
||||
|
||||
await docPage.goto('api-multiple-plugins-bar/classes/bar')
|
||||
|
||||
await expect(docPage.page.locator('.sl-badge:has-text("generated")')).toBeVisible()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user