fix(admin): add favicon and page-aware titles

This commit is contained in:
Jakub Zych
2026-10-07 10:39:22 +02:00
parent 9b3e630b6b
commit 5707f97089
8 changed files with 100 additions and 2 deletions

View File

@@ -1,10 +1,15 @@
<script setup lang="ts">
import { computed } from 'vue'
import { computed, watchEffect } from 'vue'
import { RouterView, useRoute } from 'vue-router'
import { documentTitleForRoute } from './app/pageTitle'
import AppShell from './components/shell/AppShell.vue'
const route = useRoute()
const inShell = computed(() => route.meta.shell === true)
watchEffect(() => {
document.title = documentTitleForRoute(route)
})
</script>
<template>

View File

@@ -0,0 +1,42 @@
import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { controllerIdFromPath } from './controllerRoutes'
import { t } from './i18n'
import { recordCrumb } from '../state/useBreadcrumbs'
import { activeEntry } from '../state/useNavigation'
import { settingsEntry } from '../state/useSettings'
const PRODUCT_TITLE = 'SummerCMS'
/** The visible page indicator used before the SummerCMS product name. */
export function pageIndicator(route: RouteLocationNormalizedLoaded): string {
if (route.name === 'login') {
return t('backend::lang.auth.title')
}
if (route.name === 'settings') {
return t('backend::lang.settings.title')
}
if (route.name === 'settings-form') {
return settingsEntry(String(route.params.code ?? ''))?.label ?? String(route.params.code ?? '')
}
if (route.name === 'home') {
return t('backend::lang.nav.empty')
}
if (route.name === 'not-found') {
return t('backend::lang.page.not_found')
}
const plugin = activeEntry(String(route.params.vendor ?? ''), String(route.params.plugin ?? ''))
const controller = controllerIdFromPath(route.path)
const section = plugin?.sideMenu.find((item) => item.controller === controller)
const controllerLabel = section?.label ?? plugin?.label ?? ''
if (route.name === 'create' || route.name === 'record' || route.name === 'preview') {
return recordCrumb.value || controllerLabel
}
return controllerLabel
}
/** Browser title matching WinterCMS's "Current page | Product" pattern. */
export function documentTitleForRoute(route: RouteLocationNormalizedLoaded): string {
const indicator = pageIndicator(route).trim()
return indicator === '' ? PRODUCT_TITLE : `${indicator} | ${PRODUCT_TITLE}`
}