main-site/pages/games.tsx

65 lines
2 KiB
TypeScript
Raw Normal View History

2022-12-03 20:02:13 +00:00
import Head from 'next/head'
import Link from 'next/link'
import styles from '/styles/Home.module.css'
import fsPromises from 'fs/promises'
import path from 'path'
import type { CustomLink, LinkList } from '../interfaces/LinkTypes'
function Servers(props: LinkList) {
const serverList = props.games
return (
<>
<Head>
<title>Neshura Servers</title>
<meta charSet='utf-8' />
<link rel="icon" href="/favicon.ico" />
</Head>
<h1 className={styles.title}>
Server List
</h1>
<p className={styles.description}>
Lists all available Services, probably up-to-date
</p>
<div className={styles.grid}>
{Object.values(serverList).map((item: CustomLink) => {
if (item.href != null) {
return (
<Link key={item.name} href={item.href}>
<a className={styles.contentcard}>
<div className={styles.contenttitle}><h2>{item.name }</h2></div>
<div><p>{item.desc}</p></div>
<div><p>{item.ip }</p></div>
<div className={item.status == "Online" ? styles.contentonline : styles.contentoffline}><p>{item.status}</p></div>
</a>
</Link>
)
}
else {
return (
<a key={item.name} className={styles.contentcardstatic}>
<div className={styles.contenttitle}><h2>{item.name }</h2></div>
<div><p>{item.desc}</p></div>
<div><p>{item.ip}</p></div>
<div className={item.status == "Online" ? styles.contentonline : styles.contentoffline}><p>{item.status}</p></div>
</a>
)
}
}
)}
</div>
</>
)
}
export async function getServerSideProps() {
2022-12-09 21:36:42 +00:00
const filePath = path.join(process.cwd(), '/public/pages.json')
2022-12-03 20:02:13 +00:00
const jsonData = await fsPromises.readFile(filePath)
const list = JSON.parse(jsonData.toString())
return { props: list }
}
export default Servers