We've been finding ourselves needing a lot of links on Dat sites. For instance, we want a way to specify the issues board for an app, or a place to pay authors.
We're thinking about adding a links
field to the dat.json to keep this unified.
Approach 1, as an array:
{
"title": "Beaker browser homepage",
"links": [
{"rel": "payment", "href": "https://opencollective.com/beaker"},
{"rel": "author", "href": "dat://taravancil.com", "title": "Tara Vancil"},
{"rel": "author", "href": "dat://paulfrazee.com", "title": "Paul Frazee"},
{"rel": "https://archive.org/services/purl/purl/bll/resource/issues-board", "href": "https://github.com/beakerbrowser/beakerbrowser.com/issues"}
]
}
Approach 2, as an object with the "rel" as key:
{
"title": "Beaker browser homepage",
"links": {
"payment": "https://opencollective.com/beaker",
"author": [
{"href": "dat://taravancil.com", "title": "Tara Vancil"},
"dat://paulfrazee.com"
],
"https://archive.org/services/purl/purl/bll/resource/issues-board": "https://github.com/beakerbrowser/beakerbrowser.com/issues"
}
}
Any opinions?
Thinking about this a bit more, I would strongly tend towards approach 2.
In code terms: If I want to get all the authors in the example object...
links.filter(link => link.rel === 'author')
or some other trickery,links.author
.(I think this is exactly what @jondashkyle means by more easily addressable)
In human terms: If you already know how JSON works, you don't need to know what
rel
orhref
mean in approach 2. They are meaningless acronyms (...what do they even stand for?). If you need extra metadata, then sure,href
is a good choice exactly because it's so meaningless. Giving every link a name/purpose will make it a lot easier to "standardize" on specific link types. I for one would want "author" (or even "donate"/"payment"!) links to be universally adopted across the beakerweb :)