11import { Fragment , onMount , Show , Slot , useState } from '@builder.io/mitosis' ;
22import DBLink from '../../components/link/link.lite' ;
3-
4- export interface PatternhubProps {
5- /**
6- * Used for Patternhub
7- */
8- isPatternhub ?: boolean ;
9- }
3+ import { PatternhubProps } from '../model' ;
104
115type Props = {
126 title ?: string ;
@@ -26,35 +20,41 @@ export default function ContainerWrapperShowcase(props: Props) {
2620 const [ hidden , setHidden ] = useState < boolean > ( false ) ;
2721
2822 onMount ( ( ) => {
29- const hash = window . location . hash ;
30- const queryString = hash . includes ( '?' ) ? hash . split ( '?' ) [ 1 ] : '' ;
31- const params = new URLSearchParams (
32- window . location . search || queryString
33- ) ;
23+ if ( typeof window !== 'undefined' ) {
24+ const hash = window . location . hash ;
25+ const queryString = hash . includes ( '?' ) ? hash . split ( '?' ) [ 1 ] : '' ;
26+ const params = new URLSearchParams (
27+ window . location . search || queryString
28+ ) ;
3429
35- setHidden ( Boolean ( params . get ( 'page' ) ) ) ;
30+ setHidden ( Boolean ( params . get ( 'page' ) ) ) ;
31+ }
3632 } ) ;
3733
3834 function getSourceFilePath ( ) : string | undefined {
3935 if ( ! props . title ) return ;
4036
4137 const componentName = props . title
42- . replace ( / ^ D B / , '' )
38+ ? .replace ( / ^ D B / , '' )
4339 . replaceAll ( / ( [ A - Z ] ) / g, ( match , letter , index ) =>
4440 index > 0 ? `-${ letter . toLowerCase ( ) } ` : letter . toLowerCase ( )
4541 ) ;
4642
4743 if ( componentName && / ^ [ a - z ] + ( - [ a - z ] + ) * $ / . test ( componentName ) ) {
4844 return `packages/components/src/components/${ componentName } /${ componentName } .lite.tsx` ;
4945 }
46+
47+ return ;
5048 }
5149
5250 function getGitHubSourceUrl ( ) : string | undefined {
5351 const filePath = getSourceFilePath ( ) ;
5452 if ( ! filePath ) return ;
5553
5654 const targetBranch =
57- process . env . GITHUB_BRANCH ?? process . env . BRANCH_NAME ?? 'main' ;
55+ process . env [ 'GITHUB_BRANCH' ] ??
56+ process . env [ 'BRANCH_NAME' ] ??
57+ 'main' ;
5858
5959 return `https://github.com/db-ux-design-system/core-web/blob/${ targetBranch } /${ filePath } ` ;
6060 }
0 commit comments