Skip to content

Commit

Permalink
chore: fix file upload paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Feb 15, 2024
1 parent b145951 commit 0f8fe5c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
10 changes: 10 additions & 0 deletions apps/website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ let config = {
destination: '/docs/components/authentication/:path*',
permanent: true,
},
{
source: '/docs/components/file-upload',
destination: '/docs/components/forms/file-upload',
permanent: true,
},
{
source: '/docs/components/file-upload/:path*',
destination: '/docs/components/forms/file-upload/:path*',
permanent: true,
},
]
},
webpack: (config, { defaultLoaders }) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/data/components-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const sidebar = {
},
{
title: 'FileUpload',
path: '/docs/components/file-upload',
path: '/docs/components/forms/file-upload',
new: true,
},
],
Expand Down
25 changes: 14 additions & 11 deletions apps/website/src/docs/utils/contentlayer-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ function toCapitalized(str: string) {
}

export function getGroupedComponents() {
return getDocByType('components').reduce((acc, doc) => {
const category = doc.category
if (!category) return acc
acc[toCapitalized(category)] ??= []
acc[toCapitalized(category)].push(doc)
return acc
}, {} as { [key: string]: any[] })
return getDocByType('components').reduce(
(acc, doc) => {
const category = doc.category
if (!category) return acc
acc[toCapitalized(category)] ??= []
acc[toCapitalized(category)].push(doc)
return acc
},
{} as { [key: string]: any[] }
)
}

const getUsageDoc = (id: string) => {
Expand Down Expand Up @@ -52,16 +55,16 @@ export const getDocDoc = (slug: MixedArray): Doc | undefined => {
if (isThemingTab) {
doc.frontMatter = {
...doc.frontMatter,
...(getUsageDoc(doc.id)?.frontMatter ?? {}),
...(getThemingDoc(doc.id)?.frontMatter ?? {}),
...(getUsageDoc(doc.id!)?.frontMatter ?? {}),
...(getThemingDoc(doc.id!)?.frontMatter ?? {}),
}
}

if (isPropsTab) {
doc.frontMatter = {
...doc.frontMatter,
...(getUsageDoc(doc.id)?.frontMatter ?? {}),
...(getPropsDoc(doc.id)?.frontMatter ?? {}),
...(getUsageDoc(doc.id!)?.frontMatter ?? {}),
...(getPropsDoc(doc.id!)?.frontMatter ?? {}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions apps/website/src/pages/docs/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const getStaticPaths: GetStaticPaths = async () => {
}

export const getStaticProps: GetStaticProps = async (ctx) => {
const tabsData = getComponentTabsData([ctx.params?.slug])
const doc = getDocDoc([ctx.params.slug])
const tabsData = getComponentTabsData([ctx.params?.slug!])
const doc = getDocDoc([ctx.params?.slug!])

const params =
(Array.isArray(ctx.params?.slug) ? ctx.params?.slug : [ctx.params?.slug]) ??
Expand Down

0 comments on commit 0f8fe5c

Please sign in to comment.