diff --git a/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-1200x670.webp b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-1200x670.webp new file mode 100644 index 0000000..ace02d1 Binary files /dev/null and b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-1200x670.webp differ diff --git a/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-400x223.webp b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-400x223.webp new file mode 100644 index 0000000..3c457dd Binary files /dev/null and b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-400x223.webp differ diff --git a/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-800x447.webp b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-800x447.webp new file mode 100644 index 0000000..a020cf3 Binary files /dev/null and b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32-800x447.webp differ diff --git a/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32.png b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32.png new file mode 100644 index 0000000..1e6184d Binary files /dev/null and b/media/weavy-Gemini 3 (Nano Banana Pro)-2026-01-31 at 11.02.32.png differ diff --git a/src/app/(frontend)/posts/[slug]/page.tsx b/src/app/(frontend)/posts/[slug]/page.tsx index 1192904..1471287 100644 --- a/src/app/(frontend)/posts/[slug]/page.tsx +++ b/src/app/(frontend)/posts/[slug]/page.tsx @@ -8,13 +8,10 @@ import { generateMeta } from '@/utilities/generateMeta' import { formatDateTime } from '@/utilities/formatDateTime' import RichText from '@/components/RichText' - -// ─── Types ──────────────────────────────────────────────────────────────────── type Args = { params: Promise<{ slug: string }> } -// ─── Page ───────────────────────────────────────────────────────────────────── export default async function PostPage({ params }: Args) { const { slug } = await params const payload = await getPayload({ config }) @@ -31,90 +28,84 @@ export default async function PostPage({ params }: Args) { const heroImage = post.heroImage as Media | undefined const authors = (post.populatedAuthors as any[]) ?? [] + const summary = post.meta?.description ?? null return ( -
- {/* ── Hero ── */} -
- {/* Background image with navy overlay */} - {heroImage?.url && ( - <> -
- -
-
- +
+ + {/* ── Main column ── */} +
+
+ + {/* Back link */} + + ← Tillbaka till nyheter + + + {/* Title */} +

+ {post.title} +

+ + {/* Summary / excerpt (from meta description) */} + {summary && ( +

+ {summary} +

)} -
- {/* Category / back link */} - - ← Tillbaka till nyheter - - - {/* Title */} -

- {post.title} -

- - {/* Meta row */} -
- {post.publishedAt && ( - {formatDateTime(post.publishedAt)} - )} - {authors.length > 0 && ( - - Av{' '} - {authors.map((a: any) => a.name).join(', ')} - - )} -
-
-
- - {/* ── Hero image (if present) — shown below hero on larger posts ── */} - {heroImage?.url && ( -
-
-
+ {/* Hero image */} + {heroImage?.url && ( +
+
-
-
- )} + {heroImage.alt && heroImage.alt.trim() !== '' && ( +
+ {heroImage.alt} +
+ )} + + )} - {/* ── Article body ── */} -
-
-
- {/* Payload rich text renderer */} - {post.content && } -
+ {/* Author + date */} +
+ {authors.length > 0 && ( +

+ Av {authors.map((a: any) => a.name).join(', ')} +

+ )} + {post.publishedAt && ( +

{formatDateTime(post.publishedAt)}

+ )}
-
- {/* ── Footer CTA ── */} -
-
-

- Vill du veta mer om hur Fiber Direkt kan hjälpa er verksamhet? -

- - Kontakta oss → - -
-
+ {/* Rich text body */} + {post.content && ( +
+ +
+ )} + + {/* CTA */} + + Kontakta oss + + +
+
) } diff --git a/src/app/(frontend)/posts/page.tsx b/src/app/(frontend)/posts/page.tsx index fad8ba2..b5f1004 100644 --- a/src/app/(frontend)/posts/page.tsx +++ b/src/app/(frontend)/posts/page.tsx @@ -1,16 +1,15 @@ import type { Metadata } from 'next/types' - -import { CollectionArchive } from '@/components/CollectionArchive' -import { PageRange } from '@/components/PageRange' -import { Pagination } from '@/components/Pagination' import configPromise from '@payload-config' import { getPayload } from 'payload' import React from 'react' +import type { Post, Media } from '@/payload-types' +import { FDImage } from '@/components/FDImage' +import { formatDateTime } from '@/utilities/formatDateTime' +import { Pagination } from '@/components/Pagination' import PageClient from './page.client' + export const dynamic = 'force-dynamic' - - export default async function Page() { const payload = await getPayload({ config: configPromise }) @@ -22,34 +21,78 @@ export default async function Page() { select: { title: true, slug: true, + heroImage: true, categories: true, meta: true, + publishedAt: true, + populatedAuthors: true, }, }) return ( -
+
-
-
-

Posts

-
+
+

Nyheter

+

+ {posts.totalDocs} {posts.totalDocs === 1 ? 'artikel' : 'artiklar'} +

- -
- -
- - - -
+
+ {posts.docs.length === 0 ? ( +

Inga inlägg hittades.

+ ) : ( +
+ {posts.docs.map((post) => { + const p = post as Post + const heroImage = p.heroImage as Media | undefined + const summary = p.meta?.description ?? null + return ( + +
+ {heroImage?.url ? ( + + ) : ( +
+ Ingen bild +
+ )} +
+
+

+ {p.title} +

+ {summary && ( +

+ {summary} +

+ )} + {p.publishedAt && ( +

+ {formatDateTime(p.publishedAt)} +

+ )} +
+
+ ) + })} +
+ )} {posts.totalPages > 1 && posts.page && ( - +
+ +
)}
@@ -58,6 +101,7 @@ export default async function Page() { export function generateMetadata(): Metadata { return { - title: `Payload Website Template Posts`, + title: 'Nyheter | Fiber Direkt', + description: 'Senaste nytt från Fiber Direkt', } } diff --git a/src/app/(frontend)/posts/page/page.tsx b/src/app/(frontend)/posts/page/page.tsx new file mode 100644 index 0000000..8c8cc1b --- /dev/null +++ b/src/app/(frontend)/posts/page/page.tsx @@ -0,0 +1,122 @@ +import type { Metadata } from 'next/types' +import configPromise from '@payload-config' +import { getPayload } from 'payload' +import React from 'react' +import type { Post, Media } from '@/payload-types' +import { FDImage } from '@/components/FDImage' +import { formatDateTime } from '@/utilities/formatDateTime' +import { Pagination } from '@/components/Pagination' +import PageClient from './page.client' + +export const dynamic = 'force-dynamic' + +export default async function Page() { + const payload = await getPayload({ config: configPromise }) + + const posts = await payload.find({ + collection: 'posts', + depth: 1, + limit: 12, + overrideAccess: false, + select: { + title: true, + slug: true, + heroImage: true, + categories: true, + meta: true, + publishedAt: true, + populatedAuthors: true, + }, + }) + + return ( +
+ + + {/* ── Page header ── */} +
+

+ Nyheter +

+

+ {posts.totalDocs} {posts.totalDocs === 1 ? 'artikel' : 'artiklar'} +

+
+ + {/* ── Card grid ── */} +
+ {posts.docs.length === 0 ? ( +

Inga inlägg hittades.

+ ) : ( +
+ {posts.docs.map((post) => { + const p = post as Post + const heroImage = p.heroImage as Media | undefined + const summary = p.meta?.description ?? null + + return ( + + {/* Image */} +
+ {heroImage?.url ? ( + + ) : ( +
+ Ingen bild +
+ )} +
+ + {/* Content */} +
+

+ {p.title} +

+ + {summary && ( +

+ {summary} +

+ )} + + {/* Date */} + {p.publishedAt && ( +

+ {formatDateTime(p.publishedAt)} +

+ )} +
+
+ ) + })} +
+ )} + + {/* Pagination */} + {posts.totalPages > 1 && posts.page && ( +
+ +
+ )} +
+
+ ) +} + +export function generateMetadata(): Metadata { + return { + title: 'Nyheter | Fiber Direkt', + description: 'Senaste nytt från Fiber Direkt', + } +}