apply custom favicons
This commit is contained in:
parent
9fc3a9130b
commit
bd300578b6
@ -2,7 +2,7 @@ import { DOCUMENT } from '@angular/common';
|
|||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { ApiService } from '@app/services/api.service';
|
import { ApiService } from '@app/services/api.service';
|
||||||
import { SeoService } from '@app/services/seo.service';
|
import { SeoService } from '@app/services/seo.service';
|
||||||
import { StateService } from '@app/services/state.service';
|
import { Customization, StateService } from '@app/services/state.service';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
@ -51,6 +51,7 @@ export class EnterpriseService {
|
|||||||
if (this.stateService.env.customize?.branding) {
|
if (this.stateService.env.customize?.branding) {
|
||||||
const info = this.stateService.env.customize?.branding;
|
const info = this.stateService.env.customize?.branding;
|
||||||
this.insertMatomo(info.site_id);
|
this.insertMatomo(info.site_id);
|
||||||
|
this.setFavicons(this.stateService.env.customize);
|
||||||
this.seoService.setCustomMeta(this.stateService.env.customize);
|
this.seoService.setCustomMeta(this.stateService.env.customize);
|
||||||
this.seoService.setEnterpriseTitle(info.title, true);
|
this.seoService.setEnterpriseTitle(info.title, true);
|
||||||
this.info$.next(info);
|
this.info$.next(info);
|
||||||
@ -68,6 +69,50 @@ export class EnterpriseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setFavicons(customize: Customization): void {
|
||||||
|
const enterprise = customize.enterprise;
|
||||||
|
const head = this.document.getElementsByTagName('head')[0];
|
||||||
|
|
||||||
|
const faviconLinks = [
|
||||||
|
{
|
||||||
|
rel: 'apple-touch-icon',
|
||||||
|
sizes: '180x180',
|
||||||
|
href: `/resources/${enterprise}/favicons/apple-touch-icon.png`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rel: 'icon',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '32x32',
|
||||||
|
href: `/resources/${enterprise}/favicons/favicon-32x32.png`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rel: 'icon',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '16x16',
|
||||||
|
href: `/resources/${enterprise}/favicons/favicon-16x16.png`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rel: 'manifest',
|
||||||
|
href: `/resources/${enterprise}/favicons/site.webmanifest`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rel: 'shortcut icon',
|
||||||
|
href: `/resources/${enterprise}/favicons/favicon.ico`
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
faviconLinks.forEach(linkInfo => {
|
||||||
|
let link = this.document.querySelector(`link[rel="${linkInfo.rel}"]${linkInfo.sizes ? `[sizes="${linkInfo.sizes}"]` : ''}`) as HTMLLinkElement;
|
||||||
|
if (!link) {
|
||||||
|
link = this.document.createElement('link');
|
||||||
|
head.appendChild(link);
|
||||||
|
}
|
||||||
|
Object.entries(linkInfo).forEach(([attr, value]) => {
|
||||||
|
link.setAttribute(attr, value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
insertMatomo(siteId?: number): void {
|
insertMatomo(siteId?: number): void {
|
||||||
let statsUrl = '//stats.mempool.space/';
|
let statsUrl = '//stats.mempool.space/';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user