diff --git a/.env b/.env deleted file mode 100644 index a0cdbd6..0000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -DOMAIN="martials.no" -GIT_URL=https://git.$DOMAIN -STATUS_URL="https://status.$DOMAIN/status/home" \ No newline at end of file diff --git a/astro.config.mjs b/astro.config.mjs index 4c63199..f5fef6d 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -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" }) } } }) \ No newline at end of file diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 03b25c1..96a8270 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -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" ---
-
- - - +
+ + + LinkedIn + + {m.status()}
diff --git a/src/components/icons/Gitea.astro b/src/components/icons/Gitea.astro index e03339f..bf988f1 100644 --- a/src/components/icons/Gitea.astro +++ b/src/components/icons/Gitea.astro @@ -7,4 +7,4 @@ interface Props { const { class: clazz } = Astro.props --- - + diff --git a/src/components/icons/PajamasIcon.astro b/src/components/icons/PajamasIcon.astro index 9a715bb..5158da8 100644 --- a/src/components/icons/PajamasIcon.astro +++ b/src/components/icons/PajamasIcon.astro @@ -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 --- - + diff --git a/src/components/links/ExternalLink.astro b/src/components/links/ExternalLink.astro index 94d30ea..33ad3a8 100644 --- a/src/components/links/ExternalLink.astro +++ b/src/components/links/ExternalLink.astro @@ -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") +} --- - +{ iconLeft && iconLeftAriaLabel + ? + - + + : + + + + } + diff --git a/src/components/links/ExternalLinkIconLeft.astro b/src/components/links/ExternalLinkIconLeft.astro new file mode 100644 index 0000000..fef5cb2 --- /dev/null +++ b/src/components/links/ExternalLinkIconLeft.astro @@ -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 +--- + +
+ + + + +
+ diff --git a/src/components/links/ExternalLinkTextOnly.astro b/src/components/links/ExternalLinkTextOnly.astro new file mode 100644 index 0000000..3481d70 --- /dev/null +++ b/src/components/links/ExternalLinkTextOnly.astro @@ -0,0 +1,12 @@ +--- +import type { LinkProps } from "@/types/props" + +interface Props extends LinkProps { +} + +const { href, class: clazz, ...props } = Astro.props +--- + + + + diff --git a/src/components/links/GiteaLink.astro b/src/components/links/GiteaLink.astro index 4f21266..5c9cc14 100644 --- a/src/components/links/GiteaLink.astro +++ b/src/components/links/GiteaLink.astro @@ -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 ---
- - + {m.sourceCode()}
diff --git a/src/components/myLinks/LinkCard.astro b/src/components/myLinks/LinkCard.astro index 8a9851f..218f15a 100644 --- a/src/components/myLinks/LinkCard.astro +++ b/src/components/myLinks/LinkCard.astro @@ -10,10 +10,10 @@ interface Props extends MyLink { const { title, message, url, icon, class: clazz } = Astro.props --- - +
- +
{title}

{message}

diff --git a/src/components/myLinks/myLinks.ts b/src/components/myLinks/myLinks.ts index 3de998b..8d4ba07 100644 --- a/src/components/myLinks/myLinks.ts +++ b/src/components/myLinks/myLinks.ts @@ -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[] diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..d3ccfa6 --- /dev/null +++ b/src/constants.ts @@ -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` diff --git a/src/utils/linking.ts b/src/utils/linking.ts index eeb7fd1..6ba823b 100644 --- a/src/utils/linking.ts +++ b/src/utils/linking.ts @@ -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 }