flowershow icon indicating copy to clipboard operation
flowershow copied to clipboard

Clarify use of date vs created field on pages and document it

Open rufuspollock opened this issue 2 years ago • 0 comments

We currently use created as date field even though our spec and most other implementations use date. I suggest created and date move to standard fields for all pages with date. date becomes default. Blog supports using date by default and falling back to created if not date (and this is a default for all pages). Semantics is that date is published/last updated date if different from created.

  • NB: currently lacking a created will lead to a build crash. Seems to me we should avoid this e.g. make created required in contentlayer so error shows up there or use a default date (like today!)
  • I note this behaviour suggests having some internal computed field like "flowershowDate" which we use in our code

Tasks

  • [ ] Shape this issue
  • [ ] Implement the solution 😉

Build crash if missing created date on posts

Get a somewhat obscure error

Error occurred prerendering page "/news". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Error serializing `.data.blogs[9].created` returned from `getStaticProps` in "/[[...slug]]".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.

....

Furthermore final error does not mentiion this at all

> Build error occurred
Error: Export encountered errors on following paths:
	/[[...slug]]: /news
    at /Users/rgrp/src/lifeitself/diginomics/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/src/export/index.ts:737:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

[then lengthy stack-trace]

rufuspollock avatar Jan 22 '23 23:01 rufuspollock