Skip to content

Commit

Permalink
refactor: Add "Sheets Tools" to navigation routes
Browse files Browse the repository at this point in the history
This commit adds a new navigation route for "Sheets Tools" in the Genshin Impact header component. The route is "/sheets-tools" and is now included in the navigation menu.

Refactor the Genshin Impact header component to include the new "Sheets Tools" navigation route.
  • Loading branch information
dvaJi committed Aug 19, 2024
1 parent 8ea6d40 commit 9f83c7e
Show file tree
Hide file tree
Showing 22 changed files with 662 additions and 933 deletions.
58 changes: 58 additions & 0 deletions _content/genshin/data/sheets-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"wish-tally-community": {
"name": "Wish Tally - Community",
"purpose": "This sheet aggregates all shared Wish Tally documents from our community, providing you with detailed statistics on wishes.",
"creator": "Yippy",
"url": "https://docs.google.com/spreadsheets/d/1NV2dvHQpD5_pCH92-YgnCEH2LVNmMxwGUW6E3fwL4CM/edit",
"hoyolab": "https://www.hoyolab.com/article/390587",
"categories": ["Statistic"],
"tags": ["Statistic", "Tracker", "Wish"],
"images": ["/sheets/wish_tally_01.webp", "/sheets/wish_tally_02.webp"]
},
"teyvat-central-banking-systems": {
"name": "Teyvat Central Banking Systems",
"purpose": "Effortlessly track and manage your Genshin Impact resources, including Primogems, Genesis Crystals, Resin, and Mora, with this document. Automatically update your records by using the provided feedback URL, which securely connects to miHoYo's API. Stay on top of your in-game progress with precise and up-to-date information.",
"creator": "Yippy",
"url": "https://docs.google.com/spreadsheets/d/1VrNIbZGj2XhVZv7eRMgoSO3xUhOm0EVFGFqW0y1BLpI/edit",
"hoyolab": "https://www.hoyolab.com/article/1940532",
"categories": ["Tracker"],
"tags": ["Fragile Resin", "Genesis Crystal", "Mora", "Primogem", "Tracker"],
"images": [
"/sheets/teyvat_central_banking_systems_01.png",
"/sheets/teyvat_central_banking_systems_02.webp"
]
},
"parametric-transformer": {
"name": "Parametric Transformer",
"purpose": "This sheet organizes and analyzes the distribution of groups for each material used in the Parametric Transformer. It provides a comprehensive overview of how materials are grouped, enabling efficient tracking and optimization of your Parametric Transformer usage.",
"url": "https://docs.google.com/spreadsheets/d/1M2EpQp0_i34Mb7dpjsczK0wSC8QHj3w4nBhC4vIfDXM/edit",
"categories": ["Statistic"],
"tags": ["Statistic"],
"images": [
"/sheets/parametric_transformer_01.jpg",
"/sheets/parametric_transformer_02.jpg"
]
},
"genshin-impact-helper-teams-character-builds": {
"name": "Genshin Impact Helper Team’s Character Builds",
"purpose": "This sheet compiles and showcases the optimized character builds recommended by the Genshin Impact Helper Team. It serves as a comprehensive resource for selecting the best weapons, artifacts, and talent priorities to maximize the performance of your characters in various scenarios.",
"url": "https://docs.google.com/spreadsheets/d/1gNxZ2xab1J6o1TuNVWMeLOZ7TPOqrsf3SshP5DLvKzI/edit",
"categories": ["Character Build"],
"tags": ["Characters"],
"images": [
"/sheets/genshin_impact_helper_teams_character_builds_01.jpg",
"/sheets/genshin_impact_helper_teams_character_builds_02.jpg"
]
},
"genshin-impact-calculators": {
"name": "Genshin Impact Calculators",
"purpose": "This collection of Genshin Impact calculators provides precise tools for optimizing various aspects of your gameplay, from damage output and resource management to character leveling and artifact enhancement. Use these calculators to make informed decisions and enhance your in-game efficiency.",
"url": "https://docs.google.com/spreadsheets/d/1yNV3ld2kOzl8VvZb2bg6GLQ1KRryovrb6C8Wp9tw2Q8/edit",
"categories": ["Calculator"],
"tags": ["Calculator"],
"images": [
"/sheets/genshin-impact-calculators_01.jpg",
"/sheets/genshin-impact-calculators_02.jpg"
]
}
}
5 changes: 5 additions & 0 deletions app/[lang]/(genshin)/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ const navRoutes: Route[] = [
name: "Fishing",
href: "/fishing",
},
{
id: "sheets_tools",
name: "Sheets Tools",
href: "/sheets-tools",
}
],
},
];
Expand Down
14 changes: 7 additions & 7 deletions app/[lang]/(genshin)/profile/[uid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Profile } from "interfaces/profile";
import type { Metadata } from "next";
import dynamic from "next/dynamic";
import { notFound } from "next/navigation";

import { submitGenshinUID } from "@app/actions";
import { genPageMetadata } from "@app/seo";
import DynamicBackground from "@components/DynamicBackground";
import ProfileArtifactsTable from "@components/genshin/ProfileArtifactsTable";
import ProfileBuildsTable from "@components/genshin/ProfileBuildsTable";
import { FavoriteGenshinProfile } from "./favorite";
import { SyncGenshinProfile } from "./sync";

