Skip to content

Commit

Permalink
Added gallery details & fixed window content width problems
Browse files Browse the repository at this point in the history
  • Loading branch information
PArns committed Mar 14, 2024
1 parent b728b40 commit dd43423
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 32 deletions.
15 changes: 5 additions & 10 deletions app/(desktop)/[lng]/@blog/(.)/blog/article/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@ import { getImageSource } from "@/components/contentful/image-asset";

import Translate from "@/components/translate";
import { WindowTitle } from "@/components/os/windowManager";
import {
AlternateLinkDescriptor,
AlternateURLs,
} from "next/dist/lib/metadata/types/alternative-urls-types";
import { AlternateURLs } from "next/dist/lib/metadata/types/alternative-urls-types";
import { LanguageAlternates } from "@/components/os/language-switcher";

interface BlogPostPageParams {
slug: string;
lng: string;
}

interface BlogPostPageProps {
params: BlogPostPageParams;
}

export async function generateStaticParams(): Promise<BlogPostPageParams[]> {
const config = PageBaseConfiguration();
const entries: BlogPostPageParams[] = [];
Expand All @@ -48,7 +41,9 @@ export async function generateStaticParams(): Promise<BlogPostPageParams[]> {

export async function generateMetadata({
params,
}: BlogPostPageProps): Promise<Metadata> {
}: {
params: { slug: string; lng: string };
}): Promise<Metadata> {
const config = PageBaseConfiguration();
const post = await GetBlogPostBySlug(params.slug, params.lng);

Expand Down Expand Up @@ -112,7 +107,7 @@ export default async function BlogOverlay({
}

return (
<div className="flex flex-col p-2">
<div className="flex w-full flex-col p-2">
<WindowTitle id="blog" title={`${post.title} - ${post.subTitle}`} />
<LanguageAlternates alternates={alternates} />
<BlogHeader
Expand Down
106 changes: 106 additions & 0 deletions app/(desktop)/[lng]/@pictures/(.)/pictures/gallery/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import BlogHeader from "@/components/blog/blog-header";
import { getImageSource } from "@/components/contentful/image-asset";
import { WindowTitle } from "@/components/os/windowManager";
import PhotoGallery, { GalleryPhoto } from "@/components/photo-gallery";
import Translate from "@/components/translate";
import PageBaseConfiguration from "@/configuration";
import { GetGalleryBySlug } from "@/contentful/provider/gallery-provider";
import { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";

export async function generateMetadata({
params,
}: {
params: { slug: string; lng: string };
}): Promise<Metadata> {
const config = PageBaseConfiguration();
const gallery = await GetGalleryBySlug(params.slug, params.lng);

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

return {
metadataBase: config.baseUrl,
title: `${gallery.name} `,
description: gallery.description,
openGraph: {
type: "article",

publishedTime: gallery.date.toISOString(),
url: `${config.baseUrl}/${params.lng}/pictures/gallery/${params.slug}`,
locale: params.lng,
images: [
{ url: getImageSource(gallery.teaserImage, 800), width: 800 },
{ url: getImageSource(gallery.teaserImage, 1800), width: 1800 },
],
},
};
}

export default async function GalleryOverlay({
params,
}: {
params: { slug: string; lng: string };
}) {
const gallery = await GetGalleryBySlug(params.slug, params.lng);

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


let galleryImages: GalleryPhoto[] = [];

gallery.images.map((image: any) => {
galleryImages.push({
src: getImageSource(image, 400),
lightboxImageSrc: getImageSource(image, 1200),
alt: image.fields.description,
title: image.fields.title,
width: image.fields.file.details.image.width,
height: image.fields.file.details.image.height,
});
});

return (
<div className="flex w-full flex-col p-2">
<WindowTitle id="pictures" title={`${gallery.name}`} />
<BlogHeader title={gallery.name} backgroundImage={gallery.teaserImage} />

<div className="mt-2 w-full rounded-md bg-white p-4 dark:bg-neutral-800">
<PhotoGallery photos={galleryImages} />
</div>

<div className="mr-1 mt-2 flex flex-nowrap text-neutral-800">
<Link
href={`/${params.lng}/pictures`}
className="rounded bg-sky-400 px-4 py-2 font-semibold text-white transition hover:bg-sky-700 dark:bg-sky-600 dark:hover:bg-sky-700"
>
<div className="flex flex-nowrap">
<div>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="h-6 w-6 pr-2"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M9 15L3 9m0 0l6-6M3 9h12a6 6 0 010 12h-3"
/>
</svg>
</div>
<div>
<Translate id="back" ns="blog" locale={params.lng} />
</div>
</div>
</Link>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion app/(desktop)/[lng]/@pictures/(.)/pictures/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default async function Welcome({ params }: { params: { lng: string } }) {
</div>

<div className="flex">
<div className="flex flex-col gap-3">
<div className="flex w-full flex-col gap-3">
{imageGalleries.galleries.map((gallery) => (
<GalleryCard gallery={gallery} key={gallery.slug} />
))}
Expand Down
10 changes: 6 additions & 4 deletions components/blog/blog-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function BlogHeader({
backgroundImage,
}: {
title: string;
subTitle: string;
subTitle?: string;
backgroundImage: any;
}) {
return (
Expand All @@ -25,9 +25,11 @@ export default function BlogHeader({
<h1 className="mb-2 text-4xl font-semibold drop-shadow-[0_1.2px_1.2px_rgba(0,0,0,0.8)] md:text-5xl lg:text-6xl">
{title}
</h1>
<h2 className="text-2xl font-semibold drop-shadow-[0_1.2px_1.2px_rgba(0,0,0,0.8)] md:text-3xl lg:text-4xl">
{subTitle}
</h2>
{subTitle && (
<h2 className="text-2xl font-semibold drop-shadow-[0_1.2px_1.2px_rgba(0,0,0,0.8)] md:text-3xl lg:text-4xl">
{subTitle}
</h2>
)}
</div>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions components/gallery/gallery-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default function GalleryCard({ gallery }: { gallery: ImageGallery }) {
return (
<div className="flex rounded-lg drop-shadow-lg">
<article className="w-full">
<Link href={`/${gallery.locale}/pictures/${gallery.slug}`}>
<Link
href={`/${gallery.locale}/pictures/gallery/${gallery.slug}`}
className="w-full"
>
<div className="relative overflow-hidden bg-cover bg-no-repeat p-24">
<ContentfulImageAsset
asset={gallery.teaserImage}
Expand Down Expand Up @@ -36,9 +39,9 @@ export default function GalleryCard({ gallery }: { gallery: ImageGallery }) {

<div className="rounded-b-lg bg-white p-2 dark:bg-neutral-800">
{gallery.description}
<div className="mr-1 mt-2 flex w-full flex-nowrap place-content-end text-neutral-800">
<div className="mr-1 mt-2 flex flex-nowrap place-content-end text-neutral-800">
<Link
href={`/${gallery.locale}/pictures/${gallery.slug}`}
href={`/${gallery.locale}/pictures/gallery/${gallery.slug}`}
className="rounded bg-sky-400 px-4 py-2 font-semibold text-white transition hover:bg-sky-700 dark:bg-sky-600 dark:hover:bg-sky-700"
>
<Translate id="more" ns="blog" locale={gallery.locale} />
Expand Down
4 changes: 2 additions & 2 deletions components/os/window/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ export default function DesktopWindow({
</button>
</div>
<div
className="flex w-auto overflow-y-auto overflow-x-clip"
className="flex overflow-y-auto overflow-x-clip"
onClick={handleContainerClick}
>
<div className="h-max" ref={childrenRef}>
<div className="h-max w-full" ref={childrenRef}>
{children}
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions components/photo-gallery/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client"

import PhotoAlbum, { Photo, RenderPhotoProps } from "react-photo-album";
import Image from "next/image";
import { showLightBoxImage } from "../os/lightbox";
Expand Down
16 changes: 4 additions & 12 deletions contentful/provider/gallery-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ export interface ImageGallery {
export function parseContentfulImageGallery(
imageGalleryEntry?: ImageGalleryEntry,
locale?: string,
): ImageGallery {
): ImageGallery | null {
if (!imageGalleryEntry) {
return {
name: "PARSING ERROR",
slug: "",
date: new Date(),
description: "",
locale: locale || "en",
teaserImage: null,
images: [],
};
return null;
}

return {
Expand Down Expand Up @@ -84,8 +76,8 @@ export const GetGalleries = cache(
},
);

export const GetBlogPostBySlug = cache(
async (slug: string, locale: string): Promise<ImageGallery> => {
export const GetGalleryBySlug = cache(
async (slug: string, locale: string): Promise<ImageGallery | null> => {
const res = await client.getEntries<TypeImageGallerySkeleton>({
content_type: "imageGallery",
limit: 1,
Expand Down

1 comment on commit dd43423

@vercel
Copy link

@vercel vercel bot commented on dd43423 Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.