this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

✨ Improve year ranges on work pages

+12 -3
+12 -3
src/pages/works/[work].astro
··· 8 8 import BlockMedia from "./_components/BlockMedia.astro"; 9 9 import BlockParagraph from "./_components/BlockParagraph.astro"; 10 10 import { imageAttrs } from "./media"; 11 + import { differenceInYears } from "date-fns"; 11 12 12 13 export const getStaticPaths = (async () => { 13 14 return await getCollection("works").then((works) => ··· 53 54 const startYear = started?.getFullYear(); 54 55 const endYear = finished?.getFullYear(); 55 56 const year = 56 - startYear && endYear && startYear !== endYear 57 - ? `${startYear}~${endYear}` 58 - : (endYear ?? startYear); 57 + started && !finished && !wip 58 + ? // Still active 59 + `${startYear}~now` 60 + : started && 61 + finished && 62 + differenceInYears(finished, started) > 1 && 63 + startYear !== endYear 64 + ? // Was done over multiple years 65 + `${startYear}~${endYear}` 66 + : // Done within a single year 67 + (endYear ?? startYear); 59 68 60 69 const titleStyle = misc?.title_style ?? ""; 61 70