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

Footer tweak #99

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 9 additions & 0 deletions src/app/[lang]/category/[slug]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Skeleton } from "@/components/ui/Skeleton/Skeleton"

export default function Loading() {
return (
<div className="w-full">
<Skeleton className="min-h-[150px] w-full" />
</div>
)
}
8 changes: 7 additions & 1 deletion src/app/[lang]/category/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Metadata } from "next/types"
import { unstable_setRequestLocale } from "next-intl/server"
import { Suspense } from "react"
import { CategoryArticles } from "@/components/CategoryArticles/CategoryArticles"
import { Locale } from "@/i18n/i18n"
import { setTranslations } from "@/i18n/setTranslations"
import { getMatadataObj } from "@/utils/getMetadataObj"
import Loading from "./loading"

type ArticlePageProps = { params: { slug: string; lang: Locale } }

Expand All @@ -15,5 +17,9 @@ export default async function Web({ params: { slug, lang } }: ArticlePageProps)
unstable_setRequestLocale(lang)
await setTranslations(lang)

return <CategoryArticles category={slug} />
return (
<Suspense fallback={<Loading />}>
<CategoryArticles category={slug} />
</Suspense>
)
}
8 changes: 4 additions & 4 deletions src/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { notFound } from "next/navigation"
import { unstable_setRequestLocale } from "next-intl/server"
import { Footer } from "@/components/Footer/Footer"
import { Navigation } from "@/components/Navigation/Navigation"
import { env } from "@/env.mjs"
import { i18n, type Locale } from "@/i18n/i18n"
import { setTranslations } from "@/i18n/setTranslations"
import { getNavigation } from "@/lib/client"
import "@/styles/tailwind.css"
import { unstable_setRequestLocale } from "next-intl/server"
import { notFound } from "next/navigation"
import { GoogleAnalytics } from "../GoogleAnalytics"
import Providers from "../Providers"

Expand Down Expand Up @@ -41,7 +41,7 @@ export default async function Layout({ children, params }: { children: React.Rea
if (!isValidLocale) notFound()
unstable_setRequestLocale(locale)
const translations = await setTranslations(locale)
const { navigation, footer, logo } = await getNavigation(locale)
const { navigation, footer } = await getNavigation(locale)

return (
<html lang={locale}>
Expand All @@ -55,7 +55,7 @@ export default async function Layout({ children, params }: { children: React.Rea
</div>

<main className="mx-auto flex w-full max-w-[1200px] flex-1 flex-col px-4 pb-16">{children}</main>
<Footer logoUrl={logo?.url} footer={footer} />
<Footer footer={footer} />
</body>
</Providers>
</html>
Expand Down
14 changes: 10 additions & 4 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { GetNavigationReturn } from "../Navigation/Navigation"

type FooterProps = {
footer: Pick<GetNavigationReturn, "footer">["footer"]
logoUrl: string | undefined
}

export async function Footer({ footer, logoUrl }: FooterProps) {
export async function Footer({ footer }: FooterProps) {
const locale = useLocale()

if (!footer?.contactSection) return null
Expand Down Expand Up @@ -68,14 +67,21 @@ export async function Footer({ footer, logoUrl }: FooterProps) {
<div className="w-fit lg:w-auto">
<DynamicLangSelect />
</div>
{logoUrl && (
{footer?.additionalLogo && (
<Link
hrefLang={locale}
target="_blank"
href={"https://blazity.com/"}
className="flex max-h-[100px] w-[100px] lg:justify-end"
>
<Image src={logoUrl} width={300} height={300} alt="Blazity logo" className="w-full" quality={100} />
<Image
src={footer?.additionalLogo.url}
width={300}
height={300}
alt="Blazity logo"
className="w-full"
quality={100}
/>
</Link>
)}
<p className="text-sm">
Expand Down
10 changes: 5 additions & 5 deletions src/lib/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { env } from "@/env.mjs"
import { Locale, standardNotationToHygraphLocale } from "@/i18n/i18n"
import { TypedDocumentNode } from "@graphql-typed-document-node/core"
import { print } from "graphql"
import omit from "lodash/omit"
import pThrottle from "p-throttle"
import { env } from "@/env.mjs"
import { Locale, standardNotationToHygraphLocale } from "@/i18n/i18n"
import {
getArticleBySlugQuery,
getArticleMetadataBySlugQuery,
Expand All @@ -18,8 +18,8 @@ import {
import { getHomepageMetadataQuery, getHomepageQuery, getNavigationQuery } from "./queries/components"
import { getPageBySlugQuery, getPageMetadataBySlugQuery, listPagesForSitemapQuery } from "./queries/pages"
import { getQuizQuestionsByIdQuery } from "./queries/quizes"
import { Tag } from "./tags"
import { getGlobalTranslationsQuery } from "./queries/translations"
import { Tag } from "./tags"

const throttle = pThrottle({
limit: 5, //Community: 5req/sec
Expand Down Expand Up @@ -97,14 +97,14 @@ export async function getHomepageMetadata(locale: Locale) {
}

export async function getNavigation(locale: Locale) {
const { navigations, footers, asset } = await graphqlFetch({
const { navigations, footers } = await graphqlFetch({
cache: "force-cache",
document: getNavigationQuery,
tags: ["NAVIGATION", "PAGE", "CATEGORY"],
variables: { locale },
})

return { navigation: navigations[0] ?? null, footer: footers[0] ?? null, logo: asset ?? null }
return { navigation: navigations[0] ?? null, footer: footers[0] ?? null }
}

export async function getArticlesQuantity(locale: Locale) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/queries/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export const getNavigationQuery = graphql(`
url
}
}
asset(where: { id: "clo74v3lz1yqp0bw1w7jsrrin" }) {
url
}
footers(locales: $locales, first: 1) {
logo {
url
}
additionalLogo {
url
}
ownershipAndCredits
companyName
youtubeLink
Expand Down
Loading