feat: Add global utils functions

This commit is contained in:
Lucàs
2023-06-26 15:38:04 +02:00
parent 74b9e3560b
commit cbb5e9e54f
3 changed files with 26 additions and 0 deletions
+6
View File
@@ -1,4 +1,6 @@
---
import UrlUtils from '../libs/UrlUtils.astro';
import DocumentSelector from '../libs/DocumentSelector.astro';
export interface Props {
title: string;
}
@@ -19,4 +21,8 @@ const {title} = Astro.props;
<body>
<slot/>
</body>
<UrlUtils/>
<DocumentSelector/>
</html>
+6
View File
@@ -0,0 +1,6 @@
---
---
<script is:inline>
const $ = (selector) => document.querySelector(selector)
</script>
+14
View File
@@ -0,0 +1,14 @@
---
---
<script is:inline>
const getUrlParams = (defaultParams = {}) => {
let params = {...defaultParams};
const urlParams = new URLSearchParams(window.location.search);
urlParams.forEach((value, key) => {
if (key && value) params[key] = value
})
return params
}
</script>