Skip to content

Commit

Permalink
Set favicon default url to /favicon.ico and allow to customize it (#713)
Browse files Browse the repository at this point in the history
* feat: allowing larger default integration for datahub's favicon and ME

Revert "feat: allowing larger default integration for datahub's favicon and ME"

This reverts commit 4f960614417ab2ba96f84ea482d107d88fe03f7a.

feat: remove favicon in datafeeder and datahub

* feat: set a customisable favicon for datahub

* feat: move icon to theme section
  • Loading branch information
f-necas authored Jan 9, 2024
1 parent 4bca8ed commit ed6fbd6
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 6 deletions.
1 change: 0 additions & 1 deletion apps/datafeeder/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"tsConfig": "apps/datafeeder/tsconfig.app.json",
"aot": true,
"assets": [
"apps/datafeeder/src/favicon.ico",
"apps/datafeeder/src/assets",
{
"glob": "*",
Expand Down
1 change: 0 additions & 1 deletion apps/datafeeder/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>Datafeeder</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&family=Permanent+Marker&display=swap"
Expand Down
1 change: 0 additions & 1 deletion apps/datahub/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"polyfills": "apps/datahub/src/polyfills.ts",
"tsConfig": "apps/datahub/tsconfig.app.json",
"assets": [
"apps/datahub/src/favicon.ico",
"apps/datahub/src/assets",
{
"glob": "*",
Expand Down
11 changes: 9 additions & 2 deletions apps/datahub/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Component } from '@angular/core'
import { Component, OnInit } from '@angular/core'
import { getThemeConfig } from '@geonetwork-ui/util/app-config'
import { ThemeService } from '@geonetwork-ui/util/shared'

@Component({
selector: 'datahub-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {}
export class AppComponent implements OnInit {
ngOnInit(): void {
const favicon = getThemeConfig().FAVICON
if (favicon) ThemeService.setFavicon(favicon)
}
}
Binary file removed apps/datahub/src/assets/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion apps/datahub/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>Datahub</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand Down
4 changes: 4 additions & 0 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ proxy_path = ""
# More information about the translation can be found in the docs (https://geonetwork.github.io/geonetwork-ui/main/docs/reference/i18n.html)
# languages = ['en', 'fr', 'de']


### VISUAL THEME

# All parameters are expressed in CSS format, see:
Expand Down Expand Up @@ -61,6 +62,9 @@ background_color = "#fdfbff"
# title_font = "'My Custom Title Font', fallback-font-title"
# fonts_stylesheet_url = "https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&family=Permanent+Marker&display=swap"

# Use it to set custom location for the favicon; by default, the path `/favicon.ico` will be used
# favicon = "assets/favicon.ico"

### SEARCH SETTINGS

# This section contains settings used for fine-tuning the search experience
Expand Down
2 changes: 2 additions & 0 deletions libs/util/app-config/src/lib/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export function loadAppConfig() {
'fonts_stylesheet_url',
'thumbnail_placeholder',
'header_background',
'favicon',
],
warnings,
errors
Expand All @@ -204,6 +205,7 @@ export function loadAppConfig() {
TITLE_FONT: parsedThemeSection.title_font,
MAIN_FONT: parsedThemeSection.main_font,
FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
FAVICON: parsedThemeSection.favicon,
} as ThemeConfig)

const parsedSearchSection = parseConfigSection(
Expand Down
1 change: 1 addition & 0 deletions libs/util/app-config/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface ThemeConfig {
MAIN_FONT?: string
TITLE_FONT?: string
FONTS_STYLESHEET_URL?: string
FAVICON?: string
}

export interface SearchPreset {
Expand Down
9 changes: 9 additions & 0 deletions libs/util/shared/src/lib/services/theme.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,13 @@ export class ThemeService {
}
return chroma.hsl(hue % 360, saturation, lightness).css()
}

static setFavicon(faviconPath: string): void {
const link =
document.querySelector("link[rel*='icon']") ||
document.createElement('link')
link['rel'] = 'icon'
link['href'] = faviconPath
document.getElementsByTagName('head')[0].appendChild(link)
}
}

0 comments on commit ed6fbd6

Please sign in to comment.