From 97d273312c99bc1b9f9e9627cae32080ee187927 Mon Sep 17 00:00:00 2001 From: FonduemangVI <15520607+FonduemangVI@users.noreply.github.com> Date: Thu, 2 May 2024 20:55:29 +1000 Subject: [PATCH] testing --- .github/scripts/update-contributors-backup.js | 58 +++++++++++++++++++ .github/scripts/update-contributors.js | 38 +++--------- mkdocs.yml | 2 + 3 files changed, 69 insertions(+), 29 deletions(-) create mode 100644 .github/scripts/update-contributors-backup.js diff --git a/.github/scripts/update-contributors-backup.js b/.github/scripts/update-contributors-backup.js new file mode 100644 index 000000000..f9067cdd7 --- /dev/null +++ b/.github/scripts/update-contributors-backup.js @@ -0,0 +1,58 @@ +const axios = require('axios'); +const fs = require('fs'); + +// Indentation function +function indentString(string, indentation) { + return string.split('\n').map(line => indentation + line).join('\n'); +} + +let contributors = '\n'; +let index = 0; +let page = 1; + +function fetchPage() { + axios.get(`https://api.github.com/repos/FonduemangVI/Guides/contributors?per_page=100&page=${page}`) + .then((response) => { + if (response.data.length === 0) { + // No more contributors, write the file + contributors += '
\n'; + contributors = indentString(contributors, ''); + + fs.writeFileSync('CONTRIBUTORS.md', `## Contributors\n\n\n${contributors}\n\n`); + return; + } + + response.data.forEach((user) => { + // Exclude bots and actions-user + if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user') return; + + if (index % 5 === 0) { + contributors += ''; + } + + const userHtml = ` + + ${user.login} +
+ ${user.login} +`; + + contributors += indentString(userHtml, ' '); + + if ((index + 1) % 5 === 0 || index === response.data.length - 1) { + contributors += '\n\n'; + } + + index++; + }); + + // Fetch the next page + page++; + fetchPage(); + }) + .catch((error) => { + console.error(`Could not fetch contributors: ${error}`); + }); +} + +fetchPage(); \ No newline at end of file diff --git a/.github/scripts/update-contributors.js b/.github/scripts/update-contributors.js index f9067cdd7..9e7ad8804 100644 --- a/.github/scripts/update-contributors.js +++ b/.github/scripts/update-contributors.js @@ -1,13 +1,7 @@ const axios = require('axios'); const fs = require('fs'); -// Indentation function -function indentString(string, indentation) { - return string.split('\n').map(line => indentation + line).join('\n'); -} - -let contributors = '\n'; -let index = 0; +let contributors = []; let page = 1; function fetchPage() { @@ -15,10 +9,7 @@ function fetchPage() { .then((response) => { if (response.data.length === 0) { // No more contributors, write the file - contributors += '
\n'; - contributors = indentString(contributors, ''); - - fs.writeFileSync('CONTRIBUTORS.md', `## Contributors\n\n\n${contributors}\n\n`); + fs.writeFileSync('CONTRIBUTORS.json', JSON.stringify(contributors, null, 2)); return; } @@ -26,24 +17,13 @@ function fetchPage() { // Exclude bots and actions-user if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user') return; - if (index % 5 === 0) { - contributors += ''; - } - - const userHtml = ` - - ${user.login} -
- ${user.login} -`; - - contributors += indentString(userHtml, ' '); - - if ((index + 1) % 5 === 0 || index === response.data.length - 1) { - contributors += '\n\n'; - } + const userJson = { + "title": user.login, + "image": user.avatar_url, + "url": user.html_url, + }; - index++; + contributors.push(userJson); }); // Fetch the next page @@ -55,4 +35,4 @@ function fetchPage() { }); } -fetchPage(); \ No newline at end of file +fetchPage(); diff --git a/mkdocs.yml b/mkdocs.yml index 7f793b10d..b679d2bbf 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -30,6 +30,7 @@ extra: extra_css: - stylesheets/extra.css - stylesheets/github-permalink-style.css + - css/neoteroi-mkdocs.css markdown_extensions: - attr_list @@ -54,6 +55,7 @@ markdown_extensions: - toc: permalink: "" # toc_depth: 5 + - neoteroi.cards plugins: - include-markdown: