From 574b2f173c82516828b5c327960dad0f74c973a4 Mon Sep 17 00:00:00 2001 From: Stephen Solka Date: Sat, 3 Sep 2022 08:05:38 -0400 Subject: [PATCH] embed audio --- package.json | 2 +- src/main.ts | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3d93aa1..dbea7a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "logseq-dictionary", - "version": "0.0.1", + "version": "0.0.2", "type": "module", "main": "./dist/index.html", "license": "MIT", diff --git a/src/main.ts b/src/main.ts index 7d9735c..5e9b2e3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,16 +31,25 @@ async function main() { if (result.message) { throw new Error("word not found"); } - const blocks = [ - { - content: "phonetic", - children: [ - { - content: result[0].phonetic, - }, - ], - }, - ].concat( + const firstAudio = result[0].phonetics.find((p: any) => p.audio); + const phonetic = firstAudio + ? { + content: "phonetic", + children: [ + { + content: `${firstAudio.text}\n`, + }, + ], + } + : { + content: "phonetic", + children: [ + { + content: result[0].phonetic, + }, + ], + }; + const blocks = [phonetic].concat( result[0].meanings.map((meaning: any) => { return { content: meaning.partOfSpeech,