mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-18 13:59:26 +00:00
[website] Fix document commit date fetch (#26622)
fix github api commits request refactor using new URL() object format for readability
This commit is contained in:
parent
dc5d16a399
commit
cd96919edd
2 changed files with 10 additions and 4 deletions
|
|
@ -177,8 +177,7 @@ export const LATEST_GETH_RELEASE_URL =
|
||||||
'https://api.github.com/repos/ethereum/go-ethereum/releases/latest';
|
'https://api.github.com/repos/ethereum/go-ethereum/releases/latest';
|
||||||
export const ALL_GETH_COMMITS_URL = 'https://api.github.com/repos/ethereum/go-ethereum/commits/';
|
export const ALL_GETH_COMMITS_URL = 'https://api.github.com/repos/ethereum/go-ethereum/commits/';
|
||||||
export const RELEASE_COMMIT_BASE_URL = 'https://github.com/ethereum/go-ethereum/tree/';
|
export const RELEASE_COMMIT_BASE_URL = 'https://github.com/ethereum/go-ethereum/tree/';
|
||||||
export const LAST_COMMIT_BASE_URL =
|
export const LAST_COMMIT_BASE_URL = 'https://api.github.com/repos/ethereum/go-ethereum/commits';
|
||||||
'https://api.github.com/repos/ethereum/go-ethereum/commits/website?path=';
|
|
||||||
|
|
||||||
// Binaries urls
|
// Binaries urls
|
||||||
export const BINARIES_BASE_URL = 'https://gethstore.blob.core.windows.net/builds/';
|
export const BINARIES_BASE_URL = 'https://gethstore.blob.core.windows.net/builds/';
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,19 @@ export const getLastModifiedDate = async (filePath: string) => {
|
||||||
// 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
|
// 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
|
Authorization: 'Token ' + process.env.GITHUB_TOKEN_READ_ONLY
|
||||||
});
|
});
|
||||||
|
const urlWithIndex = new URL(LAST_COMMIT_BASE_URL);
|
||||||
|
urlWithIndex.searchParams.set('path', `${filePath}/index.md`);
|
||||||
|
urlWithIndex.searchParams.set('page', '1');
|
||||||
|
urlWithIndex.searchParams.set('per_page', '1');
|
||||||
|
urlWithIndex.searchParams.set('sha', 'website');
|
||||||
|
const urlWithoutIndex = new URL(urlWithIndex);
|
||||||
|
urlWithoutIndex.searchParams.set('path', `${filePath}.md`);
|
||||||
|
|
||||||
return fetch(`${LAST_COMMIT_BASE_URL}${filePath}/index.md&page=1&per_page=1`, { headers })
|
return fetch(urlWithIndex, { headers })
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(commits => commits[0].commit.committer.date)
|
.then(commits => commits[0].commit.committer.date)
|
||||||
.catch(_ =>
|
.catch(_ =>
|
||||||
fetch(`${LAST_COMMIT_BASE_URL}${filePath}.md&page=1&per_page=1`, { headers })
|
fetch(urlWithoutIndex, { headers })
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(commits => commits[0].commit.committer.date)
|
.then(commits => commits[0].commit.committer.date)
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue