@@ -17,6 +17,7 @@ import {User} from 'common/user'
1717import { getUserForStaticProps } from 'common/supabase/users'
1818import { type GetStaticProps } from 'next'
1919import { CompassLoadingIndicator } from "web/components/widgets/loading-indicator" ;
20+ import Custom404 from '../404'
2021
2122export const getStaticProps : GetStaticProps <
2223 UserPageProps ,
@@ -27,11 +28,12 @@ export const getStaticProps: GetStaticProps<
2728
2829 const user = await getUserForStaticProps ( db , username )
2930
31+ // console.log(user)
32+
3033 if ( ! user ) {
3134 return {
32- notFound : true ,
3335 props : {
34- customText :
36+ notFoundCustomText :
3537 'The profile you are looking for is not on this site... or perhaps you just mistyped?' ,
3638 } ,
3739 }
@@ -48,6 +50,7 @@ export const getStaticProps: GetStaticProps<
4850 }
4951
5052 if ( user . userDeleted ) {
53+ console . debug ( 'User deleted' )
5154 return {
5255 props : {
5356 user : false ,
@@ -57,6 +60,15 @@ export const getStaticProps: GetStaticProps<
5760 }
5861
5962 const profile = await getProfileRow ( user . id , db )
63+ if ( ! profile ) {
64+ console . debug ( 'No profile' , `${ user . username } hasn't created a profile yet.` )
65+ return {
66+ props : {
67+ notFoundCustomText : `${ user . username } hasn't created a profile yet.` ,
68+ } ,
69+ }
70+ }
71+ // console.debug('profile', profile)
6072 return {
6173 props : {
6274 user,
@@ -71,7 +83,7 @@ export const getStaticPaths = () => {
7183 return { paths : [ ] , fallback : 'blocking' }
7284}
7385
74- type UserPageProps = DeletedUserPageProps | ActiveUserPageProps
86+ type UserPageProps = DeletedUserPageProps | ActiveUserPageProps | NotFoundPageProps
7587
7688type DeletedUserPageProps = {
7789 user : false
@@ -82,9 +94,16 @@ type ActiveUserPageProps = {
8294 username : string
8395 profile : ProfileRow
8496}
97+ type NotFoundPageProps = {
98+ notFoundCustomText : string
99+ }
85100
86101export default function UserPage ( props : UserPageProps ) {
87102 // console.debug('Starting UserPage in /[username]')
103+ if ( 'notFoundCustomText' in props ) {
104+ return < Custom404 customText = { props . notFoundCustomText } />
105+ }
106+
88107 if ( ! props . user ) {
89108 return < PageBase
90109 trackPageView = { 'user page' }
0 commit comments