Skip to content

Commit

Permalink
Merge branch 'main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
hjonin committed Feb 6, 2024
2 parents 2126b2a + 637b12e commit 6a74e86
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preproduction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'npm'
- name: Build with Eleventy
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'npm'
- name: Build with Eleventy
run: |
Expand Down
15 changes: 14 additions & 1 deletion _data/awesome.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
const EleventyFetch = require("@11ty/eleventy-fetch");

const compareAwesomeScore = (a, b) => {
return b.awesomeScore - a.awesomeScore;
}

const sortByAwesomeScoreOrName = (a, b) => {
const awesomeScoreDiff = compareAwesomeScore(a, b);
if (awesomeScoreDiff < 0 || awesomeScoreDiff > 0) {
return awesomeScoreDiff;
} else {
return a.name.localeCompare(b.name);
}
}

module.exports = async function () {
const URL = "https://code.gouv.fr/data/awesome-codegouvfr.json";

Expand All @@ -8,5 +21,5 @@ module.exports = async function () {
type: "json"
});

return awesome;
return awesome.toSorted(sortByAwesomeScoreOrName);
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"license": "MIT",
"engines": {
"node": ">=14"
"node": ">=20"
},
"homepage": "https://code.gouv.fr/",
"devDependencies": {
Expand Down
14 changes: 10 additions & 4 deletions public/js/home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(() => {
const dataBaseUrl = `${window.location.origin}/internaldata`;

const random = (items) => {
return items[Math.floor(Math.random() * items.length)];
}
Expand All @@ -8,31 +10,35 @@
const sillSoftwareTitleLink = document.querySelector(".sill .fr-card__title a");
const sillSoftwareImg = document.querySelector(".sill .fr-card__header img");

const sillDetailUrl = `https://code.gouv.fr/sill/detail`;

const getSill = async () => {
const response = await fetch(`${window.location.origin}/internaldata/sill.json`);
const response = await fetch(`${dataBaseUrl}/sill.json`);
return await response.json();
}

getSill().then(softwareList => {
const randomSoftware= random(softwareList);
sillSoftwareTitleLink.textContent = randomSoftware.name;
sillSoftwareTitleLink.href = `https://code.gouv.fr/sill/detail?name=${randomSoftware.name}`;
sillSoftwareTitleLink.href = `${sillDetailUrl}?name=${randomSoftware.name}`;
sillSoftwareImg.src = randomSoftware.logoUrl || randomSoftware.comptoirDuLibreSoftware?.logoUrl;
sillSoftwareImg.alt = logoAltTemplate`${randomSoftware.name}`;
});

const awesomeProjectTitleLink = document.querySelector(".awesome .fr-card__title a");
const awesomeProjectImg = document.querySelector(".awesome .fr-card__header img");

const awesomeUrl = `${window.location.origin}/fr/awesome`;

const getAwesome = async () => {
const response = await fetch(`${window.location.origin}/internaldata/awesome.json`);
const response = await fetch(`${dataBaseUrl}/awesome.json`);
return await response.json();
}

getAwesome().then(awesomeProjects => {
const randomProject= random(awesomeProjects);
awesomeProjectTitleLink.textContent = randomProject.name;
awesomeProjectTitleLink.href = `${window.location.origin}/fr/awesome`;
awesomeProjectTitleLink.href = awesomeUrl;
awesomeProjectImg.src = randomProject.logo;
awesomeProjectImg.alt = logoAltTemplate`${randomProject.name}`;
});
Expand Down

0 comments on commit 6a74e86

Please sign in to comment.