Fix localization on detailed project pages.
All checks were successful
Build and deploy website / build (push) Successful in 34s
All checks were successful
Build and deploy website / build (push) Successful in 34s
Fix way too much padding on <br/> tags. Added some old project entries. Added Project as a convenience type. Added link class to all a tags to easier distinguish links in text. Signed-off-by: Martin Berg Alstad <git@martials.no>
This commit is contained in:
parent
941a93f8a5
commit
b9f7b63aa9
@ -2,6 +2,8 @@
|
||||
import { Image } from "astro:assets"
|
||||
import { type ImageMetadata } from "astro"
|
||||
import BadgeList from "../badge/BadgeList.astro"
|
||||
import LocaleLink from "../links/LocaleLink.astro"
|
||||
import { type NavLink } from "@/utils/linking"
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
@ -9,14 +11,14 @@ interface Props {
|
||||
tags: string[]
|
||||
image: ImageMetadata
|
||||
imageAlt: string
|
||||
linkTo: string
|
||||
linkTo: NavLink
|
||||
}
|
||||
|
||||
const { title, description, tags, image, imageAlt, linkTo } = Astro.props
|
||||
---
|
||||
|
||||
<a
|
||||
href={linkTo}
|
||||
<LocaleLink
|
||||
to={linkTo}
|
||||
class="card bg-base-100 max-w-96 shadow-xl hover:scale-105 transition"
|
||||
>
|
||||
<figure>
|
||||
@ -29,4 +31,4 @@ const { title, description, tags, image, imageAlt, linkTo } = Astro.props
|
||||
<p>{description}</p>
|
||||
<BadgeList tags={tags} />
|
||||
</div>
|
||||
</a>
|
||||
</LocaleLink>
|
||||
|
BIN
src/content/projects/Calendar before and after.png
Normal file
BIN
src/content/projects/Calendar before and after.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
BIN
src/content/projects/Simplify-truths-website.png
Normal file
BIN
src/content/projects/Simplify-truths-website.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
@ -1,12 +0,0 @@
|
||||
---
|
||||
title: "Hotel Service"
|
||||
description: "REST API for managing hotels"
|
||||
heroImage: "./kevin-james.jpg"
|
||||
heroImageAlt: "The homepage of this site"
|
||||
tags: [Rust, Axum, Postgres, REST]
|
||||
source: "https://example.com"
|
||||
createdAt: "2024-09-22"
|
||||
updatedAt: "2024-09-22"
|
||||
---
|
||||
|
||||
Hello
|
16
src/content/projects/hvl-ics-simplifier.mdx
Normal file
16
src/content/projects/hvl-ics-simplifier.mdx
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
title: "API for å forenkle TimeEdit iCalendar filer"
|
||||
description: "Et API som forenkler tittler i ICS filer fra TimeEdit"
|
||||
heroImage: "./Calendar before and after.png"
|
||||
heroImageAlt: "En kalender før og etter APIet har blitt brukt. Venstre side er før, høyre etter."
|
||||
tags: [API, Kotlin, Spring Boot, Tomcat, iCal4j, CI/CD]
|
||||
source: "https://github.com/emberal/hvl_ics_simplifier"
|
||||
createdAt: "2023-08-08"
|
||||
updatedAt: "2024-10-20"
|
||||
---
|
||||
|
||||
Ble lei av hvor vanskelig det var å lese iCalendar filer fra HVL sin kalender i TimeEdit, så jeg lagde et API som gjør det enklere.
|
||||
Data for tittelen blir hentet fra den gamle tittelen.
|
||||
For å finne hvilken type hendselse det er, sjekkes beskrivelsen og lokasjonen.
|
||||
|
||||
APIet er skrevet i Kotlin med Spring boot, og hosted på en selvhostet tomcat server.
|
26
src/content/projects/simplify-truths.mdx
Normal file
26
src/content/projects/simplify-truths.mdx
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
title: "Forenkle sannhetsverdier og sannhetstabeller"
|
||||
description: "Forenkle sannhetsuttrykk og opprette sannhetstabeller"
|
||||
heroImage: "./Simplify-truths-website.png"
|
||||
heroImageAlt: "Nettsiden med en sannhetstabell"
|
||||
tags: [TypeScript, SolidJS, Tailwind css, Nettside, Java, API, Spring Boot, Raspberry Pi, Apache, Tomcat]
|
||||
source: "https://github.com/h600878/martials.no"
|
||||
createdAt: "2022-11-08"
|
||||
updatedAt: "2024-10-20"
|
||||
---
|
||||
{/* TODO change to Rust */}
|
||||
Noen sannhetsverdier kan bli ganske store, og kompliserte. Derfor har jeg laget dette programmet for å forenkle uttrykk mest mulig.
|
||||
Programmet bruker flere kjente metoder for å skrive om uttrykkene. Hvilke uttrykk som er brukt og hvilke endringer de gjorde,
|
||||
kan vises i menyen under søkefeltet.
|
||||
<br />
|
||||
I tillegg til å bare forenkle uttrykk, kan man også generere en sannhetstabell med alle mulige verdier i uttrykket.
|
||||
Hvis man ikke ønsker å forenkle uttrykket, men bare generere tabellen, kan man enkelt skru av forenkling. I tillegg har
|
||||
man muligheten til å filtrere resultat, enten ved å skjule sanne eller usanne verdier. Eller ved å sortere etter sanne
|
||||
eller usanne først.
|
||||
<br />
|
||||
Nettsiden er laget med TypeScript, SolidJS og Tailwind CSS. API-et er laget med Java og Spring Boot.
|
||||
Begge kjører på min egen raspberry pi 4, nettsiden er hostet på en apache2 tjener, mens API-et ligger på en tomcat tjener.
|
||||
<a href={"https://martials.no/simplify-truths.html"}>Lenke til nettsiden.</a>
|
||||
<br />
|
||||
Spørringer kan gjøres mot API-et kan utføres med GET eller POST. API-et returnerer JSON.
|
||||
[Lenke til API-docs](https://api.martials.no/simplify-truths)
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
import ProjectPage from "../../../components/projects/ProjectPage.astro"
|
||||
import ProjectPage from "@/components/projects/ProjectPage.astro"
|
||||
import { type GetStaticPathsResult } from "astro"
|
||||
|
||||
// Prerender the page as static HTML during build
|
||||
@ -7,8 +7,9 @@ export const prerender = true
|
||||
|
||||
export function getStaticPaths(): GetStaticPathsResult {
|
||||
return [
|
||||
{ params: { project: "hotelservice" } },
|
||||
{ params: { project: "homepage" } }
|
||||
{ params: { project: "hvl-ics-simplifier" } },
|
||||
{ params: { project: "homepage" } },
|
||||
{ params: { project: "simplify-truths" } }
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,9 @@ export const prerender = true
|
||||
|
||||
export function getStaticPaths(): GetStaticPathsResult {
|
||||
return [
|
||||
{ params: { project: "hotelservice" } },
|
||||
{ params: { project: "homepage" } }
|
||||
{ params: { project: "hvl-ics-simplifier" } },
|
||||
{ params: { project: "homepage" } },
|
||||
{ params: { project: "simplify-truths" } }
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
@layer base {
|
||||
br {
|
||||
@apply my-4;
|
||||
@apply my-0.5;
|
||||
}
|
||||
|
||||
h1 {
|
||||
@ -20,4 +20,9 @@
|
||||
h2 {
|
||||
@apply text-3xl font-bold mb-2;
|
||||
}
|
||||
|
||||
/* TODO change default style*/
|
||||
a {
|
||||
@apply link
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,5 @@
|
||||
import type { CollectionEntry } from "astro:content"
|
||||
|
||||
export type AbsolutePathname = `/${string}`
|
||||
|
||||
export type Project = CollectionEntry<"projects">
|
||||
|
@ -1,12 +1,18 @@
|
||||
import type { AvailableLanguageTag } from "@/paraglide/runtime.js"
|
||||
import type { AbsolutePathname } from "@/types/types.ts"
|
||||
import type { AbsolutePathname, Project } from "@/types/types.ts"
|
||||
|
||||
interface TranslatedPathnames {
|
||||
nb: AbsolutePathname
|
||||
en: `/en${AbsolutePathname}`
|
||||
}
|
||||
|
||||
export type NavLink = "/" | "/contact" | "/projects" | "/links" | "/hardware"
|
||||
export type NavLink =
|
||||
"/"
|
||||
| "/contact"
|
||||
| "/projects"
|
||||
| `/projects/${Project["id"]}`
|
||||
| "/links"
|
||||
| "/hardware"
|
||||
|
||||
const paths: Set<NavLink> = new Set([
|
||||
"/",
|
||||
@ -34,9 +40,19 @@ for (const path of paths) {
|
||||
export function localizePathname(
|
||||
pathname: NavLink,
|
||||
locale: AvailableLanguageTag
|
||||
) {
|
||||
if (pathnames[pathname]) {
|
||||
return pathnames[pathname][locale]
|
||||
): string {
|
||||
const pathnameParts = pathname.split("/")
|
||||
const firstSegment: AbsolutePathname = `/${pathnameParts[1]}`
|
||||
|
||||
if (pathnames[firstSegment]) {
|
||||
const localizedPathname = pathnames[firstSegment][locale]
|
||||
|
||||
const rest = pathnameParts.slice(2)
|
||||
if (rest.length > 0) {
|
||||
return `${localizedPathname}/${rest.join("/")}`
|
||||
} else {
|
||||
return localizedPathname
|
||||
}
|
||||
}
|
||||
return pathname
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user