Skip to content

Commit

Permalink
Generating static paths for the projects and added layout for the pro…
Browse files Browse the repository at this point in the history
…ject
  • Loading branch information
HWTjac0 committed Nov 18, 2023
1 parent e91570d commit 9eb2cdb
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
---
const current_time = new Date().toLocaleString("en-GB", { timeZone: 'Europe/Warsaw' })
const current_time = new Date().toLocaleString("en-GB", {
timeZone: "Europe/Warsaw",
});
---

<header class="p-2">
<h1 class="font-bold text-4xl">Akai Apps</h1>
<p>Dane aktualizowane ostatni raz: <span class="font-mono" >{current_time}</span></p>
<h1 class="text-4xl font-bold"><a href="/">Akai Apps</a></h1>
<p>
Dane aktualizowane ostatni raz: <span class="font-mono"
>{current_time}</span>
</p>
</header>
25 changes: 25 additions & 0 deletions src/layouts/ProjectLayout.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
import type { Project } from "@utilities/data";
interface Props extends Project {}
const { name, description, stargazerCount, languages, url } = Astro.props;
---

<section>
<div>
<h1>{name}</h1>
<div class="flex">
<p>Ilość gwiazdek: {stargazerCount}</p>
<a href={url} class="text-yellow-500">Sprawdź na githubie</a>
</div>
<ul class="flex gap-1">
{
languages.map((lang) => {
return <li>{lang}</li>;
})
}
</ul>
</div>
<article>
{description}
</article>
</section>
37 changes: 33 additions & 4 deletions src/pages/projects/[name].astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
---
export function getStaticPaths() {
return [
{ params: { name: "placeholder"}},
]
import { getProjects } from "@utilities/data";
import PageLayout from "@layouts/PageLayout.astro";
import ProjectLayout from "@layouts/ProjectLayout.astro";
import type { Project } from "@utilities/data";
type Props = Omit<Project, "name">;
export async function getStaticPaths() {
const projects = await getProjects();
const project_paths = projects.map((project) => {
return {
params: { name: project.name },
props: {
description: project.description,
stargazerCount: project.stargazerCount,
languages: project.languages,
url: project.url,
},
};
});
return project_paths;
}
const { name } = Astro.params;
const { languages, url, stargazerCount, description } = Astro.props;
---

<PageLayout title={name}>
<ProjectLayout
name={name}
languages={languages}
url={url}
stargazerCount={stargazerCount}
description={description}
/>
</PageLayout>

0 comments on commit 9eb2cdb

Please sign in to comment.