Paul Kiddle

Generating a URL for the HTML view of a data model is not a trival operation.

A URL represents a reference to a resource, but often it also has context.

For example:
Both of these links might display the same resource, but the second one might have a link back to "see more of paul's posts".

Another example:
These both refer to the same data model, but in very different contexts. In fact, the first refers to a keyed entry in a list, whereas the second is a sub-property of an entry in a different list.

So in order to generate a link we need some extra context. For the first URL, we can generate this by knowing "we want the films list, and the entry under batman" For the second, "we want the film data from an entry in the screenings list, specifically the entry for june 2024".

In code form this might look like this:

getURL('films', { id: 'batman' });
getURL('screening-film', { screeningId: '2024-06' })