diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-11-18 19:16:53 -0800 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-11-18 19:16:53 -0800 |
commit | 4716cffa3e60483bb60d3c877f10d07b839001a0 (patch) | |
tree | cacf58d8b3612cb7ba6becf2036f8c8015a2ca1a | |
parent | 2c6944ee4057490e1f3c3dea7e48a23b4658beea (diff) | |
download | www-4716cffa3e60483bb60d3c877f10d07b839001a0.tar www-4716cffa3e60483bb60d3c877f10d07b839001a0.tar.gz www-4716cffa3e60483bb60d3c877f10d07b839001a0.tar.bz2 www-4716cffa3e60483bb60d3c877f10d07b839001a0.zip |
Use string template for hitokoto
Thanks to Pop: string template does not work for scripts in HTML but only standalone script due to HtmlWebpackPlugin
-rw-r--r-- | neo/src/index.html | 14 | ||||
-rw-r--r-- | neo/src/index.js | 12 |
2 files changed, 12 insertions, 14 deletions
diff --git a/neo/src/index.html b/neo/src/index.html index ec90934..a8e112f 100644 --- a/neo/src/index.html +++ b/neo/src/index.html @@ -6,20 +6,6 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"> <title>Yuuta Liang</title> - <script> - document.addEventListener("DOMContentLoaded", () => { - fetch('https://yuuta.moe/quote/') - .then((response) => response.json()) - .then((data) => { - const q = document.querySelector('#quote'); - q.title = data.text_zh; - q.innerHTML = data.text; - const t = document.querySelector('#quote_title'); - t.title = data.title_zh; - t.innerHTML = data.title; - }); - }); - </script> </head> <body> diff --git a/neo/src/index.js b/neo/src/index.js index e69de29..1b3c3ff 100644 --- a/neo/src/index.js +++ b/neo/src/index.js @@ -0,0 +1,12 @@ +document.addEventListener("DOMContentLoaded", () => { + fetch('https://yuuta.moe/quote/') + .then((response) => response.json()) + .then((data) => { + const q = document.querySelector('#quote'); + q.title = data.text_zh; + q.innerHTML = `「${data.text}」`; + const t = document.querySelector('#quote_title'); + t.title = data.title_zh; + t.innerHTML = `—— ${data.title}`; + }); +}); |