UNPKG

@solid-data-modules/bookmarks-rdflib

Version:

A library to manage bookmarks in Solid Pods based on rdflib.js

31 lines 1.04 kB
import { bookm, dct } from "../namespaces.js"; import { rdf } from "@solid-data-modules/rdflib-utils"; export class BookmarkQuery { constructor(bookmarkDoc, store) { this.bookmarkDoc = bookmarkDoc; this.store = store; } queryBookmarks() { const bookmarks = this.store.each(undefined, rdf("type"), bookm("Bookmark"), this.bookmarkDoc); return bookmarks .map((it) => it) .map((it) => { const title = this.store.anyValue(it, dct("title"), undefined, this.bookmarkDoc); if (!title) return null; const bookmarkedUrl = this.store.anyValue(it, bookm("recalls"), undefined, this.bookmarkDoc); if (!bookmarkedUrl) return null; return { uri: it.uri, title, bookmarkedUrl: bookmarkedUrl, }; }) .filter(nonNull); } } function nonNull(value) { return value !== null; } //# sourceMappingURL=BookmarkQuery.js.map