Skip to content

Commit

Permalink
Make sure URLs are always slugified
Browse files Browse the repository at this point in the history
  • Loading branch information
victorhmp committed Sep 3, 2019
1 parent c0c608f commit e5a29a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion react/ComponentsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const ComponentsGrid: FC<OuterProps> = ({ ComponentsListQuery }) => {
link={`/docs/components/${params.category}/${
component.appName
}/${(component.file &&
removeFileExtension(component.file)) ||
slug(removeFileExtension(component.file))) ||
''}`}
/>
</div>
Expand Down
11 changes: 10 additions & 1 deletion react/hooks/useApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ export function useApp() {

const { file } = params
const { appName, major } = useAppVersionState()
const fileName = file || 'README'
const fileName = file ? slugToPascal(file) : 'README'

const finalAppName = `${appName}@${major}`

return { appName: finalAppName, fileName }
}

function slugToPascal(slug: string) {
const result = slug
.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join('')

return result
}

0 comments on commit e5a29a0

Please sign in to comment.