gdq-archive/frontend/pages/index.tsx

107 lines
3.0 KiB
TypeScript
Raw Normal View History

2021-01-05 15:25:09 +00:00
/**
* Copyright (C) 2019-2021 Carl Kittelberger <icedream@icedream.pw>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2020-08-22 20:25:57 +00:00
import * as React from 'react';
import Head from 'next/head';
import Link from 'next/link';
import ListGroup from 'react-bootstrap/ListGroup';
import { Breadcrumb } from 'react-bootstrap';
import { useIntl } from 'react-intl';
import { FormattedMessage } from '../components/localization';
import { VideoOnDemandIndex } from '../util/datatypes/VideoOnDemandIdentifier';
import { getIndex } from '../util/api';
2021-01-04 16:31:36 +00:00
import { GetServerSideProps, NextPage } from 'next';
2020-08-22 20:25:57 +00:00
2021-01-04 16:31:36 +00:00
interface HomeProps {
index: VideoOnDemandIndex
}
2020-08-22 20:25:57 +00:00
2021-01-04 16:31:36 +00:00
export const getServerSideProps: GetServerSideProps<HomeProps> = async () => {
// Fetch VOD IDs and announcements
2020-08-22 20:25:57 +00:00
return {
props: {
2021-01-04 16:31:36 +00:00
index: await getIndex(),
2020-08-22 20:25:57 +00:00
},
};
}
2021-01-04 16:31:36 +00:00
const Home: NextPage<HomeProps> = ({ index: { announcements, ids } }) => {
2020-08-22 20:25:57 +00:00
const intl = useIntl();
return (
<div>
<Head>
<title>
{intl.formatMessage({
id: 'App.title',
description: 'The full title of the website',
defaultMessage: 'Games Done Quick Instant Archive',
})}
</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Breadcrumb>
<Link passHref href="/">
<Breadcrumb.Item active>
<FormattedMessage
id="Breadcrumb.homeTitle"
defaultMessage="GDQ Instant Archive"
description="Root node text in breadcrumb"
/>
</Breadcrumb.Item>
</Link>
</Breadcrumb>
<h1>
<FormattedMessage
id="Home.introText1"
defaultMessage="Instant access to your favorite VODs of Games Done Quick!"
/>
</h1>
<p>
<FormattedMessage
id="Home.introText2"
defaultMessage="This website collects all the broadcasted runs and allows streaming and downloading them."
/>
</p>
2021-01-03 17:44:30 +00:00
{
announcements.map((text, id) => (
<p key={id}>
<b>Announcement:</b> {text}
2021-01-03 17:44:30 +00:00
</p>
))
}
2020-08-22 20:25:57 +00:00
<ListGroup>
{ids.map(({ id, title }) => (
<Link key={id} passHref href="/[id]" as={`/${id}`}>
<ListGroup.Item action>
<h5>{title}</h5>
</ListGroup.Item>
</Link>
))}
</ListGroup>
</div>
);
}
2021-01-04 16:31:36 +00:00
export default Home;