#5 Repos are now displayed on the webpage - Additional stlying required.

This commit is contained in:
Luke Else 2025-02-09 17:35:54 +00:00
parent 712d7857db
commit 9da13b76d3
6 changed files with 47 additions and 31 deletions

View File

@ -6,6 +6,7 @@ node_modules
.git .git
.gitattributes .gitattributes
.gitea
.eslintignore .eslintignore
.eslintrc.cjs .eslintrc.cjs

View File

@ -95,6 +95,21 @@
box-shadow: .3em .3em .3em var(--header); box-shadow: .3em .3em .3em var(--header);
} }
.container {
padding-top: 3em;
max-width: 90%;
margin: auto;
}
.cards {
display: flex;
flex-wrap: wrap;
flex-direction: row;
gap: 3em 3em;
padding: 2em 0em 2em 0em;
transition: all 0.2s;
}
@keyframes animationName { @keyframes animationName {
0% { opacity:0; } 0% { opacity:0; }
50% { opacity:1; } 50% { opacity:1; }

View File

@ -1,12 +1,12 @@
import type { GitRepo } from "../types"; import type { GitRepo } from "../types";
const API_BASE_URL = "https://git.luke-else.co.uk/api/v1"; const API_BASE_URL = "https://git.luke-else.co.uk/api/v1";
// const ACCESS_TOKEN = import.meta.env.VITE_GITEA_TOKEN;
export async function fetchRepos(): Promise<GitRepo[]> { export async function fetchRepos(): Promise<GitRepo[]> {
try { try {
console.log("Fetching repos..."); console.log("Fetching repos...");
const response = await fetch(`${API_BASE_URL}/repos/search`, { const response = await fetch(`${API_BASE_URL}/repos/search?sort=updated&order=desc&limit=12`, {
headers: { headers: {
// "Authorization": `token ${ACCESS_TOKEN}`, // "Authorization": `token ${ACCESS_TOKEN}`,
"Content-Type": "application/json" "Content-Type": "application/json"

View File

@ -1,8 +1,9 @@
export interface GitRepo { export interface GitRepo {
id: number;
name: string; name: string;
full_name: string;
description: string; description: string;
language: string;
size: number;
updated_at: Date;
html_url: string; html_url: string;
private: boolean; private: boolean;
fork: boolean; fork: boolean;

View File

@ -61,22 +61,6 @@
font-size: 1.5em; font-size: 1.5em;
} }
/* Skills Cards CSS */
.container {
padding-top: 3em;
max-width: 90%;
margin: auto;
}
.cards {
display: flex;
flex-wrap: wrap;
flex-direction: row;
gap: 3em 3em;
padding: 2em 0em 2em 0em;
transition: all 0.2s;
}
</style> </style>
{#await getJson('/json/me.json')} {#await getJson('/json/me.json')}

View File

@ -1,20 +1,35 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onMount } from "svelte";
import { repos, loadRepos } from "$lib/stores"; import { repos, loadRepos } from "$lib/stores";
import Card from "$lib/components/Cards/Card.svelte";
onMount(loadRepos); onMount(loadRepos);
</script> </script>
<h1>My Projects</h1> <h1>My Projects</h1>
{#if $repos.length > 0} <div class="container">
<ul> {#if $repos.length > 0}
{#each $repos as repo} <div class="cards">
<li> {#each $repos as repo}
<a href="{repo.html_url}" target="_blank">{repo.name}</a> - {repo.description} <Card>
</li> <div slot="header">
{/each} <h2>{repo.name}</h2>
</ul> {repo.language}
{:else} </div>
<p>Loading repositories...</p> <div slot="content">
{/if} <p class="not-required">{@html repo.description}</p>
</div>
<div slot="footer">
<!-- svelte-ignore a11y-invalid-attribute -->
<a href="{repo.html_url}">{repo.name}</a>
{repo.size}KiB
{repo.updated_at}
</div>
</Card>
{/each}
</div>
{:else}
<p>Loading repositories...</p>
{/if}
</div>