Store and publish annotations on the web, as described in the Web Annotation Discovery proposal.

web-annotation-discovery-se.../routes/render/ renderCollection.ts
23 lines
687 B

  1. import type { Request, Response } from 'express';
  2. import { escapeHtml } from '../util.js';
  3. export function renderCollection(req: Request, res: Response, { collection, container, user }) {
  4. const nicestName = collection.label || container.name || '';
  5. res.render('collection', {
  6. title: `Annotation collection “${nicestName}” of ${user}`,
  7. collection,
  8. nicestName,
  9. user,
  10. head: `
  11. <link
  12. rel="alternate"
  13. type='application/ld+json; profile="http://www.w3.org/ns/anno.jsonld"'
  14. href=""
  15. title="${escapeHtml(nicestName)}"
  16. />
  17. `,
  18. json: JSON.stringify(collection, null, 2),
  19. annotations: collection.first.items,
  20. });
  21. }