Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Jan 15, 2025
1 parent 2119b4e commit 208947c
Showing 1 changed file with 44 additions and 26 deletions.
70 changes: 44 additions & 26 deletions Source/Function/Commit/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@
---
const { user, repo } = Astro.props;
const Last = (
await (
await fetch(
`https://api.github.com/repos/${user}/${repo}/commits?per_page=1`,
)
).json()
)[0];
const Last = await (
await fetch(
`https://api.github.com/repos/${user}/${repo}/commits?per_page=10`,
)
).json();
---

<div>
{
Last && (
Last.length > 0 ? (
<>
<p>
<strong>Message:</strong> {Last.commit.message}
</p>
<h1>Latest Commits</h1>

<h2>
{user}/{repo}
</h2>

<p>
<strong>Author:</strong> {Last.commit.author.name}
</p>
{Last.map(
(Commit: {
message: string;
author: {
name: string;
date: string;
};
html_url: string;
}) => (
<div>
<p>
<strong>Message:</strong> {Commit.message}
</p>

<p>
<strong>Date:</strong>{" "}
{new Date(Last.commit.author.date).toLocaleDateString()}
</p>
<p>
<strong>Author:</strong> {Commit.author.name}
</p>
<p>
<strong>Date:</strong>{" "}
{new Date(
Commit.author.date,
).toLocaleDateString()}
</p>

<a
href={Last.html_url}
target="_blank"
rel="noopener noreferrer">
View on GitHub
</a>
<a
href={Commit.html_url}
target="_blank"
rel="noopener noreferrer">
View on GitHub
</a>
</div>
),
)}
</>
) : (
<p>No commits found.</p>
)
}

{!Last && <p>No commits found.</p>}
</div>

0 comments on commit 208947c

Please sign in to comment.