diff --git a/common/spaces/space.ts b/common/spaces/space.ts index 1d62dbf7..b3203666 100644 --- a/common/spaces/space.ts +++ b/common/spaces/space.ts @@ -180,7 +180,9 @@ export class Space extends EventEmitter { async fetchAttachmentList(): Promise { return (await this.space.fetchFileList()).filter( (fileMeta) => - !fileMeta.name.endsWith(".md") && !fileMeta.name.endsWith(".plug.json"), + !fileMeta.name.endsWith(".md") && + !fileMeta.name.endsWith(".plug.json") && + fileMeta.name !== "data.db", ); } diff --git a/plugs/core/attachment.ts b/plugs/core/attachment.ts new file mode 100644 index 00000000..d1285f80 --- /dev/null +++ b/plugs/core/attachment.ts @@ -0,0 +1,7 @@ +import { QueryProviderEvent } from "$sb/app_event.ts"; +import { applyQuery } from "$sb/lib/query.ts"; +import { space } from "$sb/silverbullet-syscall/mod.ts"; + +export async function attachmentQueryProvider({ query }: QueryProviderEvent) { + return applyQuery(query, await space.listAttachments()); +} diff --git a/plugs/core/core.plug.yaml b/plugs/core/core.plug.yaml index 758c8fab..1c51173e 100644 --- a/plugs/core/core.plug.yaml +++ b/plugs/core/core.plug.yaml @@ -66,6 +66,12 @@ functions: command: name: "Editor: Toggle Read Only Mode" + # Attachments + attachmentQueryProvider: + path: ./attachment.ts:attachmentQueryProvider + events: + - query:attachment + # Backlinks indexLinks: path: "./page.ts:indexLinks" diff --git a/website/๐Ÿ”Œ Directive/Query.md b/website/๐Ÿ”Œ Directive/Query.md index 49ce9236..620c2531 100644 --- a/website/๐Ÿ”Œ Directive/Query.md +++ b/website/๐Ÿ”Œ Directive/Query.md @@ -54,6 +54,7 @@ Start writing ` |name |lastModified |contentType |size|perm|type|repo |uri |author |share-support| @@ -199,10 +200,10 @@ from a visual perspective. **Result:** Here you go. This is the result we would like to achieve ๐ŸŽ‰. Did you see how I used `render` and `template/plug` in a query? ๐Ÿš€ -* [[๐Ÿ”Œ Directive]] +* [[๐Ÿ”Œ Directive]] * [[๐Ÿ”Œ Backlinks]] by **Guillermo Vayรก** ([repo](https://github.com/Willyfrog/silverbullet-backlinks)) -* [[๐Ÿ”Œ Collab]] -* [[๐Ÿ”Œ Tasks]] +* [[๐Ÿ”Œ Collab]] +* [[๐Ÿ”Œ Tasks]] * [[๐Ÿ”Œ Share]]