-
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 #891 from zirreal/robonomics-wiki-test
more fixes
- Loading branch information
Showing
2 changed files
with
59 additions
and
50 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 |
---|---|---|
@@ -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 |
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,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 | ||
|
||
}; |