mirror of https://github.com/ethereum/go-ethereum
Merge pull request #157 from ethereum/fix-last-edit-timestamp
fix: docs last edit timestamppull/26460/head^2
commit
57b5b1de8d
@ -0,0 +1,8 @@ |
||||
# Algolia |
||||
NEXT_PUBLIC_ALGOLIA_APP_ID= |
||||
NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY= |
||||
NEXT_PUBLIC_ALGOLIA_BASE_SEARCH_INDEX_NAME= |
||||
|
||||
# GitHub API |
||||
# check fine-grained tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens |
||||
GITHUB_TOKEN_READ_ONLY= |
@ -1,7 +1,12 @@ |
||||
import { ALL_GETH_COMMITS_URL } from '../constants'; |
||||
|
||||
export const fetchLatestReleaseCommit = (versionNumber: string) => { |
||||
return fetch(`${ALL_GETH_COMMITS_URL}/${versionNumber}`) |
||||
const headers = new Headers({ |
||||
// About personal access tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens
|
||||
Authorization: 'Token ' + process.env.GITHUB_TOKEN_READ_ONLY |
||||
}); |
||||
|
||||
return fetch(`${ALL_GETH_COMMITS_URL}/${versionNumber}`, { headers }) |
||||
.then(response => response.json()) |
||||
.then(commit => commit.sha.slice(0, 8)); |
||||
}; |
||||
|
@ -0,0 +1,18 @@ |
||||
import { LAST_COMMIT_BASE_URL } from '../constants'; |
||||
|
||||
export const getLastModifiedDate = async (filePath: string) => { |
||||
const headers = new Headers({ |
||||
// About personal access tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens
|
||||
Authorization: 'Token ' + process.env.GITHUB_TOKEN_READ_ONLY |
||||
}); |
||||
|
||||
return fetch(`${LAST_COMMIT_BASE_URL}${filePath}/index.md&page=1&per_page=1`, { headers }) |
||||
.then(res => res.json()) |
||||
.then(commits => commits[0].commit.committer.date) |
||||
.catch(_ => |
||||
fetch(`${LAST_COMMIT_BASE_URL}${filePath}.md&page=1&per_page=1`, { headers }) |
||||
.then(res => res.json()) |
||||
.then(commits => commits[0].commit.committer.date) |
||||
.catch(console.error) |
||||
); |
||||
}; |
Loading…
Reference in new issue