mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
feat(header): custom links
This commit is contained in:
parent
2b10bd4510
commit
271e0c5b60
@ -12,6 +12,7 @@ NEXT_PUBLIC_FixedTopServerName=false
|
||||
NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png
|
||||
NEXT_PUBLIC_CustomTitle=NezhaDash
|
||||
NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha.
|
||||
NEXT_PUBLIC_Links="[{"link":"https://github.com/hamster1963/nezha-dash","name":"GitHub"},{"link":"https://buycoffee.top/coffee","name":"Buycoffee☕️"}]"
|
||||
NEXT_PUBLIC_DisableIndex=false
|
||||
NEXT_PUBLIC_BASE_PATH=/
|
||||
NEXT_PUBLIC_ShowTagCount=false
|
||||
|
@ -51,6 +51,7 @@ function Header() {
|
||||
</p>
|
||||
</section>
|
||||
<section className="flex items-center gap-2">
|
||||
<Links />
|
||||
<LanguageSwitcher />
|
||||
<ModeToggle />
|
||||
</section>
|
||||
@ -60,6 +61,37 @@ function Header() {
|
||||
);
|
||||
}
|
||||
|
||||
type links = {
|
||||
link: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
function Links() {
|
||||
const linksEnv = getEnv("NEXT_PUBLIC_Links");
|
||||
|
||||
const links: links[] | null = linksEnv ? JSON.parse(linksEnv) : null;
|
||||
|
||||
if (!links) return null;
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{links.map((link, index) => {
|
||||
return (
|
||||
<a
|
||||
key={index}
|
||||
href={link.link}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1 text-sm font-medium opacity-50 transition-opacity hover:opacity-100"
|
||||
>
|
||||
{link.name}
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// https://github.com/streamich/react-use/blob/master/src/useInterval.ts
|
||||
const useInterval = (callback: () => void, delay: number | null) => {
|
||||
const savedCallback = useRef<() => void>(() => {});
|
||||
|
@ -12,5 +12,6 @@ NEXT_PUBLIC_FixedTopServerName=false
|
||||
NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png
|
||||
NEXT_PUBLIC_CustomTitle=NezhaDash
|
||||
NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha.
|
||||
NEXT_PUBLIC_Links="[{"link":"https://github.com/hamster1963/nezha-dash","name":"GitHub"},{"link":"https://buycoffee.top/coffee","name":"Buycoffee☕️"}]"
|
||||
NEXT_PUBLIC_DisableIndex=false
|
||||
NEXT_PUBLIC_ShowTagCount=false
|
Loading…
Reference in New Issue
Block a user