Add a footer to the layouts.

This commit is contained in:
Dave Smith-Hayes 2024-03-02 13:09:42 -05:00
parent 5dbcd597cd
commit a6fccd61be
5 changed files with 32 additions and 14 deletions

View File

@ -1,5 +1,6 @@
import { FC } from 'hono/jsx';
import Header from './layout/header';
import Footer from './layout/footer';
const Layout: FC = (props) => {
return (
@ -10,6 +11,7 @@ const Layout: FC = (props) => {
<body>
<Header title={props.siteData.title} />
{props.children}
<Footer title={props.siteData.copyright} />
</body>
</html>
)

View File

@ -0,0 +1,13 @@
import { FC } from 'hono/jsx';
const currentYear = new Date().getFullYear();
const Footer: FC = (props) => {
return (
<footer>
<div>{props.copyright}</div>
</footer>
);
};
export default Footer;

View File

@ -1,4 +1,6 @@
const Header = (props) => {
import { FC } from 'hono/jsx';
const Header: FC = (props) => {
return (
<header>
<div class="title">{props.title}</div>

View File

@ -1,14 +1,12 @@
import { Hono } from 'hono';
import SiteData from './model/SiteData';
import Layout from './frontend/layout';
import { SiteConfig, configMiddleware } from './middleware/config';
const app = new Hono();
app.use(configMiddleware);
app.get('/', (c) => {
const siteData: SiteData = {
title: "Slovocast",
description: "A no-nonsense podcast hosting platform."
};
app.get('/', async (c) => {
const siteData: SiteConfig = await c.get('config');
const layout = (
<Layout siteData={siteData}>

View File

@ -5,18 +5,21 @@ type SiteConfig = {
name: string,
description: string,
baseUrl: string
copyright: string,
};
const currentYear = new Date().getFullYear();
const config: SiteConfig = {
name: "Slovocast",
description: "A no-nonesense Podcast hosting platform.",
baseUrl: "dev.slovocast.com"
baseUrl: "dev.slovocast.com",
copyright: `Copyright ${currentYear} Slovocast`,
};
const configMiddleware = new Hono();
configMiddleware.use((c: Context, next) => {
const configMiddleware = async function(c: Context, next) {
c.set('config', config);
next();
});
await next();
};
export SiteConfig, configMiddleware;
export { SiteConfig, configMiddleware };