Moved some contstants to a constants.ts file.
Added LinkedIn link in footer. Added option to add icon to ExternalLinks Refactored some code in ExternalLink. Signed-off-by: Martin Berg Alstad <git@martials.no>
This commit is contained in:
parent
b9f7b63aa9
commit
4724b0a0e0
3
.env
3
.env
@ -1,3 +0,0 @@
|
||||
DOMAIN="martials.no"
|
||||
GIT_URL=https://git.$DOMAIN
|
||||
STATUS_URL="https://status.$DOMAIN/status/home"
|
@ -39,10 +39,7 @@ export default defineConfig({
|
||||
}),
|
||||
env: {
|
||||
schema: {
|
||||
DOMAIN: envField.string({ context: "client", access: "public" }),
|
||||
URL: envField.string({ context: "client", access: "public" }),
|
||||
GIT_URL: envField.string({ context: "client", access: "public" }),
|
||||
STATUS_URL: envField.string({ context: "client", access: "public" })
|
||||
URL: envField.string({ context: "client", access: "public" })
|
||||
}
|
||||
}
|
||||
})
|
@ -1,20 +1,19 @@
|
||||
---
|
||||
import GiteaLink from "./links/GiteaLink.astro"
|
||||
import PajamasIcon from "./icons/PajamasIcon.astro"
|
||||
import ExternalLink from "./links/ExternalLink.astro"
|
||||
import LanguageButtonGroup from "./LanguageButtonGroup.astro"
|
||||
import { GIT_URL, STATUS_URL } from "astro:env/client"
|
||||
import * as m from "@/paraglide/messages"
|
||||
|
||||
const giteaLink = `${GIT_URL}/martials/martials.no`
|
||||
import { LINKED_IN_URL, THIS_GIT_URL, STATUS_URL } from "../constants"
|
||||
---
|
||||
|
||||
<div class="divider" />
|
||||
<div class="py-5 flex flex-row gap-1 justify-around w-full items-center">
|
||||
<div>
|
||||
<GiteaLink href={giteaLink} />
|
||||
<ExternalLink href={STATUS_URL} class="flex items-center" title="Status">
|
||||
<PajamasIcon name="pajamas:status-health" class="w-6 h-6 mr-2" />
|
||||
<div class="flex flex-col gap-1">
|
||||
<GiteaLink href={THIS_GIT_URL} />
|
||||
<ExternalLink href={LINKED_IN_URL} iconLeft="pajamas:linkedin" iconLeftAriaLabel="LinkedIn" title="LinkedIn">
|
||||
LinkedIn
|
||||
</ExternalLink>
|
||||
<ExternalLink href={STATUS_URL} iconLeft="pajamas:status-health" iconLeftAriaLabel="Status health" title="Status">
|
||||
{m.status()}
|
||||
</ExternalLink>
|
||||
</div>
|
||||
|
@ -7,4 +7,4 @@ interface Props {
|
||||
const { class: clazz } = Astro.props
|
||||
---
|
||||
|
||||
<PajamasIcon name="pajamas:gitea" class={clazz}></PajamasIcon>
|
||||
<PajamasIcon name="pajamas:gitea" aria-label="Gitea" class={clazz} />
|
||||
|
@ -4,9 +4,10 @@ import type { ComponentProps } from "@/types/props"
|
||||
import { Icon } from "astro-icon/components"
|
||||
interface Props extends ComponentProps {
|
||||
name: PajamasIcon
|
||||
"aria-label": string
|
||||
}
|
||||
|
||||
const { name, class: clazz, ...props } = Astro.props
|
||||
---
|
||||
|
||||
<Icon name={name} class:list={[clazz]} {...props} />
|
||||
<Icon name={name} class:list={["w-6 h-6", clazz]} {...props} />
|
||||
|
@ -1,12 +1,28 @@
|
||||
---
|
||||
import type { LinkProps } from "@/types/props"
|
||||
import type { PajamasIcon } from "@/types/icons"
|
||||
import ExternalLinkTextOnly from "./ExternalLinkTextOnly.astro"
|
||||
import ExternalLinkIconLeft from "./ExternalLinkIconLeft.astro"
|
||||
|
||||
interface Props extends LinkProps {
|
||||
noStyle?: boolean
|
||||
iconLeft?: PajamasIcon
|
||||
iconLeftAriaLabel?: string
|
||||
}
|
||||
|
||||
const { href, noStyle = false, class: clazz, ...props } = Astro.props
|
||||
const { iconLeft, iconLeftAriaLabel, ...props } = Astro.props
|
||||
if (iconLeft && !iconLeftAriaLabel) {
|
||||
throw new Error("ExternalLink: iconLeftAriaLabel is required when iconLeft is provided")
|
||||
}
|
||||
---
|
||||
|
||||
<a href={href} target="_blank" rel="noopener" class:list={[noStyle ? "" : "link", clazz]} {...props}>
|
||||
{ iconLeft && iconLeftAriaLabel
|
||||
?
|
||||
<ExternalLinkIconLeft iconLeft={iconLeft} iconLeftAriaLabel={iconLeftAriaLabel} {...props}>
|
||||
<slot />
|
||||
</a>
|
||||
</ExternalLinkIconLeft>
|
||||
:
|
||||
<ExternalLinkTextOnly {...props}>
|
||||
<slot />
|
||||
</ExternalLinkTextOnly>
|
||||
}
|
||||
|
||||
|
20
src/components/links/ExternalLinkIconLeft.astro
Normal file
20
src/components/links/ExternalLinkIconLeft.astro
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
import type { PajamasIcon as PajamasIconType } from "@/types/icons"
|
||||
import type { LinkProps } from "@/types/props"
|
||||
import ExternalLinkTextOnly from "./ExternalLinkTextOnly.astro"
|
||||
import PajamasIcon from "../icons/PajamasIcon.astro"
|
||||
|
||||
interface Props extends LinkProps {
|
||||
iconLeft: PajamasIconType
|
||||
iconLeftAriaLabel: string
|
||||
}
|
||||
const { href, class: clazz, iconLeft, iconLeftAriaLabel, ...props } = Astro.props
|
||||
---
|
||||
|
||||
<div class="flex items-center">
|
||||
<PajamasIcon name={iconLeft} aria-label={iconLeftAriaLabel} class="mr-2" />
|
||||
<ExternalLinkTextOnly href={href} class={clazz} {...props}>
|
||||
<slot />
|
||||
</ExternalLinkTextOnly>
|
||||
</div>
|
||||
|
12
src/components/links/ExternalLinkTextOnly.astro
Normal file
12
src/components/links/ExternalLinkTextOnly.astro
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
import type { LinkProps } from "@/types/props"
|
||||
|
||||
interface Props extends LinkProps {
|
||||
}
|
||||
|
||||
const { href, class: clazz, ...props } = Astro.props
|
||||
---
|
||||
|
||||
<a href={href} target="_blank" rel="noopener" class:list={[clazz]} {...props}>
|
||||
<slot />
|
||||
</a>
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
import ExternalLink from "./ExternalLink.astro"
|
||||
import * as m from "@/paraglide/messages"
|
||||
import Gitea from "../icons/Gitea.astro"
|
||||
interface Props {
|
||||
href: string
|
||||
}
|
||||
@ -9,8 +8,7 @@ const { href } = Astro.props
|
||||
---
|
||||
|
||||
<div>
|
||||
<ExternalLink href={href} class="flex items-center gap-1">
|
||||
<Gitea class="w-6 h-6" />
|
||||
<ExternalLink iconLeft="pajamas:gitea" iconLeftAriaLabel="Gitea" href={href}>
|
||||
{m.sourceCode()}
|
||||
</ExternalLink>
|
||||
</div>
|
||||
|
@ -10,10 +10,10 @@ interface Props extends MyLink {
|
||||
const { title, message, url, icon, class: clazz } = Astro.props
|
||||
---
|
||||
|
||||
<ExternalLink href={url} noStyle>
|
||||
<ExternalLink href={url}>
|
||||
<div class:list={["card bg-neutral", clazz]}>
|
||||
<div class="card-body p-5 flex flex-row items-center">
|
||||
<PajamasIcon name={icon ?? "pajamas:link"} class="w-6 h-6" />
|
||||
<PajamasIcon name={icon ?? "pajamas:link"} aria-label={icon ? title : "Link"} />
|
||||
<div>
|
||||
<h5 class="card-title">{title}</h5>
|
||||
<p class="prose">{message}</p>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { PajamasIcon } from "@/types/icons.ts"
|
||||
import { GIT_URL } from "astro:env/client"
|
||||
import * as m from "@/paraglide/messages"
|
||||
import * as c from "@/constants.ts"
|
||||
|
||||
export interface MyLink {
|
||||
title: string;
|
||||
@ -12,35 +12,35 @@ export interface MyLink {
|
||||
export default [
|
||||
{
|
||||
title: "GitHub",
|
||||
url: "https://github.com/emberal",
|
||||
url: c.GITHUB_PROFILE_URL,
|
||||
icon: "pajamas:github"
|
||||
},
|
||||
{
|
||||
title: "Gitea",
|
||||
url: `${GIT_URL}/martials`,
|
||||
url: c.GIT_PROFILE_URL,
|
||||
message: m.forPersonalProjects(),
|
||||
icon: "pajamas:gitea"
|
||||
},
|
||||
{
|
||||
title: "LinkedIn",
|
||||
url: "https://www.linkedin.com/in/martin-b-2a69391a3/",
|
||||
url: c.LINKED_IN_URL,
|
||||
icon: "pajamas:linkedin"
|
||||
},
|
||||
{
|
||||
title: "Mastodon (Snabelen)",
|
||||
url: "https://snabelen.no/@Martials",
|
||||
url: c.MASTODON_URL,
|
||||
icon: "pajamas:mastodon"
|
||||
},
|
||||
{
|
||||
title: "Pixelfed",
|
||||
url: "https://pixelfed.social/i/web/profile/261454857934868480"
|
||||
url: c.PIXELFED_URL
|
||||
},
|
||||
{
|
||||
title: "Steam",
|
||||
url: "https://steamcommunity.com/id/martials/"
|
||||
url: c.STEAM_URL
|
||||
},
|
||||
{
|
||||
title: "Trakt.tv",
|
||||
url: "https://trakt.tv/users/martials"
|
||||
url: c.TRAKT_URL
|
||||
}
|
||||
] satisfies MyLink[]
|
||||
|
11
src/constants.ts
Normal file
11
src/constants.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export const DOMAIN = "martials.no"
|
||||
export const LINKED_IN_URL = "https://www.linkedin.com/in/martin-b-2a69391a3"
|
||||
export const GIT_BASE_URL = `https://git.${DOMAIN}`
|
||||
export const GIT_PROFILE_URL = `${GIT_BASE_URL}/martials`
|
||||
export const GITHUB_PROFILE_URL = "https://github.com/emberal"
|
||||
export const MASTODON_URL = "https://snabelen.no/@Martials"
|
||||
export const PIXELFED_URL = "https://pixelfed.social/i/web/profile/261454857934868480"
|
||||
export const STEAM_URL = "https://steamcommunity.com/id/martials/"
|
||||
export const THIS_GIT_URL = `${GIT_BASE_URL}/martials/martials.no`
|
||||
export const TRAKT_URL = "https://trakt.tv/users/martials"
|
||||
export const STATUS_URL = `https://status.${DOMAIN}/status/home`
|
@ -58,8 +58,9 @@ export function localizePathname(
|
||||
}
|
||||
|
||||
export function resolvePathname(pathname: string): AbsolutePathname {
|
||||
if (pathname.startsWith("/en")) {
|
||||
return pathname.slice(3) as AbsolutePathname
|
||||
const enPattern = "/en"
|
||||
if (pathname.startsWith(enPattern)) {
|
||||
return pathname.slice(enPattern.length) as AbsolutePathname
|
||||
}
|
||||
return pathname as AbsolutePathname
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user