Skip to content

Commit

Permalink
opentierboy-49 General SEO Improvements
Browse files Browse the repository at this point in the history
- Replace `tag` paths with hyphens replacing underscores; old underscore links are optimistically redirected to the new paths
  • Loading branch information
infinia-yzl committed Jul 20, 2024
1 parent 77de8be commit 7e39b65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 1 addition & 5 deletions app/rank/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ItemSet} from "@/models/ItemSet";
import ImageSetConfig from "@/models/ImageSet";
import dynamic from "next/dynamic";
import {Metadata, ResolvingMetadata} from "next";
import {slugify} from "@/lib/utils";
import {createSEOFriendlyTagSlug, slugify} from "@/lib/utils";
import {redirect} from "next/navigation";

const typedImageSetConfig = imagesetConfig as ImageSetConfig;
Expand All @@ -12,10 +12,6 @@ const TierListManager = dynamic(
{ssr: false}
);

function createSEOFriendlyTagSlug(tag: string): string {
return tag ? tag.toLowerCase().replace(/_+/g, '-').replace(/^-|-$/g, '') : '';
}

export async function generateStaticParams() {
const params: { slug: string[] }[] = [];
Object.entries(typedImageSetConfig.packages).forEach(([packageName, packageData]) => {
Expand Down
4 changes: 2 additions & 2 deletions components/PackageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link';
import {Button} from "@/components/ui/button";
import {Card, CardHeader, CardTitle, CardContent} from "@/components/ui/card";
import {Separator} from "@/components/ui/separator";
import {slugify, cn} from "@/lib/utils";
import {slugify, cn, createSEOFriendlyTagSlug} from "@/lib/utils";
import {getFont, FontName} from '@/lib/fonts';

interface PackageCardProps {
Expand Down Expand Up @@ -60,7 +60,7 @@ const PackageCard: React.FC<PackageCardProps> = ({packageData, tags}) => {
"group-hover:hover:bg-white/30" // Additional hover effect when card is hovered
)}
>
<Link href={`/rank/${slugify(packageData.displayName)}/${tagName}`}>
<Link href={`/rank/${slugify(packageData.displayName)}/${createSEOFriendlyTagSlug(tagName)}`}>
{tagName === 'all' ? 'All Items' : packageData.tags[tagName]?.title || tagName}
</Link>
</Button>
Expand Down
4 changes: 4 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ export const getTierGradient = (index: number, tiersLength: number): string => {
return `var(--tier-gradient-${tierGradientIndexMap[index % 7]})`;
}
};

export function createSEOFriendlyTagSlug(tag: string): string {
return tag ? tag.toLowerCase().replace(/_+/g, '-').replace(/^-|-$/g, '') : '';
}

0 comments on commit 7e39b65

Please sign in to comment.