File tree Expand file tree Collapse file tree 4 files changed +26
-17
lines changed Expand file tree Collapse file tree 4 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
1919import { getDevDocsFrontMatter , getDocsFrontMatter , getFileBySlug } from 'sentry-docs/mdx' ;
2020import { mdxComponents } from 'sentry-docs/mdxComponents' ;
2121import { setServerContext } from 'sentry-docs/serverContext' ;
22+ import { VERSION_INDICATOR } from 'sentry-docs/versioning' ;
2223
2324export async function generateStaticParams ( ) {
2425 const docs = await ( isDeveloperDocs ? getDevDocsFrontMatter ( ) : getDocsFrontMatter ( ) ) ;
@@ -112,10 +113,13 @@ export default async function Page({params}: {params: {path?: string[]}}) {
112113 // collect versioned files
113114 const versions = ( await getDocsFrontMatter ( ) )
114115 . filter ( ( { slug} ) => {
115- return slug . includes ( '__v' ) && slug . includes ( pageNode . path . split ( '__v' ) [ 0 ] ) ;
116+ return (
117+ slug . includes ( VERSION_INDICATOR ) &&
118+ slug . includes ( pageNode . path . split ( VERSION_INDICATOR ) [ 0 ] )
119+ ) ;
116120 } )
117121 . map ( ( { slug} ) => {
118- const segments = slug . split ( '__v' ) ;
122+ const segments = slug . split ( VERSION_INDICATOR ) ;
119123 return segments [ segments . length - 1 ] ;
120124 } ) ;
121125
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import {Fragment} from 'react';
22
33import { serverContext } from 'sentry-docs/serverContext' ;
44import { sortPages } from 'sentry-docs/utils' ;
5+ import { VERSION_INDICATOR } from 'sentry-docs/versioning' ;
56
67import { NavChevron } from './sidebar/navChevron' ;
78import { SidebarLink } from './sidebarLink' ;
@@ -35,19 +36,22 @@ export const toTree = (nodeList: Node[]): EntityTree[] => {
3536 . sort ( ( a , b ) => a . path . localeCompare ( b . path ) )
3637 . forEach ( node => {
3738 let curPath = '' ;
38- node . path . split ( '/' ) . reduce ( ( r , name : string ) => {
39- curPath += `${ name } /` ;
40- if ( ! r [ name ] ) {
41- r [ name ] = { result : [ ] } ;
42- r . result . push ( {
43- name,
44- children : r [ name ] . result ,
45- node : curPath === node . path ? node : null ,
46- } ) ;
47- }
48-
49- return r [ name ] ;
50- } , level ) ;
39+ // hide versioned pages in sidebar
40+ if ( ! node . path . includes ( VERSION_INDICATOR ) ) {
41+ node . path . split ( '/' ) . reduce ( ( r , name : string ) => {
42+ curPath += `${ name } /` ;
43+ if ( ! r [ name ] ) {
44+ r [ name ] = { result : [ ] } ;
45+ r . result . push ( {
46+ name,
47+ children : r [ name ] . result ,
48+ node : curPath === node . path ? node : null ,
49+ } ) ;
50+ }
51+
52+ return r [ name ] ;
53+ } , level ) ;
54+ }
5155 } ) ;
5256
5357 result . length ; // result[0] is undefined without this. wat
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ import {ChevronDownIcon} from '@radix-ui/react-icons';
44import * as RadixSelect from '@radix-ui/react-select' ;
55import { usePathname , useRouter } from 'next/navigation' ;
66
7+ import { VERSION_INDICATOR } from 'sentry-docs/versioning' ;
8+
79import styles from './style.module.scss' ;
810
911const stripTrailingSlash = ( url : string ) => {
1012 return url . replace ( / \/ $ / , '' ) ;
1113} ;
1214
13- const VERSION_INDICATOR = '__v' ;
14-
1515export function VersionSelector ( { versions} : { versions : string [ ] } ) {
1616 const availableVersions = [ 'latest' , ...versions ] ;
1717 const router = useRouter ( ) ;
Original file line number Diff line number Diff line change 1+ export const VERSION_INDICATOR = '__v' ;
You can’t perform that action at this time.
0 commit comments