plugins/download-counter: stylizable
Massimo Melina committed
Feb 15, 2023 at 17:31 UTC
33b95e6f5a4a430b2437f94a669437cab790b3cc
4 files changed
+7
-7
plugins/download-counter/plugin.js
+3
-2
@@ -1,5 +1,5 @@
1
exports.description = "Counts downloads for each file, and displays the total in the list"
2
-exports.version = 2 // comply to new async init/unload
2
+exports.version = 3 // stylizable
3
exports.apiRequired = 3
4
5
exports.init = async api => {
@@ -28,7 +28,8 @@ exports.init = async api => {
28
}
29
30
return {
31
- frontend_js: 'hits.js',
31
+ frontend_js: 'main.js',
32
+ frontend_css: 'style.css',
33
unload: () => save.flush(), // we may have pending savings
34
middleware: (ctx) =>
35
() => { // execute after other middlewares are done
plugins/download-counter/public/hits.js
deleted
-5
@@ -1,5 +0,0 @@
1
-HFS.onEvent('additionalEntryProps', ({ entry }) => {
2
- const n = entry.hits
3
- if (typeof n === 'number')
4
- return 'Hits: ' + n + ' — '
5
-})
plugins/download-counter/public/main.js
new
+2
@@ -0,0 +1,2 @@
1
+HFS.onEvent('additionalEntryProps', ({ entry: { hits } }) =>
2
+ hits && '<span class="download-counter">' + hits + '</span>')
plugins/download-counter/public/style.css
new
+2
@@ -0,0 +1,2 @@
1
+.download-counter::before { content: "Hits: " }
2
+.download-counter::after { content: " — " }