aboutsummaryrefslogtreecommitdiffstats
path: root/dist
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2023-02-18 15:36:08 +0100
committerivarlovlie <git@ivarlovlie.no>2023-02-18 15:36:08 +0100
commitfd6c3380f628c4de4e313c53152366a4484feeca (patch)
treee458bec875b6c60e88bd909152059a4d89c498e6 /dist
parent69d345b334c7a3fecdb0cd5f440fabd83a755309 (diff)
downloadauroraklinikken.no-fd6c3380f628c4de4e313c53152366a4484feeca.tar.xz
auroraklinikken.no-fd6c3380f628c4de4e313c53152366a4484feeca.zip
feat: build app not package
Diffstat (limited to 'dist')
-rw-r--r--dist/sanity-client.d.ts1
-rw-r--r--dist/sanity-client.js8
-rw-r--r--dist/utils.js30
3 files changed, 39 insertions, 0 deletions
diff --git a/dist/sanity-client.d.ts b/dist/sanity-client.d.ts
new file mode 100644
index 0000000..e0f8358
--- /dev/null
+++ b/dist/sanity-client.d.ts
@@ -0,0 +1 @@
+export declare const sanity: import("@sanity/client").SanityClient;
diff --git a/dist/sanity-client.js b/dist/sanity-client.js
new file mode 100644
index 0000000..4415100
--- /dev/null
+++ b/dist/sanity-client.js
@@ -0,0 +1,8 @@
+import { env } from "$env/dynamic/private";
+import createSanityClient from "@sanity/client";
+export const sanity = createSanityClient({
+ projectId: env.SANITY_STUDIO_API_PROJECT_ID,
+ dataset: env.SANITY_STUDIO_API_DATASET,
+ apiVersion: "2022-03-24",
+ useCdn: true,
+});
diff --git a/dist/utils.js b/dist/utils.js
new file mode 100644
index 0000000..d89663e
--- /dev/null
+++ b/dist/utils.js
@@ -0,0 +1,30 @@
+// Replaces the locale slug in a URL.
+//
+// If the `full` argument is set to `true`, the full URL is returned as a string.
+// e.g. https://mywebsite.com/en/blog/article-1 => https://mywebsite.com/de/blog/article-1
+//
+// Otherwise (default) the URL relative to the base is returned.
+// e.g. https://mywebsite.com/en/blog/article-1 => /de/blog/article-1
+export const replaceLocaleInUrl = (url, locale, full = false) => {
+ const [, , ...rest] = url.pathname.split('/');
+ const new_pathname = `/${[locale, ...rest].join('/')}`;
+ if (!full) {
+ return `${new_pathname}${url.search}`;
+ }
+ const newUrl = new URL(url.toString());
+ newUrl.pathname = new_pathname;
+ return newUrl.toString();
+};
+export function fromLocalizedString(localizedString, locale) {
+ if (typeof localizedString === "string")
+ return localizedString;
+ // @ts-ignore
+ if (localizedString[locale])
+ return localizedString[locale];
+ // @ts-ignore
+ if (localizedString["nb"])
+ return localizedString["nb"];
+ // @ts-ignore
+ if (localizedString["en"])
+ return localizedString["en"];
+}