Browser extension that demonstrates the Web Annotation Discovery mechanism: subscribe to people’s annotation collections/‘feeds’, to see their notes on the web; and create & publish annotations yourself.

web-annotation-discovery-we.../src/content_script/ discovery.ts
19 lines
693 B

  1. import type { AnnotationSourceDescriptor } from '../storage/AnnotationSource';
  2. import { discoverAnnotationFeeds, discoverEmbeddedAnnotations } from '../discovery';
  3. import { WebAnnotation } from 'web-annotation-utils';
  4. export function discoverAnnotationsEmbeddedAsJSONLD(): WebAnnotation[] {
  5. // TODO data validation
  6. return discoverEmbeddedAnnotations() as WebAnnotation[];
  7. };
  8. // Find any link like this: <link rel="alternate" type='application/ld+json;profile="http://www.w3.org/ns/anno.jsonld"'>
  9. export function discoverAnnotationSources(
  10. ): AnnotationSourceDescriptor[] {
  11. return discoverAnnotationFeeds().map(({ url, title }) => ({
  12. url,
  13. title,
  14. type: 'container',
  15. }));
  16. }