-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from zirreal/robonomics-wiki-test
github api
- Loading branch information
Showing
1 changed file
with
54 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
const eleventyFetch = require("@11ty/eleventy-fetch"); | ||
|
||
// const getDocs = async () => { | ||
// let url = 'https://api.github.com/repos/airalab/robonomics-wiki/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}`, | ||
// }, | ||
// }, | ||
// }); | ||
// 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 | ||
|
||
// }; | ||
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}`, | ||
}, | ||
}, | ||
}); | ||
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 | ||
|
||
}; |