Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix menu display and navigation to invalid category #120

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/app/[[...category]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Suspense } from 'react';
import type { Metadata } from 'next';
import { redirect } from 'next/navigation';

import shuffle from '@/utils/shuffle';
import getProjects from './getProjects';
Expand Down Expand Up @@ -27,6 +28,12 @@ export async function generateStaticParams() {
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const DefaultPageTitle = 'Open-source for good';
const category = categoryFromParams(params);

// Redirect home if category is not valid, as we capture all routes
if (category && !categories.includes(category)) {
return redirect('/');
}

return {
title: category
? `${category.charAt(0).toUpperCase() + category.slice(1)} open-source projects`
Expand Down
11 changes: 7 additions & 4 deletions src/app/[[...category]]/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
display: none;
}

.sorting {
margin: 1em 0;
}

@media only screen and (max-width: 599px) {
.categories {
margin-bottom: 1em;
Expand Down Expand Up @@ -51,10 +55,9 @@
.lg-only-br {
display: inline;
}
}

.sorting {
margin: 3em;
.sorting {
margin: 3em;
}
}

/*-----------------------------------
Expand Down
Loading