Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-05-29 18:02:18 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-05-29 18:02:18 -0700
commit187faec2dfb7959c536d6847a61be912cff9275e (patch)
tree2875104e6f5c33912dd6cfffb0c36d2982d702ad /src/import_external_resources.js
parentfdf9e0145ee14d4db7004c56d0e5b15cb3461e2d (diff)
Try to simplify trooper counter
Diffstat (limited to 'src/import_external_resources.js')
-rw-r--r--src/import_external_resources.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/import_external_resources.js b/src/import_external_resources.js
new file mode 100644
index 0000000..aba29d2
--- /dev/null
+++ b/src/import_external_resources.js
@@ -0,0 +1,15 @@
+import mapsheets from './assets/images/mapsheets.svg';
+import counters from './assets/images/counters.svg';
+
+const files = {
+ 'mapsheets.svg': mapsheets,
+ 'counters.svg': counters
+}
+
+document.querySelectorAll('use[data-href*=".svg"').forEach(el => {
+ const [filename] = el.dataset.href.match(/.+\.svg/g)
+ , href = el.dataset.href.replace(filename, files[filename].split('/').pop())
+ ;
+
+ el.setAttributeNS(null, 'href', href);
+});