"use client"; import { useLiveQuery } from "dexie-react-hooks"; import { getImageUrl } from "@/common/image-utils"; import useDatabase from "../hooks/use-database"; import { Config } from "@ssr/common/config"; export default function BackgroundCover() { const database = useDatabase(); const settings = useLiveQuery(() => database.getSettings()); if (settings == undefined || settings?.backgroundCover == undefined || settings?.backgroundCover == "") { return null; // Don't render anything if the background image is not set } let backgroundCover = settings.backgroundCover; let prependWebsiteUrl = false; // Remove the prepending slash if (backgroundCover.startsWith("/")) { prependWebsiteUrl = true; backgroundCover = backgroundCover.substring(1); } if (prependWebsiteUrl) { backgroundCover = Config.websiteUrl + "/" + backgroundCover; } // Static background color if (backgroundCover.startsWith("#")) { return (
); } return ( // eslint-disable-next-line @next/next/no-img-element Background image ); }