* Highlight /about in nav * Refine full frame icon * Add timestamp to /about * Add /about to cmdk menu * Enrich /about content * Make /about categories responsive * Enlarge app nav buttons * Add /about richer categories * Widen main nav buttons * Add more /about category content * Catch db errors in /about * Update key /about image * Add /about avatar * Add jest TextEncoder polyfill * Refactor sidebar text configuration * Show /about hero photo meta * Hoist about content to server page * Hide admin email on small screens * Add basic about page form * Finalize basic /about upsert functionality * Make /about/edit safe for blank templates * Add configuration to hide /about page * Add default /about title text * Add interactive photos to /about edit form * Apply final /about i18n * Ensure /about static optimization * Add CTA for admins to add /about descriptions * Add convenience for accepting full photo urls * Add photo placeholder icon * Show /about empty state when there are no photos * Hide sort control when in app empty state
137 lines
3.4 KiB
TypeScript
137 lines
3.4 KiB
TypeScript
import type { MetadataRoute } from 'next';
|
|
import { getDataForCategoriesCached } from '@/category/cache';
|
|
import {
|
|
ABSOLUTE_PATH_FULL,
|
|
ABSOLUTE_PATH_GRID,
|
|
absolutePathForAlbum,
|
|
absolutePathForCamera,
|
|
absolutePathForFilm,
|
|
absolutePathForFocalLength,
|
|
absolutePathForLens,
|
|
absolutePathForPhoto,
|
|
absolutePathForRecents,
|
|
absolutePathForRecipe,
|
|
absolutePathForTag,
|
|
absolutePathForYear,
|
|
} from '@/app/path';
|
|
import { isTagFavs } from '@/tag';
|
|
import { BASE_URL, GRID_HOMEPAGE_ENABLED } from '@/app/config';
|
|
import { getAllPhotoIdsWithUpdatedAt } from '@/photo/query';
|
|
import {
|
|
getLastModifiedForCategories,
|
|
NULL_CATEGORY_DATA,
|
|
} from '@/category/data';
|
|
|
|
// Cache for 24 hours
|
|
export const revalidate = 86_400;
|
|
|
|
const PRIORITY_HOME = 1;
|
|
const PRIORITY_HOME_VIEW = 0.9;
|
|
const PRIORITY_CATEGORY_SPECIAL = 0.8;
|
|
const PRIORITY_CATEGORY = 0.7;
|
|
const PRIORITY_PHOTO = 0.5;
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const [
|
|
categories,
|
|
photos,
|
|
] = await Promise.all([
|
|
getDataForCategoriesCached().catch(() => NULL_CATEGORY_DATA),
|
|
getAllPhotoIdsWithUpdatedAt().catch(() => []),
|
|
]);
|
|
|
|
const {
|
|
recents,
|
|
years,
|
|
cameras,
|
|
lenses,
|
|
albums,
|
|
tags,
|
|
recipes,
|
|
films,
|
|
focalLengths,
|
|
} = categories;
|
|
|
|
const lastModifiedSite = getLastModifiedForCategories(
|
|
categories,
|
|
photos,
|
|
);
|
|
|
|
return [
|
|
// Homepage
|
|
{
|
|
url: BASE_URL!,
|
|
priority: PRIORITY_HOME,
|
|
lastModified: lastModifiedSite,
|
|
},
|
|
// Grid or full
|
|
{
|
|
url: GRID_HOMEPAGE_ENABLED ? ABSOLUTE_PATH_FULL : ABSOLUTE_PATH_GRID,
|
|
priority: PRIORITY_HOME_VIEW,
|
|
lastModified: lastModifiedSite,
|
|
},
|
|
// Recents
|
|
...recents.map(({ lastModified }) => ({
|
|
url: absolutePathForRecents(),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Years
|
|
...years.map(({ year, lastModified }) => ({
|
|
url: absolutePathForYear(year),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Cameras
|
|
...cameras.map(({ camera, lastModified }) => ({
|
|
url: absolutePathForCamera(camera),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Lenses
|
|
...lenses.map(({ lens, lastModified }) => ({
|
|
url: absolutePathForLens(lens),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Albums
|
|
...albums.map(({ album, lastModified }) => ({
|
|
url: absolutePathForAlbum(album),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Tags
|
|
...tags.map(({ tag, lastModified }) => ({
|
|
url: absolutePathForTag(tag),
|
|
priority: isTagFavs(tag)
|
|
? PRIORITY_CATEGORY_SPECIAL
|
|
: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Recipes
|
|
...recipes.map(({ recipe, lastModified }) => ({
|
|
url: absolutePathForRecipe(recipe),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Films
|
|
...films.map(({ film, lastModified }) => ({
|
|
url: absolutePathForFilm(film),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Focal Lengths
|
|
...focalLengths.map(({ focal, lastModified }) => ({
|
|
url: absolutePathForFocalLength(focal),
|
|
priority: PRIORITY_CATEGORY,
|
|
lastModified,
|
|
})),
|
|
// Photos
|
|
...photos.map(({ id, updatedAt }) => ({
|
|
url: absolutePathForPhoto({ photo: id }),
|
|
priority: PRIORITY_PHOTO,
|
|
lastModified: updatedAt,
|
|
})),
|
|
];
|
|
}
|