File tree Expand file tree Collapse file tree 5 files changed +14
-6
lines changed
packages/theme-nonepress/src Expand file tree Collapse file tree 5 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ export default function MDXPage(props: Props): JSX.Element {
2929 } = frontMatter ;
3030
3131 const sidebarCustomProps = frontMatter . sidebar_custom_props as {
32- sidebar_id : string ;
32+ sidebar_id ?: string ;
33+ sidebar_version ?: string ;
3334 } ;
3435 const sidebarId = sidebarCustomProps ?. sidebar_id ;
36+ const sidebarVersion = sidebarCustomProps ?. sidebar_version ;
3537
3638 return (
3739 < HtmlClassNameProvider
@@ -56,6 +58,7 @@ export default function MDXPage(props: Props): JSX.Element {
5658 minHeadingLevel = { tocMinHeadingLevel ! }
5759 maxHeadingLevel = { tocMaxHeadingLevel ! }
5860 sidebarId = { sidebarId }
61+ sidebarVersion = { sidebarVersion }
5962 toc = { toc }
6063 >
6164 < article className = "prose max-w-full" >
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ import "./styles.css";
1818
1919export default function Sidebar ( {
2020 className,
21- sidebarId = "" ,
21+ sidebarId,
22+ sidebarVersion,
2223} : Props ) : JSX . Element | null {
2324 const { pathname } = useLocation ( ) ;
2425 const windowSize = useWindowSize ( ) ;
@@ -30,8 +31,8 @@ export default function Sidebar({
3031
3132 const docsVersionCandidate = useDocsVersionCandidates ( ) ;
3233 const sidebarContent = useVersionedSidebar (
33- docsVersionCandidate [ 0 ] . name ,
34- sidebarId ,
34+ sidebarVersion || docsVersionCandidate [ 0 ] . name ,
35+ sidebarId || "" ,
3536 ) ;
3637
3738 if ( isMobile || ! sidebarContent || sidebarContent . length === 0 ) {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export default function Page({
1414 hideTableOfContents = false ,
1515 reduceContentWidth = true ,
1616 sidebarId,
17+ sidebarVersion,
1718 toc,
1819 minHeadingLevel,
1920 maxHeadingLevel,
@@ -24,7 +25,7 @@ export default function Page({
2425 < div className = "page" >
2526 { /* sidebar */ }
2627 { ! hideSidebar && (
27- < Sidebar sidebarId = { sidebarId } className = "page-sidebar" />
28+ < Sidebar sidebarId = { sidebarId } sidebarVersion = { sidebarVersion } className = "page-sidebar" />
2829 ) }
2930 { /* main */ }
3031 < main className = "page-main" >
Original file line number Diff line number Diff line change @@ -1519,6 +1519,7 @@ declare module "@theme/Page" {
15191519 readonly hideTableOfContents ?: boolean ;
15201520 readonly reduceContentWidth ?: boolean ;
15211521 readonly sidebarId ?: string ;
1522+ readonly sidebarVersion ?: string ;
15221523 readonly toc ?: readonly TOCItem [ ] ;
15231524 readonly minHeadingLevel ?: number ;
15241525 readonly maxHeadingLevel ?: number ;
@@ -1618,6 +1619,7 @@ declare module "@theme/Page/Sidebar" {
16181619 export interface Props {
16191620 readonly className ?: string ;
16201621 readonly sidebarId ?: string ;
1622+ readonly sidebarVersion ?: string ;
16211623 }
16221624
16231625 export default function Sidebar ( props : Props ) : JSX . Element | null ;
Original file line number Diff line number Diff line change @@ -78,7 +78,8 @@ export default async function createConfigAsync() {
7878 changelogHeader : `description: Changelog
7979toc_max_heading_level: 2
8080sidebar_custom_props:
81- sidebar_id: changelog` ,
81+ sidebar_id: changelog
82+ sidebar_version: current` ,
8283 } satisfies ChangelogOptions ,
8384 ] ,
8485 ] ,
You can’t perform that action at this time.
0 commit comments