summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/aplayer.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-06-02 10:58:11 +0800
committerEltrac <hi@guhub.cn>2025-06-02 10:58:11 +0800
commit4ded783eeb4fdda0d56525f8e36dd4384f0e3c90 (patch)
tree3986e5f7fec0752205157280d3d6b0d04feccabb /layouts/shortcodes/aplayer.html
parent7fbcc28260a9683e3085b08d462a7407fa8fd62f (diff)
feat: add aPlayer shortcode
Diffstat (limited to 'layouts/shortcodes/aplayer.html')
-rw-r--r--layouts/shortcodes/aplayer.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/layouts/shortcodes/aplayer.html b/layouts/shortcodes/aplayer.html
new file mode 100644
index 00000000..b335e462
--- /dev/null
+++ b/layouts/shortcodes/aplayer.html
@@ -0,0 +1,23 @@
+{{ with resources.Get "css/aplayer.css" }}
+<style>{{ .Content | safeCSS }}</style>
+{{ end }}
+<div id="aplayer{{ with .Get "id" }}-{{ . }}{{ end }}" style="margin: 1rem 0;"></div>
+<script src="https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js"></script>
+<script>
+const ap = new APlayer({
+ container: document.getElementById('aplayer'),
+ audio: [{
+ name: '{{ .Get "name" }}',
+ artist: '{{ .Get "artist" }}',
+ url: '{{ .Get "url" }}',
+ cover: '{{ .Get "cover" }}'
+ }]
+});
+
+ap.on('play', function () {
+ umami.track('🎵 Play music with aPlayer')
+});
+ap.on('ended', function () {
+ umami.track('🎵 Played entiresong with aPlayer')
+});
+</script>