← Public packages
@kentcdodds/photo-portfolio
A fast, photo-first portfolio site you update by chatting with your agent: galleries, about, contact, and one-step rollback.
Files
/** @jsxRuntime automatic */
/** @jsxImportSource remix/component */
import type { RemixNode } from 'remix/component'
import type { SocialPlatform } from '../../src/domain/types.ts'
import { routes } from '../routes.ts'
import type { Site } from '../data/site.ts'
import { icon, socialLabels } from './icons.tsx'
export type PageMeta = {
/** Page title; the site name is appended. Omit on the home page. */
title?: string
description?: string
/** Absolute Open Graph image URL. */
image?: { url: string; width: number; height: number; alt: string }
/** Absolute canonical URL. */
canonical: string
nav?: 'home' | 'galleries' | 'about' | 'contact'
/** Never index (preview, contact confirmation, 404). */
noindex?: boolean
}
function navLink(href: string, label: string, current: boolean) {
return (
<a href={href} aria-current={current ? 'page' : undefined}>
{label}
</a>
)
}
/** Full HTML page: head (SEO + Open Graph), header, footer, preview banner, lightbox client. */
export function documentPage(site: Site, meta: PageMeta, children: RemixNode) {
const { config } = site.content
const title = meta.title
? `${meta.title} · ${config.siteName}`
: `${config.siteName} · ${config.tagline}`
const description = meta.description || config.seoDescription
const socials = Object.entries(config.social) as Array<
[SocialPlatform, string]
>
const year = new Date().getUTCFullYear()
return (
<html lang="en" data-theme={config.theme}>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<title>{title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={meta.canonical} />
{meta.noindex || site.preview ? (
<meta name="robots" content="noindex, nofollow" />
) : null}
<meta
name="color-scheme"
content={config.theme === 'auto' ? 'light dark' : config.theme}
/>
<meta property="og:type" content="website" />
<meta property="og:site_name" content={config.siteName} />
<meta property="og:title" content={meta.title ?? config.siteName} />
<meta property="og:description" content={description} />
<meta property="og:url" content={meta.canonical} />
{meta.image ? (
<>
<meta property="og:image" content={meta.image.url} />
<meta
property="og:image:width"
content={String(meta.image.width)}
/>
<meta
property="og:image:height"
content={String(meta.image.height)}
/>
<meta property="og:image:alt" content={meta.image.alt} />
</>
) : null}
<meta
name="twitter:card"
content={meta.image ? 'summary_large_image' : 'summary'}
/>
<link
rel="icon"
type="image/png"
href={`${site.assetBase}/favicon.png`}
/>
<link
rel="apple-touch-icon"
href={`${site.assetBase}/apple-touch-icon.png`}
/>
<link rel="stylesheet" href={`${site.assetBase}/styles.css`} />
<style>{`:root{--accent:${config.accentColor}}`}</style>
</head>
<body>
<a class="skip-link" href="#main">
Skip to content
</a>
{site.preview ? (
<div class="preview-bar" role="status">
<span>
<strong>Preview</strong> · unpublished changes, only visible with
your preview link
</span>
<a href={routes.previewExit.href()}>Exit preview</a>
</div>
) : null}
<header class="site-header">
<a class="brand" href={routes.home.href()}>
{config.siteName}
</a>
<nav class="site-nav" aria-label="Main">
{navLink(
routes.galleries.href(),
'Galleries',
meta.nav === 'galleries',
)}
{navLink(routes.about.href(), 'About', meta.nav === 'about')}
{navLink(
routes.contact.index.href(),
'Contact',
meta.nav === 'contact',
)}
</nav>
</header>
<main id="main">{children}</main>
<footer class="site-footer">
<div class="footer-inner">
<p>
© {year} {config.photographerName}
{config.location ? (
<span class="footer-location">
{icon('pin')} {config.location}
</span>
) : null}
</p>
{socials.length > 0 ? (
<ul class="social-links" aria-label="Elsewhere">
{socials.map(([platform, url]) => (
<li>
<a href={url} rel="me noopener" target="_blank">
{socialLabels[platform]}
</a>
</li>
))}
</ul>
) : null}
</div>
</footer>
{site.clientModuleUrl ? (
<script type="module" src={site.clientModuleUrl}></script>
) : null}
</body>
</html>
)
}