import fs from 'node:fs/promises'
import path from 'node:path'
import Link from 'next/link'
import styles from '~/styles/index.module.css'
import sharp from 'sharp'
const mimes = {
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
png: 'image/png',
bmp: 'image/bmp',
gif: 'image/gif'
}
export default async function Index() {
const buttonDir = 'images/buttons/'
const buttonFiles = (await fs.readdir(path.join(process.cwd(), buttonDir)).catch(() => {}) || [])
.filter(buttonName => buttonName.match(/\.(png|gif|jpg|jpeg)$/))
const buttonLinks = (await fs.readFile(path.join(process.cwd(), 'images/buttons/urls.txt'), {encoding: 'utf8'}).catch(() => {}) || '')
.split('\n').filter(line => !!line)
.map(line => line.match(/^([^:]+):\s+(.*)$/))
.filter(match => !!match)
.reduce((acc,[_, name, url]) => ({...acc, [name]: url}), {})
const buttons = await Promise.all(buttonFiles.map(async buttonFile => {
const origImageData = await fs.readFile(path.join(process.cwd(), buttonDir, buttonFile))
let preview = null
const metadata = await sharp(origImageData, {pages: -1}).metadata()
// Generate preview if there's more than one frame
if(metadata.pages > 1) {
preview = await sharp(origImageData, {pages: 1})
.png({quality: 80, force: true})
.toBuffer()
}
return {
name: buttonFile.split('.').slice(0, -1).join('.'),
mime: mimes[buttonFile.split('.').at(-1)] || 'image/*',
url: buttonLinks[buttonFile],
data: origImageData.toString('base64'),
preview: preview?.toString('base64')
}
}))
const friendButtons = buttons.filter(button => button.name !== 'tempest')
const ourButton = buttons.filter(button => button.name === 'tempest')[0]
return (
<>
Hi, we're tempest! We're a median plural
system of six members, but most of the time you'll probably see us
operating as one
We like coding, VR, and making CG art
At a glance
Pronouns:
they/it
Cohort:
millenial
Orientation:
ace . . . ish
Partners:
several
Children:
two
Capitalize name:
not unless we're at work
Note: This is the information for our system in aggregate,
for individual info see our about page
{friendButtons.length > 0 && (
Friends and other neighbors:
{ourButton &&
}
{friendButtons.map(button => {
const image =
const preview = button.preview ?
: null
if(button.url)
return (
{image}{preview}
)
else
return (
{image}{preview}
)
})}