Skip to content

Commit

Permalink
embed audio
Browse files Browse the repository at this point in the history
  • Loading branch information
trashhalo committed Sep 3, 2022
1 parent be6723e commit 574b2f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-dictionary",
"version": "0.0.1",
"version": "0.0.2",
"type": "module",
"main": "./dist/index.html",
"license": "MIT",
Expand Down
29 changes: 19 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<audio controls><source src="${firstAudio.audio}"></audio>`,
},
],
}
: {
content: "phonetic",
children: [
{
content: result[0].phonetic,
},
],
};
const blocks = [phonetic].concat(
result[0].meanings.map((meaning: any) => {
return {
content: meaning.partOfSpeech,
Expand Down

0 comments on commit 574b2f1

Please sign in to comment.