1
Fork 0
mirror of https://github.com/glassflame/glassflame.github.io.git synced 2024-11-25 09:34:27 +00:00

Create configuration primitives

This commit is contained in:
Steffo 2023-10-18 18:11:33 +02:00
parent d7c579285f
commit 9730c76058
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 23 additions and 0 deletions

22
src/config.mjs Normal file
View file

@ -0,0 +1,22 @@
/**
* Get configuration from the given location.
*
* @param location {Location} The location to use to determine the configuration.
* @returns {{file: string, vault: string}}
*/
export function configFromURL(location) {
const queryString = new URLSearchParams(location.search)
const vault = queryString.get("vault")
const file = queryString.get("file")
return {vault, file}
}
/**
* Get configuration from the current {@link window.location}.
*
* @returns {{file: string, vault: string}}
*/
export function configFromWindow() {
return configFromURL(window.location)
}

1
src/index.mjs Normal file
View file

@ -0,0 +1 @@
import {} from "./config.mjs"