chore: update getLastModifiedDate util
This commit is contained in:
parent
9748bdfd0c
commit
ec7773916b
|
@ -5,7 +5,7 @@ import NextLink from 'next/link';
|
||||||
import { GopherHomeFront } from '../components/UI/svgs';
|
import { GopherHomeFront } from '../components/UI/svgs';
|
||||||
import { PageMetadata } from '../components/UI';
|
import { PageMetadata } from '../components/UI';
|
||||||
|
|
||||||
import { METADATA} from '../constants';
|
import { METADATA } from '../constants';
|
||||||
|
|
||||||
const Page404NotFound: NextPage = ({}) => {
|
const Page404NotFound: NextPage = ({}) => {
|
||||||
return (
|
return (
|
||||||
|
@ -13,10 +13,16 @@ const Page404NotFound: NextPage = ({}) => {
|
||||||
<PageMetadata title={METADATA.PAGE_404_TITLE} description={METADATA.PAGE_404_DESCRIPTION} />
|
<PageMetadata title={METADATA.PAGE_404_TITLE} description={METADATA.PAGE_404_DESCRIPTION} />
|
||||||
|
|
||||||
<main id='main-content'>
|
<main id='main-content'>
|
||||||
<Flex direction='column' alignItems='center' py={{ base: 16, md: 24 }} border="2px" borderColor="primary">
|
<Flex
|
||||||
|
direction='column'
|
||||||
|
alignItems='center'
|
||||||
|
py={{ base: 16, md: 24 }}
|
||||||
|
border='2px'
|
||||||
|
borderColor='primary'
|
||||||
|
>
|
||||||
<GopherHomeFront />
|
<GopherHomeFront />
|
||||||
<Text
|
<Text
|
||||||
fontSize={{ base: "8xl", md: "9xl" }}
|
fontSize={{ base: '8xl', md: '9xl' }}
|
||||||
lineHeight='120%'
|
lineHeight='120%'
|
||||||
fontFamily='heading'
|
fontFamily='heading'
|
||||||
textAlign='center'
|
textAlign='center'
|
||||||
|
@ -26,7 +32,7 @@ const Page404NotFound: NextPage = ({}) => {
|
||||||
404
|
404
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
fontSize={{ base: 'xl', md: '2xl'}}
|
fontSize={{ base: 'xl', md: '2xl' }}
|
||||||
fontFamily='heading'
|
fontFamily='heading'
|
||||||
fontWeight='700'
|
fontWeight='700'
|
||||||
textAlign='center'
|
textAlign='center'
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
import { LAST_COMMIT_BASE_URL } from '../constants';
|
import { LAST_COMMIT_BASE_URL } from '../constants';
|
||||||
|
|
||||||
export const getLastModifiedDate = async (filePath: string) =>
|
export const getLastModifiedDate = async (filePath: string) => {
|
||||||
fetch(`${LAST_COMMIT_BASE_URL}${filePath}/index.md&page=1&per_page=1`)
|
const headers = new Headers({
|
||||||
|
// Note: this token expires on Dec 16, 2023
|
||||||
|
// 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
|
||||||
|
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(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`)
|
fetch(`${LAST_COMMIT_BASE_URL}${filePath}.md&page=1&per_page=1`, { 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)
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue