move other options to ENV

This commit is contained in:
Lio 2024-07-23 19:55:50 +02:00
parent a0d7b52ccb
commit 2d354e8401
3 changed files with 24 additions and 7 deletions

View file

@ -1,19 +1,20 @@
---
import config from "../../config.yaml";
import { Boolify } from "../lib/boolify";
const { href, text, icon } = Astro.props;
const useIcons = Boolify(import.meta.env.PUBLIC_USEICONS);
---
{
config.socialIcons && (
useIcons && (
<a href={href} target="_blank" rel="noopener noreferrer">
<i class={`fa-brands fa-${icon ? icon : text.toLowerCase()}`} />
<i class={`fa-brands fa-${icon ? icon : text.toLowerCase()} fa-2xl`} />
</a>
)
}
{
!config.socialIcons && (
!useIcons && (
<a href={href} target="_blank" rel="noopener noreferrer">
<i class={`fa-brands fa-${icon ? icon : text.toLowerCase()}`} />
{text}
</a>
)
}

View file

@ -1,5 +1,4 @@
---
import config from "../../config.yaml";
import pb from "../lib/pb";
export const prerender = false
const backgroundRec = await pb.collection('images').getFirstListItem('useAsBackground=true');
@ -15,7 +14,7 @@ const background = await pb.files.getUrl(backgroundRec, backgroundRec.file);
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<meta name="generator" content={Astro.generator} />
<title>{config.title}</title>
<title>{import.meta.env.PUBLIC_TITLE}</title>
</head>
<body>
<slot />

17
src/lib/boolify.ts Normal file
View file

@ -0,0 +1,17 @@
var BoolArray = [true, false, 'true', 'false', 1, 0];
const isBoolean = function (arg) {
if (BoolArray.indexOf(arg) === -1) {
return false;
} else {
return true;
}
}
const Boolify = function (arg) {
if (BoolArray.indexOf(arg) === -1) {
return null;
} else {
return (arg == true || arg == 'true' || arg == 1) ? true : false;
}
}
export { isBoolean, Boolify };