mirror of
https://github.com/glassflame/glassflame.github.io.git
synced 2024-11-25 17:44:26 +00:00
Create configuration primitives
This commit is contained in:
parent
d7c579285f
commit
9730c76058
2 changed files with 23 additions and 0 deletions
22
src/config.mjs
Normal file
22
src/config.mjs
Normal 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
1
src/index.mjs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import {} from "./config.mjs"
|
Loading…
Reference in a new issue