Improve MineGeo interface and functionality
This commit is contained in:
24
lib/site-settings.ts
Normal file
24
lib/site-settings.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import "server-only";
|
||||
import { cache } from "react";
|
||||
import { admin, required } from "./supabase";
|
||||
import { defaultSiteSettings, type SiteSettings } from "@/shared/site-settings";
|
||||
|
||||
export const getSiteSettings = cache(async (): Promise<SiteSettings> => {
|
||||
const row = required(
|
||||
await admin()
|
||||
.from("site_settings")
|
||||
.select("beta_badge_enabled")
|
||||
.eq("id", true)
|
||||
.single(),
|
||||
);
|
||||
return { betaBadgeEnabled: row.beta_badge_enabled };
|
||||
});
|
||||
|
||||
export async function initialSiteSettings(): Promise<SiteSettings> {
|
||||
try {
|
||||
return await getSiteSettings();
|
||||
} catch {
|
||||
// A settings outage must not block the site from rendering.
|
||||
return defaultSiteSettings;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user