feat: support alternative logos like png

closes #442
This commit is contained in:
Mathias Schopmans
2024-03-26 09:22:03 +01:00
parent 969306c794
commit d254ec1af6
6 changed files with 20 additions and 9 deletions

View File

@@ -63,6 +63,9 @@ the `about.md` if they do not exist yet.
Place your `logo.svg` and `favicon.ico` in the `public` folder next to the `package.json`. Place your `logo.svg` and `favicon.ico` in the `public` folder next to the `package.json`.
The ideal logo is 150px x 60px. For reference have a look at [public/logo.svg](./public/logo.svg). The ideal logo is 150px x 60px. For reference have a look at [public/logo.svg](./public/logo.svg).
If you want to use a file other than an SVG, copy it to the `public` folder and set the name of the
file as `logoFile` inside the `config.json`. e.g. `"logoFile": "acme-logo.png"`
### Step 3: Configure the radar ### Step 3: Configure the radar
Open the `config.json` file and configure the radar to your needs. Open the `config.json` file and configure the radar to your needs.
@@ -71,6 +74,7 @@ Open the `config.json` file and configure the radar to your needs.
| --------- | ------------------------------------------------------------------------------------------------------------------------------ | | --------- | ------------------------------------------------------------------------------------------------------------------------------ |
| basePath | Set if hosting under a sub-path, otherwise set it to `/`. Default is `/techradar` | | basePath | Set if hosting under a sub-path, otherwise set it to `/`. Default is `/techradar` |
| baseUrl | Set to the full URL, where the radar will be hosted. Will be used for sitemap.xml. `https://www.aoe.com/techradar` | | baseUrl | Set to the full URL, where the radar will be hosted. Will be used for sitemap.xml. `https://www.aoe.com/techradar` |
| logoFile | (optional) Filepath in public folder. Default is `logo.svg` |
| toggles | (optional) Modify the behaviour and contents of the radar. See config below. | | toggles | (optional) Modify the behaviour and contents of the radar. See config below. |
| sections | (optional) Modify the order of sections (`radar`, `tags`, `list`) | | sections | (optional) Modify the order of sections (`radar`, `tags`, `list`) |
| colors | A map of colors for the radar. Can be any valid CSS color value | | colors | A map of colors for the radar. Can be any valid CSS color value |

View File

@@ -2,6 +2,7 @@
"basePath": "/techradar", "basePath": "/techradar",
"baseUrl": "", "baseUrl": "",
"editUrl": "https://github.dev/AOEpeople/techradar/blob/main/radar/{release}/{id}.md", "editUrl": "https://github.dev/AOEpeople/techradar/blob/main/radar/{release}/{id}.md",
"logoFile": "logo.svg",
"toggles": { "toggles": {
"showChart": true, "showChart": true,
"showTagFilter": true, "showTagFilter": true,

6
package-lock.json generated
View File

@@ -4028,9 +4028,9 @@
"dev": true "dev": true
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.715", "version": "1.4.717",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.715.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.717.tgz",
"integrity": "sha512-XzWNH4ZSa9BwVUQSDorPWAUQ5WGuYz7zJUNpNif40zFCiCl20t8zgylmreNmn26h5kiyw2lg7RfTmeMBsDklqg==", "integrity": "sha512-6Fmg8QkkumNOwuZ/5mIbMU9WI3H2fmn5ajcVya64I5Yr5CcNmO7vcLt0Y7c96DCiMO5/9G+4sI2r6eEvdg1F7A==",
"dev": true "dev": true
}, },
"node_modules/emoji-regex": { "node_modules/emoji-regex": {

View File

@@ -1,14 +1,14 @@
import logo from "../../../public/logo.svg";
import styles from "./Footer.module.css"; import styles from "./Footer.module.css";
import { SocialLinks } from "@/components/SocialLinks/SocialLinks"; import { SocialLinks } from "@/components/SocialLinks/SocialLinks";
import { getAppName, getImprintUrl, getLabel } from "@/lib/data"; import { getAppName, getImprintUrl, getLabel, getLogoUrl } from "@/lib/data";
export function Footer() { export function Footer() {
const logoUrl = getLogoUrl();
return ( return (
<div className={styles.footer}> <div className={styles.footer}>
<div className={styles.branding}> <div className={styles.branding}>
<img src={logo.src} className={styles.logo} alt={getAppName()} /> <img src={logoUrl} className={styles.logo} alt={getAppName()} />
<p className={styles.description}>{getLabel("footer")}</p> <p className={styles.description}>{getLabel("footer")}</p>
<SocialLinks className={styles.socialLinks} /> <SocialLinks className={styles.socialLinks} />
</div> </div>

View File

@@ -3,18 +3,19 @@
import Link from "next/link"; import Link from "next/link";
import { usePathname } from "next/navigation"; import { usePathname } from "next/navigation";
import logo from "../../../public/logo.svg";
import styles from "./Logo.module.css"; import styles from "./Logo.module.css";
import { getAppName } from "@/lib/data"; import { getAppName, getLogoUrl } from "@/lib/data";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
export function Logo() { export function Logo() {
const pathname = usePathname(); const pathname = usePathname();
const appName = getAppName(); const appName = getAppName();
const logoUrl = getLogoUrl();
return ( return (
<Link href="/" className={cn(styles.logo, pathname != "/" && styles.small)}> <Link href="/" className={cn(styles.logo, pathname != "/" && styles.small)}>
<img src={logo.src} className={cn(styles.src)} alt={appName} /> <img src={logoUrl} className={cn(styles.src)} alt={appName} />
<span className={styles.subline}>{appName}</span> <span className={styles.subline}>{appName}</span>
</Link> </Link>
); );

View File

@@ -3,6 +3,7 @@ import config from "./config";
import { format } from "@/lib/format"; import { format } from "@/lib/format";
import { Flag, Item, Quadrant, Ring } from "@/lib/types"; import { Flag, Item, Quadrant, Ring } from "@/lib/types";
import { assetUrl } from "@/lib/utils";
export function getLabel(key: keyof typeof config.labels) { export function getLabel(key: keyof typeof config.labels) {
return config.labels[key] || ""; return config.labels[key] || "";
@@ -20,6 +21,10 @@ export function getAppName() {
return getLabel("title"); return getLabel("title");
} }
export function getLogoUrl() {
return assetUrl("/" + config.logoFile);
}
export function getChartConfig() { export function getChartConfig() {
return config.chart; return config.chart;
} }