diff --git a/apps/blog/app/[param]/(user-profile)/layout.tsx b/apps/blog/app/[param]/(user-profile)/layout.tsx index c470497bdc78f1efe10787465c0d3842e6419601..581bcf3a9a67688e374af1d72c40c85a0011eb0d 100644 --- a/apps/blog/app/[param]/(user-profile)/layout.tsx +++ b/apps/blog/app/[param]/(user-profile)/layout.tsx @@ -13,7 +13,14 @@ const logger = getLogger('app'); export async function generateMetadata({ params }: { params: { param: string } }): Promise { const raw = params.param; - const username = raw.startsWith('%40') ? raw.replace('%40', '') : raw; + // Only process if it looks like a username (starts with @ or %40) + if (!raw.startsWith('@') && !raw.startsWith('%40')) { + return { + title: 'Hive', + description: 'Hive: Communities Without Borders.' + }; + } + const username = raw.startsWith('%40') ? raw.replace('%40', '') : raw.replace('@', ''); const queryClient = getQueryClient(); try { const account = await queryClient.fetchQuery({ @@ -57,7 +64,13 @@ export async function generateMetadata({ params }: { params: { param: string } } const Layout = async ({ children, params }: { children: ReactNode; params: { param: string } }) => { const queryClient = getQueryClient(); const { param } = params; - const username = param.startsWith('%40') ? param.replace('%40', '') : param; + + // Only process if it looks like a username (starts with @ or %40) + if (!param.startsWith('@') && !param.startsWith('%40')) { + notFound(); + } + + const username = param.startsWith('%40') ? param.replace('%40', '') : param.replace('@', ''); const valid = await isUsernameValid(username); if (!valid) { diff --git a/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx b/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx index 9538b3b912230fc86783befe5295b3a2f84096eb..68101be81084d4bf7e07dfecd1c7cacbb4c22c3c 100644 --- a/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx +++ b/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx @@ -12,7 +12,14 @@ export async function generateMetadata({ }: { params: { param: string; p2: string; permlink: string }; }): Promise { - const author = params?.p2?.replace('%40', ''); + // p2 should start with @ or %40 for valid post URLs + if (!params?.p2?.startsWith('@') && !params?.p2?.startsWith('%40')) { + return { + title: 'Hive', + description: 'Hive: Communities Without Borders.' + }; + } + const author = params.p2.replace('%40', '').replace('@', ''); const permlink = params?.permlink; const observer = getObserverFromCookies(); diff --git a/apps/blog/app/[param]/[p2]/[permlink]/page.tsx b/apps/blog/app/[param]/[p2]/[permlink]/page.tsx index a4558d640e7ad85bbc9163bea1a6c3b1d395d653..b1f0d27a2e6668dbb6322066481c90913087c8c8 100644 --- a/apps/blog/app/[param]/[p2]/[permlink]/page.tsx +++ b/apps/blog/app/[param]/[p2]/[permlink]/page.tsx @@ -18,8 +18,13 @@ const PostPage = async ({ }: { params: { param: string; p2: string; permlink: string }; }) => { + // p2 should start with @ or %40 for valid post URLs + if (!p2?.startsWith('@') && !p2?.startsWith('%40')) { + notFound(); + } + const queryClient = getQueryClient(); - const username = p2.replace('%40', ''); + const username = p2.replace('%40', '').replace('@', ''); const community = param; const validUser = await isUsernameValid(username); if (!validUser) notFound(); diff --git a/apps/blog/features/layouts/community/community-layout.tsx b/apps/blog/features/layouts/community/community-layout.tsx index 0f54386fdbb6d66b2854c718541164c3796842c5..adf9146e8b8a06b4d8243e6c267d12a80a72afd6 100644 --- a/apps/blog/features/layouts/community/community-layout.tsx +++ b/apps/blog/features/layouts/community/community-layout.tsx @@ -27,11 +27,13 @@ const CommunityLayout = ({ children, community }: { children: ReactNode; communi const isRolesPage = pathname?.includes('/roles/'); const { data: subsData } = useQuery({ queryKey: ['subscribers', community], - queryFn: () => getSubscribers(community ?? '') + queryFn: () => getSubscribers(community ?? ''), + enabled: community?.startsWith('hive-') }); const { data: notificationData } = useQuery({ queryKey: ['AccountNotification', community], - queryFn: () => getAccountNotifications(community ?? '') + queryFn: () => getAccountNotifications(community ?? ''), + enabled: community?.startsWith('hive-') }); const { data: mySubsData } = useQuery({ @@ -42,7 +44,8 @@ const CommunityLayout = ({ children, community }: { children: ReactNode; communi const { data: communityData } = useQuery({ queryKey: ['community', community], - queryFn: () => getCommunity(community, observer) + queryFn: () => getCommunity(community, observer), + enabled: community?.startsWith('hive-') }); return ( diff --git a/apps/blog/features/layouts/community/prefetch-component.tsx b/apps/blog/features/layouts/community/prefetch-component.tsx index d90b9094e0910a2d4c2afc40667f38dfdc849ea9..575043267212cafd750b2fd3f3dec3307d51dde3 100644 --- a/apps/blog/features/layouts/community/prefetch-component.tsx +++ b/apps/blog/features/layouts/community/prefetch-component.tsx @@ -24,7 +24,7 @@ const PrefetchComponent = async ({ children, community }: { children: ReactNode; queryKey: ['communitiesList', sort], queryFn: () => getCommunities(sort, query, observer) }); - if (community) { + if (community.startsWith('hive-')) { await queryClient.prefetchQuery({ queryKey: ['community', community], queryFn: async () => await getCommunity(community, observer) diff --git a/apps/blog/features/post-editor/post-form.tsx b/apps/blog/features/post-editor/post-form.tsx index 9c07b9db98b615ceaad358bfcaafc317b206f9be..e7b110502bad97fc6c48e2d5df4c076553bd399c 100644 --- a/apps/blog/features/post-editor/post-form.tsx +++ b/apps/blog/features/post-editor/post-form.tsx @@ -110,7 +110,7 @@ export default function PostForm({ const { data: communityData } = useQuery({ queryKey: ['community', categoryParam], queryFn: () => getCommunity(categoryParam ?? storedPost.category, observer), - enabled: Boolean(categoryParam) || Boolean(storedPost.category) + enabled: categoryParam?.startsWith('hive-') || storedPost.category?.startsWith('hive-') }); const { data: mySubsData } = useQuery({ queryKey: ['subscriptions', username],