Formatting + moved search index fetching to top level

This commit is contained in:
squidfunk
2021-02-24 18:02:09 +01:00
parent cb723d4bef
commit d6317dc514
69 changed files with 404 additions and 328 deletions

View File

@@ -20,6 +20,8 @@
* IN THE SOFTWARE.
*/
import { configuration } from "~/_"
/* ----------------------------------------------------------------------------
* Functions
* ------------------------------------------------------------------------- */
@@ -88,3 +90,18 @@ export function hash(value: string): number {
}
return h
}
/**
* Add a digest to a value to ensure uniqueness
*
* When a single account hosts multiple sites on the same GitHub Pages domain,
* entries would collide, because session and local storage are not unique.
*
* @param value - Value
*
* @returns Value with digest
*/
export function digest(value: string): string {
const config = configuration()
return `${value}[${hash(config.base)}]`
}