@@ -226,7 +226,11 @@ export async function handleListSembleCollections(request: Request, env: Env): P
226226}
227227
228228/**
229- * POST /api/integrations/margin/bookmarks — create an at.margin.bookmark on PDS
229+ * POST /api/integrations/margin/bookmarks — save a page to Margin.
230+ *
231+ * Margin no longer has a distinct bookmark record; bookmarks are an
232+ * at.margin.note with `motivation: 'bookmarking'` (no selector, since the whole
233+ * page is the target) and the description carried in `body.value`.
230234 */
231235export async function handleCreateMarginBookmark ( request : Request , env : Env ) : Promise < Response > {
232236 const session = await getSessionFromRequest ( request , env ) ;
@@ -272,17 +276,22 @@ export async function handleCreateMarginBookmark(request: Request, env: Env): Pr
272276 : [ ] ;
273277
274278 const rkey = generateTID ( ) ;
279+ const description = body . description ?. trim ( ) ;
275280 const record = {
276- $type : 'at.margin.bookmark' ,
277- source : body . url ,
278- title : body . title || undefined ,
279- description : body . description || undefined ,
281+ $type : 'at.margin.note' ,
282+ motivation : 'bookmarking' ,
283+ target : {
284+ source : body . url ,
285+ ...( body . title ? { title : body . title } : { } ) ,
286+ } ,
287+ ...( description ? { body : { value : description , format : 'text/plain' } } : { } ) ,
280288 tags : [ ] ,
289+ generator : { name : 'Skyreader' , homepage : 'https://skyreader.app' } ,
281290 createdAt : new Date ( ) . toISOString ( ) ,
282291 } ;
283292
284293 const pdsClient = createPDSClient ( session ) ;
285- const result = await pdsClient . putRecord ( 'at.margin.bookmark ' , rkey , record ) ;
294+ const result = await pdsClient . putRecord ( 'at.margin.note ' , rkey , record ) ;
286295
287296 if ( ! result . success ) {
288297 return new Response ( JSON . stringify ( { error : result . error } ) , {
0 commit comments