pull/1680/head
FonduemangVI 10 months ago
parent 7aff0599ee
commit 97d273312c

@ -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 = '<table>\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 += '</table>\n';
contributors = indentString(contributors, '');
fs.writeFileSync('CONTRIBUTORS.md', `## Contributors\n\n<!-- readme: contributors -start -->\n${contributors}\n<!-- readme: contributors -end -->\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 += '<tr>';
}
const userHtml = `
<td align="center">
<img src="${user.avatar_url}&v=4" style="width: 50px; border-radius: 50%;" alt="${user.login}"/>
<br />
<b><a href="${user.html_url}">${user.login}</a></b>
</td>`;
contributors += indentString(userHtml, ' ');
if ((index + 1) % 5 === 0 || index === response.data.length - 1) {
contributors += '\n</tr>\n';
}
index++;
});
// Fetch the next page
page++;
fetchPage();
})
.catch((error) => {
console.error(`Could not fetch contributors: ${error}`);
});
}
fetchPage();

@ -1,13 +1,7 @@
const axios = require('axios'); const axios = require('axios');
const fs = require('fs'); const fs = require('fs');
// Indentation function let contributors = [];
function indentString(string, indentation) {
return string.split('\n').map(line => indentation + line).join('\n');
}
let contributors = '<table>\n';
let index = 0;
let page = 1; let page = 1;
function fetchPage() { function fetchPage() {
@ -15,10 +9,7 @@ function fetchPage() {
.then((response) => { .then((response) => {
if (response.data.length === 0) { if (response.data.length === 0) {
// No more contributors, write the file // No more contributors, write the file
contributors += '</table>\n'; fs.writeFileSync('CONTRIBUTORS.json', JSON.stringify(contributors, null, 2));
contributors = indentString(contributors, '');
fs.writeFileSync('CONTRIBUTORS.md', `## Contributors\n\n<!-- readme: contributors -start -->\n${contributors}\n<!-- readme: contributors -end -->\n`);
return; return;
} }
@ -26,24 +17,13 @@ function fetchPage() {
// Exclude bots and actions-user // Exclude bots and actions-user
if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user') return; if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user') return;
if (index % 5 === 0) { const userJson = {
contributors += '<tr>'; "title": user.login,
} "image": user.avatar_url,
"url": user.html_url,
const userHtml = ` };
<td align="center">
<img src="${user.avatar_url}&v=4" style="width: 50px; border-radius: 50%;" alt="${user.login}"/>
<br />
<b><a href="${user.html_url}">${user.login}</a></b>
</td>`;
contributors += indentString(userHtml, ' ');
if ((index + 1) % 5 === 0 || index === response.data.length - 1) {
contributors += '\n</tr>\n';
}
index++; contributors.push(userJson);
}); });
// Fetch the next page // Fetch the next page

@ -30,6 +30,7 @@ extra:
extra_css: extra_css:
- stylesheets/extra.css - stylesheets/extra.css
- stylesheets/github-permalink-style.css - stylesheets/github-permalink-style.css
- css/neoteroi-mkdocs.css
markdown_extensions: markdown_extensions:
- attr_list - attr_list
@ -54,6 +55,7 @@ markdown_extensions:
- toc: - toc:
permalink: "" permalink: ""
# toc_depth: 5 # toc_depth: 5
- neoteroi.cards
plugins: plugins:
- include-markdown: - include-markdown:

Loading…
Cancel
Save