sets the site title based on the configured name
This commit is contained in:
+23
-2
@@ -1,8 +1,10 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, effect, inject } from '@angular/core';
|
||||||
|
import { Title } from '@angular/platform-browser';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
import { NavbarComponent } from './navbar/navbar.component';
|
import { NavbarComponent } from './navbar/navbar.component';
|
||||||
import { MediaPlayerComponent } from './media-player/media-player.component';
|
import { MediaPlayerComponent } from './media-player/media-player.component';
|
||||||
import { FooterComponent } from './footer/footer.component';
|
import { FooterComponent } from './footer/footer.component';
|
||||||
|
import { StationConfigService } from './services/station-config.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -11,4 +13,23 @@ import { FooterComponent } from './footer/footer.component';
|
|||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
styleUrl: './app.scss',
|
styleUrl: './app.scss',
|
||||||
})
|
})
|
||||||
export class App {}
|
export class App {
|
||||||
|
private titleService = inject(Title);
|
||||||
|
private stationConfig = inject(StationConfigService);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
const config = this.stationConfig.config();
|
||||||
|
const fullName = `${config.name_primary} ${config.name_secondary}`.trim();
|
||||||
|
this.titleService.setTitle(fullName);
|
||||||
|
|
||||||
|
// Update favicon to use the station's logo_url.
|
||||||
|
// Meta.updateTag() is unreliable for favicons in some browsers,
|
||||||
|
// so we update the <link> element directly.
|
||||||
|
const faviconEl = document.querySelector('link[rel="icon"]') as HTMLLinkElement | null;
|
||||||
|
if (faviconEl && config.logo_url) {
|
||||||
|
faviconEl.href = config.logo_url;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>RadioStation</title>
|
<title>KMountain Flower Radio</title>
|
||||||
<base href="/" />
|
<base href="/" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||||
|
|||||||
Reference in New Issue
Block a user