site: ui/ux refresh, seo pass, find/lists indexes, 25 new finds
- newspaper-style masthead (stats | "Unique" | About/Blog) on every page with per-page italic subheader + last-updated date on listing pages; sitewide 42rem reading width - pinterest home (hero + masonry, "load more"); old list view at /index3/ - new pages: /about, /blog, /legal, /find/, /finds/, custom 404 - footer collection links now clickable; "founded" stat replaces "updated" in the masthead - centralised SEO component with per-page json-ld (Review, BlogPosting, Product, Article, CollectionPage, ItemList, BreadcrumbList, etc.); @astrojs/sitemap + @astrojs/rss; robots.txt; promoted finds canonical to their review - memoize getSiteStats() so the masthead/footer counts don't multiply per-page build cost - 25 new daily-finds captures
This commit is contained in:
+126
@@ -0,0 +1,126 @@
|
||||
import { heroes } from './hero';
|
||||
import type { OgImage } from '../components/SEO.astro';
|
||||
|
||||
export type OgFallback = 'reviews' | 'finds' | 'posts' | 'site';
|
||||
|
||||
const SITE_URL = 'https://unique.rzen.dev';
|
||||
|
||||
const FALLBACK_PATHS: Record<OgFallback, string> = {
|
||||
reviews: '/og/reviews.png',
|
||||
finds: '/og/finds.png',
|
||||
posts: '/og/posts.png',
|
||||
site: '/og/default.png',
|
||||
};
|
||||
|
||||
const FALLBACK_DIMS = { width: 1200, height: 630, type: 'image/png' };
|
||||
|
||||
export function buildOgImage(
|
||||
heroId: string | undefined,
|
||||
fallback: OgFallback,
|
||||
alt: string
|
||||
): OgImage {
|
||||
const hero = heroId ? heroes[heroId] : undefined;
|
||||
if (hero?.kind === 'image') {
|
||||
const fmt = hero.src.format;
|
||||
const mime = fmt
|
||||
? `image/${fmt === 'jpg' ? 'jpeg' : fmt}`
|
||||
: undefined;
|
||||
return {
|
||||
url: new URL(hero.src.src, SITE_URL).href,
|
||||
width: hero.src.width,
|
||||
height: hero.src.height,
|
||||
alt,
|
||||
type: mime,
|
||||
};
|
||||
}
|
||||
return {
|
||||
url: new URL(FALLBACK_PATHS[fallback], SITE_URL).href,
|
||||
width: FALLBACK_DIMS.width,
|
||||
height: FALLBACK_DIMS.height,
|
||||
alt,
|
||||
type: FALLBACK_DIMS.type,
|
||||
};
|
||||
}
|
||||
|
||||
export function absoluteUrl(path: string): string {
|
||||
return new URL(path, SITE_URL).href;
|
||||
}
|
||||
|
||||
export type Crumb = { name: string; url: string };
|
||||
|
||||
export function buildBreadcrumbs(crumbs: Crumb[]): Record<string, unknown> {
|
||||
return {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: crumbs.map((c, i) => ({
|
||||
'@type': 'ListItem',
|
||||
position: i + 1,
|
||||
name: c.name,
|
||||
item: absoluteUrl(c.url),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export type ListItem = { url: string; name: string };
|
||||
|
||||
export function buildItemList(
|
||||
items: ListItem[],
|
||||
name?: string
|
||||
): Record<string, unknown> {
|
||||
return {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'ItemList',
|
||||
...(name ? { name } : {}),
|
||||
numberOfItems: items.length,
|
||||
itemListElement: items.map((it, i) => ({
|
||||
'@type': 'ListItem',
|
||||
position: i + 1,
|
||||
name: it.name,
|
||||
url: absoluteUrl(it.url),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export const PERSON_AUTHOR = {
|
||||
'@type': 'Person',
|
||||
name: 'rzen',
|
||||
url: `${SITE_URL}/about/`,
|
||||
};
|
||||
|
||||
export const ORGANIZATION = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Organization',
|
||||
'@id': `${SITE_URL}/#org`,
|
||||
name: 'Unique',
|
||||
url: SITE_URL,
|
||||
logo: `${SITE_URL}/favicon.svg`,
|
||||
};
|
||||
|
||||
export const WEBSITE = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'WebSite',
|
||||
'@id': `${SITE_URL}/#site`,
|
||||
name: 'Unique',
|
||||
url: SITE_URL,
|
||||
description:
|
||||
'A small log of delightful, unique things — products, apps, phenomena, oddities.',
|
||||
publisher: { '@id': `${SITE_URL}/#org` },
|
||||
inLanguage: 'en-US',
|
||||
};
|
||||
|
||||
const SOFTWARE_CATEGORIES = new Set([
|
||||
'apps',
|
||||
'app',
|
||||
'software',
|
||||
'macos-apps',
|
||||
'macos',
|
||||
'ios-apps',
|
||||
'ios',
|
||||
'tools',
|
||||
]);
|
||||
|
||||
export function reviewedItemType(category: string): 'SoftwareApplication' | 'Product' {
|
||||
return SOFTWARE_CATEGORIES.has(category.toLowerCase())
|
||||
? 'SoftwareApplication'
|
||||
: 'Product';
|
||||
}
|
||||
Reference in New Issue
Block a user