feat: allow to define format for page title

respect this config option also when generating static content.

closes #376
This commit is contained in:
Danny Koppenhagen
2023-06-19 14:44:28 +02:00
committed by Stefan Rotsch
parent 8876d3b1c7
commit 810db6aea6
8 changed files with 34 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
import { useEffect } from "react";
import { radarName } from "../config";
import { setTitle } from "../config";
type SetTitleProps = {
title: string;
@@ -8,7 +8,7 @@ type SetTitleProps = {
export default function SetTitle({ title }: SetTitleProps) {
useEffect(() => {
document.title = `${title} | ${radarName}`;
setTitle(document, title)
}, [title]);
return null;

View File

@@ -23,6 +23,13 @@ export interface ConfigData {
export const radarName =
process.env.REACT_APP_RADAR_NAME || "AOE Technology Radar";
export const radarNameShort = radarName;
export const titleFormat = process.env.REACT_APP_RADAR_TITLE_FORMAT || "%TECHNOLOGY_NAME% | %APP_TITLE%"
export function setTitle(document: Document, title: string) {
document.title = titleFormat
.replace('%TECHNOLOGY_NAME%', title)
.replace('%APP_TITLE%', radarName)
}
export const getItemPageNames = (items: Item[]) =>
items.map((item) => `${item.quadrant}/${item.name}`);