diff --git a/generate.js b/generate.js index 3656698..b71f465 100644 --- a/generate.js +++ b/generate.js @@ -12,14 +12,18 @@ const toAbsolute = (p) => path.resolve(__dirname, p) const template = fs.readFileSync(toAbsolute('dist/index.html'), 'utf-8'); const { render } = await import('./dist/server/entry-server.js'); const { routes } = await import('./dist/assets/routes/routes.js'); +const { content } = await import('./dist/assets/content/content.js'); function generateStaticPages() { for (const { path } of routes) { console.log('path:', path); const appHtml = render(path) + const pageTitle = content[path].title - const html = template.replace(``, appHtml) + const html = template + .replace('', `${pageTitle}`) + .replace(``, appHtml) const filePath = `dist${path}index.html` writeFileSyncRecursive(toAbsolute(filePath), html) diff --git a/index.html b/index.html index 6cff60a..630f7fa 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite React SSG +
diff --git a/src/App.tsx b/src/App.tsx index e7de309..9fb2240 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,10 +2,14 @@ import React from "react"; import { Route, Routes } from 'react-router-dom' import { routes } from './routes/routes' import { content } from "./content/content"; +import { usePageTitle } from "./hooks/use-page-title"; const pages: Record = import.meta.glob('./pages/**/*.tsx', { eager: true }) export function App() { + + usePageTitle(); + return ( <>