import useTranslations from "@hooks/use-translations";
import { AD_ARTICLE_SLOT } from "@lib/constants";
import { getBuild, getPlayer } from "@lib/genshinShowcase";
import { getUrl, getUrlLQ } from "@lib/imgUrl";
import { Profile } from "interfaces/profile";
import { submitGenshinUID } from "@app/actions";

import { FavoriteGenshinProfile } from "./favorite";
import { SyncGenshinProfile } from "./sync";

const Ads = dynamic(() => import("@components/ui/Ads"), { ssr: false });
const FrstAds = dynamic(() => import("@components/ui/FrstAds"), { ssr: false });
Expand Down Expand Up @@ -106,11 +106,11 @@ export default async function GenshinPlayerProfile({ params }: Props) {
placementName="genshinbuilds_billboard_atf"
classList={["flex", "justify-center"]}
/>
<div className="relative">
<div className="relative z-10">
<ProfileFavorites />
</div>
<div
className="relative mt-4 rounded-xl bg-cover bg-center"
className="relative z-10 mt-4 rounded-xl bg-cover bg-center"
style={{
backgroundImage: `url(${getUrlLQ(
`/profile/${profile.namecardId}_1.png`
Expand Down
169 changes: 169 additions & 0 deletions app/[lang]/(genshin)/sheets-tools/[tool]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import type { Metadata } from "next";
import importDynamic from "next/dynamic";
import { notFound } from "next/navigation";

import { genPageMetadata } from "@app/seo";
import Badge from "@components/ui/Badge";
import useTranslations from "@hooks/use-translations";
import { i18n } from "@i18n-config";
import { AD_ARTICLE_SLOT } from "@lib/constants";
import { getUrl } from "@lib/imgUrl";
import { getData } from "@lib/localData";

const Ads = importDynamic(() => import("@components/ui/Ads"), { ssr: false });
const FrstAds = importDynamic(() => import("@components/ui/FrstAds"), {
ssr: false,
});

export const dynamic = "force-static";

interface GenshinImpactCalculators {
name: string;
purpose: string;
url: string;
categories: string[];
tags: string[];
images: string[];
creator?: string;
hoyolab?: string;
}

export async function generateStaticParams() {
const sheets = await getData<Record<string, GenshinImpactCalculators>>(
"genshin",
"sheets-tools"
);
const routes: { lang: string; tool: string }[] = [];

for await (const lang of i18n.locales) {
for (const tool of Object.keys(sheets)) {
routes.push({ lang, tool });
}
}
return routes;
}

interface Props {
params: {
tool: string;
lang: string;
};
}

export async function generateMetadata({
params,
}: Props): Promise<Metadata | undefined> {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { t, locale } = await useTranslations(
params.lang,
"genshin",
"sheets_tools"
);

const sheets = await getData<Record<string, GenshinImpactCalculators>>(
"genshin",
"sheets-tools"
);
const sheet = sheets[params.tool];

if (!sheet) {
return;
}

const title = t("detail_title", {
name: sheet.name,
category: sheet.categories[0],
});
const description = sheet.purpose;

return genPageMetadata({
title,
description,
path: `/sheets-tools/${params.tool}`,
locale,
});
}

export default async function GenshinSheetsToolsPage({ params }: Props) {
const { t } = await useTranslations(params.lang, "genshin", "sheets_tools");
const sheets = await getData<Record<string, GenshinImpactCalculators>>(
"genshin",
"sheets-tools"
);
const sheet = sheets[params.tool];

if (!sheet) {
return notFound();
}

return (
<div className="relative">
<h2 className="text-2xl font-semibold text-gray-200">
{t("detail_title", {
name: sheet.name,
category: sheet.categories[0],
})}
</h2>
<p>{sheet.purpose}</p>
<FrstAds
placementName="genshinbuilds_billboard_atf"
classList={["flex", "justify-center"]}
/>
<Ads className="mx-auto my-0" adSlot={AD_ARTICLE_SLOT} />
<div className="card">
<div>
<ul className="flex flex-wrap gap-4">
{sheet.images.map((image) => (
<li key={image}>
<img
src={getUrl(image, 300, 480)}
alt={sheet.name}
className="rounded-lg"
width={300}
height={480}
/>
</li>
))}
</ul>
</div>
<p>
{t("creator")}: {sheet.creator}
</p>
<p>
{t("link")}:{" "}
<a href={sheet.url} target="_blank" rel="noreferrer noopener">
{sheet.url}
</a>
</p>
{sheet.hoyolab ? (
<p>
{t("hoyolab_article")}:{" "}
<a href={sheet.hoyolab} target="_blank" rel="noreferrer noopener">
{sheet.hoyolab}
</a>
</p>
) : null}
<div>
<h4>{t("categories")}:</h4>
<ul>
{sheet.categories.map((category) => (
<Badge key={category}>{category}</Badge>
))}
</ul>
</div>
<div>
<h4>{t("tags")}:</h4>
<ul>
{sheet.tags.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
</ul>
</div>
</div>
<FrstAds
placementName="genshinbuilds_incontent_1"
classList={["flex", "justify-center"]}
/>
</div>
);
}
Loading

0 comments on commit 9f83c7e

Please sign in to comment.