Skip to content

Commit

Permalink
🔥 Cablage en cours...
Browse files Browse the repository at this point in the history
  • Loading branch information
Funasitien committed Jun 3, 2024
1 parent eccc6ad commit c2db681
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 100 deletions.
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@iconify-json/simple-icons": "^1.1.90",
"astro": "^4.3.1",
"astro-icon": "^1.1.0",
"axios": "^1.7.2",
"tailwindcss": "^3.4.1",
"theme-change": "^2.5.0"
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ interface Props {
title: string;
body: string;
href: string;
img_url: string;
img_alt: string;
}
const { img_url, img_alt ="Icone du jeu", title, body, href } = Astro.props;
Expand Down
9 changes: 6 additions & 3 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"
></script>
<script>
---
import axios from "axios";
---
<!--
<script is:inline>
console.log(axios)
const owner = "TheHubGames",
repo = "hub_games";
Expand Down
58 changes: 58 additions & 0 deletions src/js/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

document.addEventListener("DOMContentLoaded", function () {
const repoOwner = "TheHubGames"; // Remplacez par le nom du propriétaire du dépôt
const repoName = "hub_games"; // Remplacez par le nom du dépôt

const apiUrl = `https://api.github.com/repos/${repoOwner}/${repoName}/releases/latest`;

fetch(apiUrl)
.then((response) => {
if (!response.ok) {
throw new Error(
"Erreur lors de la récupération de la dernière release depuis GitHub"
);
}
return response.json();
})

.then((data) => {
const releasesDiv = document.getElementById("github-releases");
const md = window.markdownit();
document.getElementById("load").style.display = "none";

const releaseContainer = document.createElement("div");
releaseContainer.classList.add(
"card",
"m-2",
"lg:card-side",
"bg-base-300",
"shadow-xl"
);

const firstFewLines = data.body.split("\n").slice(0, 8).join("\n"); // Récupère les 8 premières lignes
const releaseHTML = `<div class="lg:w-1/3 card-body">
<h2 class="news-title accent-content light:base-100 text-4xl-sm"><i class="fa-solid fa-bullhorn"></i> ${
data.name
}</h2>
<div class="news-text neutral-content">${md.render(
firstFewLines
)}</div>
<div class="card-actions justify-end">
<a href="hub_source/MAJ/Derniere_maj" class="btn btn-primary" target="_blank">Lire la suite</a>
</div>
</div>
<!--<figure><img class="mr-6 rounded object-cover hidden lg:block" src="https://hubgames.studio/content/rsrc_maj/1.X.X/" alt="" /></figure>-->`;
releaseContainer.innerHTML = releaseHTML;

releasesDiv.appendChild(releaseContainer);
})
.catch((error) => {
const releasesDiv = document.getElementById("github-releases");
releasesDiv.innerHTML =
"<p>Erreur lors de la récupération de la dernière release depuis GitHub</p>";
console.error(
"Erreur lors de la récupération de la dernière release depuis GitHub",
error
);
});
});
Loading

0 comments on commit c2db681

Please sign in to comment.