Website 1.2.0: starter pages on a new install, and a site icon

A new install had no pages, so the home page and its live preview showed
only the header and footer (found on cross-demo2). The backend now adds the
fixed pages with starter text at startup. Settings -> Site icon sets the
favicon, with a default from the church's colour and initial. The Latest
message's Card layout has its name; the media picker's placeholder has
enough contrast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 08:18:47 +02:00
co-authored by Claude Opus 5.5
parent 6905a19c8c
commit 79e1450df6
18 changed files with 285 additions and 24 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ export function ImagePicker({ value, onChange, label }: { value: string | null;
<span className="block text-sm font-medium text-gray-800">{label}</span>
<div className="mt-1 flex items-center gap-3">
<div className="h-16 w-24 shrink-0 overflow-hidden rounded border border-gray-200 bg-gray-50">
{chosen ? <img src={chosen.url} alt={chosen.alt} className="h-full w-full object-cover" /> : <span className="flex h-full items-center justify-center text-xs text-gray-400">No image</span>}
{chosen ? <img src={chosen.url} alt={chosen.alt} className="h-full w-full object-cover" /> : <span className="flex h-full items-center justify-center text-xs text-gray-600">No image</span>}
</div>
<Btn onClick={() => setOpen(true)}>{value ? "Change" : "Choose"}</Btn>
{value && <Btn kind="link" onClick={() => onChange(null)}>Remove</Btn>}
@@ -8,9 +8,10 @@ import Link from "next/link";
import { useState } from "react";
import { api, canEdit } from "@/admin/api";
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
import { Hourglass, ListOrdered, Search, Settings } from "lucide-react";
import { AppWindow, Hourglass, ListOrdered, Search, Settings } from "lucide-react";
import { ImagePicker } from "@/admin/media";
type Settings = { comingSoonText: string; googleVerification: string | null; bingVerification: string | null };
type Settings = { comingSoonText: string; googleVerification: string | null; bingVerification: string | null; faviconId: string | null };
type PageRow = { id: string; kind: string; title: string; inNav: boolean };
export default function SettingsPage() {
@@ -42,6 +43,18 @@ export default function SettingsPage() {
</div>
<p className="mt-3 text-sm text-gray-600">A Google Business Profile helps people find your church on Google Maps: set one up at business.google.com with the same address as your church details.</p>
</Panel>
<Panel icon={AppWindow} title="Site icon">
<p className="mb-3 text-sm text-gray-600">The little picture in the browser tab and bookmarks. Choose a square picture (512 × 512 pixels is best; a PNG can have a see-through background). Without one, your site uses your church&apos;s icon, or your church&apos;s initial on its colour. This goes live straight away.</p>
<div className="flex flex-wrap items-end gap-6">
<ImagePicker label="Icon" value={s.faviconId} onChange={(faviconId) => setForm({ ...form, faviconId })} />
{/* What the site shows now (the default when none is chosen). */}
<div className="text-sm text-gray-600">
<span className="block font-medium text-gray-800">In use now</span>
<img src={`/site-icon?saved=${encodeURIComponent(settings.data.faviconId ?? "none")}`} alt="" width={32} height={32} className="mt-1 h-8 w-8 rounded" />
</div>
</div>
{fields.faviconId && <p className="mt-2 text-sm text-red-700">{fields.faviconId}</p>}
</Panel>
<Panel icon={Hourglass} title="Coming soon">
<Field label="The line under “Coming soon”" hint="Shown until you first publish your site." error={fields.comingSoonText}>
<input className={inputClass} value={s.comingSoonText} maxLength={300} onChange={(e) => setForm({ ...form, comingSoonText: e.target.value })} />
@@ -26,7 +26,7 @@ const SECTIONS: Record<string, string> = { hero: "Top of the page", serviceTimes
const VARIANT_NAMES: Record<string, string> = {
photo: "Photo", video: "Video", collage: "Collage", split: "Split", text: "Text only", panel: "Panel", strip: "Inline strip", map: "With map",
"image-text": "Image and text", pastor: "With pastor", cards: "Cards", list: "List", bands: "Alternating bands", faces: "Faces", featured: "Featured",
calendar: "Calendar strip", compact: "Compact", banner: "Banner", centred: "Centred", image: "Image background",
calendar: "Calendar strip", card: "Card", compact: "Compact", banner: "Banner", centred: "Centred", image: "Image background",
};
const ALL_VARIANTS: Record<string, string[]> = {
hero: ["photo", "video", "collage", "split", "text"], serviceTimes: ["panel", "strip", "map"], welcome: ["text", "image-text", "pastor"], ministries: ["cards", "list", "bands"],
+10 -1
View File
@@ -6,12 +6,21 @@ import { brandAttributes } from "@crosscode/ui";
import { loadContent } from "@/site/load";
import { PreviewBar } from "@/site/PreviewBar";
/** A short, stable version for the icon's address. */
const iconVersion = (s: string) => {
let h = 0;
for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) | 0;
return (h >>> 0).toString(36);
};
export async function generateMetadata(): Promise<Metadata> {
const c = await loadContent();
const name = c.church?.name ?? "Church Website";
return {
title: { default: name, template: `%s · ${name}` },
icons: c.church?.branding.iconUrl ? { icon: c.church.branding.iconUrl } : undefined,
// 1.2.0: always an icon (app/site-icon): the site's own, the church's, or a default. The
// version changes with it, so browsers don't keep showing an old one.
icons: { icon: `/site-icon?v=${iconVersion(c.favicon ?? c.church?.branding.iconUrl ?? `${c.palette.brand}|${c.church?.shortName ?? c.church?.name ?? ""}`)}` },
// A preview is never indexed (§4).
...(c.mode === "published" && c.preview ? { robots: { index: false, follow: false } } : {}),
};
@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { loadContent } from "@/site/load";
import { localRedirect } from "@/lib/localRedirect";
/**
* 1.2.0: the site's icon (favicon). The one chosen under Settings, else the church's icon from its
* profile, else a default made for the church: its initial on its brand colour (a cross when the
* church isn't known yet). The layout links here with a version, so a new icon shows at once.
*/
export async function GET() {
const c = await loadContent();
if (c.favicon) return localRedirect(c.favicon);
const shared = c.church?.branding.iconUrl;
if (shared && /^https:\/\//.test(shared)) return new NextResponse(null, { status: 303, headers: { Location: shared } });
return new NextResponse(defaultIcon(c.palette.brand, c.palette.onBrand, c.church?.shortName || c.church?.name || null), {
headers: { "Content-Type": "image/svg+xml", "Cache-Control": "public, max-age=300" },
});
}
const rgb = (v: string, otherwise: string) => (/^\d{1,3} \d{1,3} \d{1,3}$/.test(v) ? `rgb(${v.replace(/ /g, ",")})` : otherwise);
function defaultIcon(brand: string, onBrand: string, name: string | null): string {
const bg = rgb(brand, "rgb(31,78,121)");
const fg = rgb(onBrand, "#fff");
const initial = name?.trim().match(/\p{L}|\p{N}/u)?.[0]?.toUpperCase();
const mark = initial
? `<text x="32" y="44" text-anchor="middle" font-family="Georgia, 'Times New Roman', serif" font-size="38" font-weight="700" fill="${fg}">${initial.replace(/[<>&"']/g, "")}</text>`
: `<path d="M28 12h8v12h12v8H36v20h-8V32H16v-8h12z" fill="${fg}"/>`;
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="${bg}"/>${mark}</svg>`;
}
+5 -1
View File
@@ -72,7 +72,11 @@ export type SiteMessage = {
thumbnail: string | null;
};
type Common = { church: Church | null; palette: Palette; style: { fontPairing: string; corners: string }; verification?: { google: string | null; bing: string | null } };
type Common = {
church: Church | null; palette: Palette; style: { fontPairing: string; corners: string }; verification?: { google: string | null; bing: string | null };
/** 1.2.0: the site's own icon (Settings); absent from a backend before 1.2.0. */
favicon?: string | null;
};
export type ComingSoon = Common & { mode: "coming-soon"; template: Template; comingSoonText: string };