feat: allow to define format for page title
respect this config option also when generating static content. closes #376
This commit is contained in:
committed by
Stefan Rotsch
parent
8876d3b1c7
commit
810db6aea6
@@ -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;
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user