Skip to content

Commit

Permalink
refactor: change the writeup header
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Apr 10, 2024
1 parent 352a3f1 commit 467f49c
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/pages/writeups/[ctf]/[year]/[category]/[name].astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ type Props = WriteUp;
const writeup = Astro.props;
const { Content } = await writeup.render();
const items = {
author: writeup.data.author,
category: writeup.category,
points: writeup.data.points,
solves: writeup.data.solves,
};
let maxWidth = Math.max(...Object.keys(items).map((key) => key.length));
---

<PageLayout title={writeup.data.title} description={writeup.data.description}>
Expand Down Expand Up @@ -54,27 +63,21 @@ const { Content } = await writeup.render();
</div>

<section class="animate">
<!-- create table with Points, Solves, points: X \nsolves: X -->
<table class="table-auto">
<tbody>
<tr>
<td class="font-semibold">Category</td>
<td>{writeup.category}</td>
</tr>
<tr>
<td class="font-semibold">Points</td>
<td>{writeup.data.points}</td>
</tr>
<tr>
<td class="font-semibold">Solves</td>
<td>{writeup.data.solves}</td>
</tr>
<tr>
<td class="font-semibold">Author</td>
<td>{writeup.data.author}</td>
</tr>
</tbody>
</table>
<div class="flex flex-col text-left">
{
Object.entries(items).map(([key, value]) => {
const padding = "&nbsp;".repeat(maxWidth - key.length);
return (
<div class="inline">
<span>{key}</span>
<span set:html={padding} />
{" -> "}
<span class="font-semibold">{value}</span>
</div>
);
})
}
</div>
</section>

<article class="animate">
Expand Down

0 comments on commit 467f49c

Please sign in to comment.