IIIF-Commons / iiif-helpers

MIT License
3 stars 2 forks source link

Added nav date helper for navigating by date #16

Closed stephenwf closed 3 months ago

stephenwf commented 4 months ago

This will produce an object that can be used to create a tree for navigating by decade, year, month or day. It will also optionally choose the best one (based on the first divergence).

Parsing the Cookbook example it can produce the following navigations:

Automatic choice:

1986
  January
    Wed Jan 01 1986
      1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
1987
  January
    Thu Jan 01 1987
      1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide"

By century:

1900 - 1999
  1980 - 1989
    1986
      January
        Wed Jan 01 1986
          1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide (1986-01-01T00:00:00+00:00)
    1987
      January
        Thu Jan 01 1987
          1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide (1987-01-01T00:00:00+00:00)"

By decade:

1980 - 1989
  1986
    January
      Wed Jan 01 1986
        1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
  1987
    January
      Thu Jan 01 1987
        1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

By year:

1986
  January
    Wed Jan 01 1986
      1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
1987
  January
    Thu Jan 01 1987
      1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

By month: (note, this adds year to the labels)

January 1986
  Wed Jan 01 1986
    1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
January 1987
  Thu Jan 01 1987
    1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

By day:

Wed Jan 01 1986
  1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
Thu Jan 01 1987
  1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

The tree structure includes some basic information for rendering:

type T = {
  id: string;
  type: 'day';
  count: number;
  label: InternationalString;
}

And then also numeric representations if you want to build your own labels (e.g. year, day, month numbers)

The final resource includes:

interface DateNavigationResource {
  id: string;
  type: 'Manifest' | 'Canvas';
  label: InternationalString;
  navDate: string;
}
codesandbox-ci[bot] commented 4 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.