Add a footer to the layouts.
This commit is contained in:
parent
5dbcd597cd
commit
a6fccd61be
@ -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>
|
||||
)
|
||||
|
13
app/src/frontend/layout/footer.tsx
Normal file
13
app/src/frontend/layout/footer.tsx
Normal 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;
|
@ -1,4 +1,6 @@
|
||||
const Header = (props) => {
|
||||
import { FC } from 'hono/jsx';
|
||||
|
||||
const Header: FC = (props) => {
|
||||
return (
|
||||
<header>
|
||||
<div class="title">{props.title}</div>
|
||||
|
@ -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}>
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user