From c93befa925337b58f4b0365996953efb49fff47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lohrer?= Date: Tue, 21 Apr 2026 09:22:12 +0200 Subject: [PATCH] =?UTF-8?q?feat(publish):=20buildKind30023=20=C3=BCbernimm?= =?UTF-8?q?t=20a-tags=20aus=20frontmatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/src/core/event.ts | 5 +++++ publish/tests/event_test.ts | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/publish/src/core/event.ts b/publish/src/core/event.ts index 9da8c9d..6c8b39a 100644 --- a/publish/src/core/event.ts +++ b/publish/src/core/event.ts @@ -37,6 +37,11 @@ export function buildKind30023(args: BuildArgs): UnsignedEvent { tags.push(['l', lang, 'ISO-639-1']) } if (clientTag) tags.push(['client', clientTag]) + if (Array.isArray(fm.a)) { + for (const coord of fm.a) { + tags.push(['a', coord, '', 'translation']) + } + } if (additionalTags) tags.push(...additionalTags) return { kind: 30023, diff --git a/publish/tests/event_test.ts b/publish/tests/event_test.ts index 3c2e637..e80c7bb 100644 --- a/publish/tests/event_test.ts +++ b/publish/tests/event_test.ts @@ -92,3 +92,47 @@ Deno.test('buildKind30023: leerer clientTag wird weggelassen', () => { }) assertEquals(ev.tags.some((t) => t[0] === 'client'), false) }) + +Deno.test('buildKind30023: schreibt a-tags aus frontmatter mit marker "translation"', () => { + const fm = { + title: 'T', + slug: 'abc', + date: new Date('2024-01-01T00:00:00Z'), + lang: 'de', + a: [ + '30023:0123456789abcdef:other-slug', + '30023:0123456789abcdef:third-slug', + ], + } as Frontmatter + const ev = buildKind30023({ + fm, + rewrittenBody: 'body', + coverUrl: undefined, + pubkeyHex: '0123456789abcdef', + clientTag: '', + nowSeconds: 1700000000, + }) + const aTags = ev.tags.filter((t) => t[0] === 'a') + assertEquals(aTags, [ + ['a', '30023:0123456789abcdef:other-slug', '', 'translation'], + ['a', '30023:0123456789abcdef:third-slug', '', 'translation'], + ]) +}) + +Deno.test('buildKind30023: ohne a im frontmatter keine a-tags im event', () => { + const fm = { + title: 'T', + slug: 'abc', + date: new Date('2024-01-01T00:00:00Z'), + lang: 'de', + } as Frontmatter + const ev = buildKind30023({ + fm, + rewrittenBody: 'body', + coverUrl: undefined, + pubkeyHex: '0123456789abcdef', + clientTag: '', + nowSeconds: 1700000000, + }) + assertEquals(ev.tags.filter((t) => t[0] === 'a'), []) +})