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...). 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...). You can find this information using: https://pdsls.dev
16 */
17 repo: string;
18 filter?: string;
19 /**
20 * @default 50
21 */
22 limit?: number;
23}
24
25export interface LeafletDocumentRecord {
26 $type: "pub.leaflet.document";
27 pages: { [x: string]: unknown };
28 title: string;
29 author: string;
30 description: string;
31 publication: string;
32 publishedAt: string;
33}
34
35export interface LeafletDocumentView {
36 rkey: string;
37 cid: string;
38 title: string;
39 description: string;
40 author: string;
41 publication: string;
42 publishedAt: string;
43}
44
45export interface MiniDoc {
46 did: string;
47 handle: string;
48 pds: string;
49 signing_key: string;
50}
51
52export interface CollectionFilter {
53 limit?: number;
54 reverse?: boolean;
55 cursor?: string;
56}
57
58export interface EntryFilter {
59 id?: string;
60}
61
62export interface GetLeafletDocumentsParams {
63 repo: ActorIdentifier;
64 rpc: Client<XRPCQueries, XRPCProcedures>;
65 cursor?: string;
66 limit?: number;
67 reverse?: boolean;
68}
69
70export interface GetSingleLeafletDocumentParams {
71 repo: ActorIdentifier;
72 rpc: Client<XRPCQueries, XRPCProcedures>;
73 id: string;
74}
75
76export interface Facet extends PubLeafletRichtextFacet.Main {}
77export interface RichTextSegment {
78 text: string;
79 facet?: Exclude<Facet["features"], { $type: string }>;
80}
81
82// yoinked from: https://github.com/mary-ext/atcute/blob/trunk/packages/lexicons/lexicons/lib/syntax/handle.ts
83/**
84 * represents a decentralized identifier (DID).
85 */
86export type Did<Method extends string = string> = `did:${Method}:${string}`;