leaflet.pub astro loader
1import type { Client } from "@atcute/client";
2import type { ActorIdentifier } from "@atcute/lexicons";
3import type { XRPCProcedures, XRPCQueries } from "@atcute/lexicons/ambient";
4import type { PubLeafletRichtextFacet } from "./lexicons/index.js";
5
6export interface LiveLeafletLoaderOptions {
7 /**
8 * @description Your repo is your DID (did:plc... or did:web...) or handle (username.bsky.social). You can find this information using: https://pdsls.dev
9 */
10 repo: string;
11}
12
13export interface StaticLeafletLoaderOptions {
14 /**
15 * @description Your repo is your DID (did:plc... or did:web...) or handle (username.bsky.social). You can find this information using: https://pdsls.dev
16 */
17 repo: string;
18 /**
19 * @description The number of records leaflet records to return for getCollection, the default being 50. The range can be from 1 to 100.
20 * @default 50
21 */
22 limit?: number;
23 /**
24 * @description Whether or not the records should be returned in reverse order.
25 * @default undefined
26 */
27 reverse?: boolean;
28}
29
30export interface LeafletDocumentRecord {
31 $type: "pub.leaflet.document";
32 pages: { [x: string]: unknown };
33 title: string;
34 author: string;
35 description: string;
36 publication: string;
37 publishedAt: string;
38}
39
40export interface LeafletDocumentView {
41 rkey: string;
42 cid: string;
43 title: string;
44 description: string;
45 author: string;
46 publication: string;
47 publishedAt: string;
48}
49
50export interface MiniDoc {
51 did: string;
52 handle: string;
53 pds: string;
54 signing_key: string;
55}
56
57export interface CollectionFilter {
58 limit?: number;
59 reverse?: boolean;
60 cursor?: string;
61}
62
63export interface EntryFilter {
64 id?: string;
65}
66
67export interface GetLeafletDocumentsParams {
68 repo: ActorIdentifier;
69 rpc: Client<XRPCQueries, XRPCProcedures>;
70 cursor?: string;
71 limit?: number;
72 reverse?: boolean;
73}
74
75export interface GetSingleLeafletDocumentParams {
76 repo: ActorIdentifier;
77 rpc: Client<XRPCQueries, XRPCProcedures>;
78 id: string;
79}
80
81export interface Facet extends PubLeafletRichtextFacet.Main {}
82export interface RichTextSegment {
83 text: string;
84 facet?: Exclude<Facet["features"], { $type: string }>;
85}
86
87// yoinked from: https://github.com/mary-ext/atcute/blob/trunk/packages/lexicons/lexicons/lib/syntax/handle.ts
88/**
89 * represents a decentralized identifier (DID).
90 */
91export type Did<Method extends string = string> = `did:${Method}:${string}`;