Skip to content

Commit

Permalink
fixed in project view language change and markdown rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
HWTjac0 committed Jul 6, 2024
1 parent 9216009 commit 026d353
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { getRelativeLocaleUrl } from 'astro:i18n';
const currentLang = getLangFromUrl(Astro.url) as string;
const translate = useTranslations(currentLang);
const translatedURL = getRelativeLocaleUrl(getNextLang(currentLang), "");
const currentPathname = Astro.url.pathname;
const nextPathname = currentPathname.slice(4, currentPathname.length);
const translatedURL = new URL(`/${getNextLang(currentLang)}/${nextPathname}`, Astro.url.origin);
---
<header class="flex items-center justify-between p-2 sm:px-10 sm:py-3">
<h1 class="flex items-center gap-10 text-5xl">
Expand Down
9 changes: 8 additions & 1 deletion src/components/Project.astro
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ if(metadata.ok) {
}
}
finalTitle = placeWhitespaces(finalTitle);
let finalDescription = description;
if(currentLang === "pl") {
finalDescription = c?.description_pl ? c.description_pl : description;
} else {
finalDescription = c?.description_en ? c.description_en : description;
}
---

<div
Expand Down Expand Up @@ -134,7 +141,7 @@ finalTitle = placeWhitespaces(finalTitle);
</div>
</div>
</div>
{description && <p class="line-clamp-2">{description}</p>}
{finalDescription && <p class="line-clamp-2">{finalDescription}</p>}
</div>
<div class="flex items-end justify-between" id="updateDate">
<p class="cursor-help text-sm" title={updateDate}>
Expand Down
10 changes: 8 additions & 2 deletions src/layouts/ProjectLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ if(metadata.ok) {
const lang = getLangFromUrl(Astro.url)
let finalDescription;
if(lang === "pl") {
finalDescription = availableMeta.readmePl ? m?.readmePl : description;
finalDescription = (
availableMeta.readmePl && m?.readmePl.ok ?
m?.readmePl.value :
description);
} else {
finalDescription = availableMeta.readmeEn ? m?.readmeEn : description;
finalDescription = (
availableMeta.readmeEn && m?.readmeEn.ok ?
m?.readmeEn.value :
description);
}
---
Expand Down
6 changes: 4 additions & 2 deletions src/utilities/repoMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ export class Metadata {
}
}
#setReadmePolish(readme: any): Result<string>{
return readme ? Ok(marked(readme[1].text) as string) : Err();
const parsed = marked(readme[1].text).toString();
return readme ? Ok(parsed) : Err();
}
#setReadmeEnglish(readme: any): Result<string>{
return readme ? Ok(marked(readme[1].text) as string) : Err();
const parsed = marked(readme[1].text).toString();
return readme ? Ok(parsed) : Err();
}
}

0 comments on commit 026d353

Please sign in to comment.