Skip to content

Commit

Permalink
Merge pull request #891 from zirreal/robonomics-wiki-test
Browse files Browse the repository at this point in the history
more fixes
  • Loading branch information
zirreal authored Sep 23, 2024
2 parents 8af9508 + 2c7b392 commit 5b7a709
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 50 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# env variables used in the project
GITHUB_TOKEN = ''
GSCRIPT_ID = ''
CAPTCHA_ID = 10000000-ffff-ffff-ffff-000000000001 # for localhost
OPENAI_KEY = '' # key for translation goes there
104 changes: 54 additions & 50 deletions src/_data/github.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
const eleventyFetch = require("@11ty/eleventy-fetch");

const getDocs = async () => {
let url = 'https://api.github.com/repos/airalab/robonomics-wiki/contents/src/docs';

try {
let json = await eleventyFetch(url, {
duration: "5d",
type: "json",
fetchOptions: {
headers: {
Accept: "application/vnd.github+jso",
"X-GitHub-Api-Version": "2022-11-28",
Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
},
},
});

return json;
} catch (error) {
console.error(`Fetch failed in github.js. ${error}`);
}
};

module.exports = async function () {
let user = "airalab";
let repo = "robonomics-wiki"
let url = `https://api.github.com/repos/${user}/${repo}/commits`;

const arr = await getDocs();
const result = [];

arr.forEach(async d => {
if(d.name.includes('md')) {
try {
let json = await eleventyFetch(url + `?path=src/docs/${d.name}`, {
duration: "3d",
type: "json",
fetchOptions: {
headers: {
Accept: "application/vnd.github+jso",
"X-GitHub-Api-Version": "2022-11-28",
Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
},
if(process.env.GITHUB_TOKEN) {
const getDocs = async () => {
let url = 'https://api.github.com/repos/airalab/robonomics-wiki/contents/src/docs';

try {
let json = await eleventyFetch(url, {
duration: "5d",
type: "json",
fetchOptions: {
headers: {
Accept: "application/vnd.github+jso",
"X-GitHub-Api-Version": "2022-11-28",
Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
},
});
result.push({name: d.name, author: json[0].commit.author.name, date: json[0].commit.author.date, url: json[0].html_url});
} catch (error) {
console.error(`Fetch failed in github.js. ${error}`);
}
},
});

return json;
} catch (error) {
console.error(`Fetch failed in github.js. ${error}`);
}
})
};

module.exports = async function () {
let user = "airalab";
let repo = "robonomics-wiki"
let url = `https://api.github.com/repos/${user}/${repo}/commits`;

const arr = await getDocs();
const result = [];

arr.forEach(async d => {
if(d.name.includes('md')) {
try {
let json = await eleventyFetch(url + `?path=src/docs/${d.name}`, {
duration: "3d",
type: "json",
fetchOptions: {
headers: {
Accept: "application/vnd.github+jso",
"X-GitHub-Api-Version": "2022-11-28",
Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
},
},
});
result.push({name: d.name, author: json[0].commit.author.name, date: json[0].commit.author.date, url: json[0].html_url});
} catch (error) {
console.error(`Fetch failed in github.js. ${error}`);
}
}
})

return result

};
}

return result

};

0 comments on commit 5b7a709

Please sign in to comment.