Use shorter date format in title that fits better on narrow tabs
This commit is contained in:
@@ -37,8 +37,6 @@ onMounted(() => {
|
|||||||
document.addEventListener('keydown', handleGlobalKey, { passive: false })
|
document.addEventListener('keydown', handleGlobalKey, { passive: false })
|
||||||
// Set document language via shared util
|
// Set document language via shared util
|
||||||
if (lang) document.documentElement.setAttribute('lang', lang)
|
if (lang) document.documentElement.setAttribute('lang', lang)
|
||||||
// Initialize title
|
|
||||||
document.title = formatTodayString(new Date(calendarStore.now))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -49,7 +47,7 @@ onBeforeUnmount(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => calendarStore.now,
|
() => calendarStore.now,
|
||||||
(val) => {
|
(val) => {
|
||||||
document.title = formatTodayString(new Date(val))
|
document.title = formatTodayString(new Date(val), "short", "short")
|
||||||
},
|
},
|
||||||
{ immediate: false },
|
{ immediate: false },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -185,9 +185,9 @@ function formatDateLong(date, includeYear = false) {
|
|||||||
/**
|
/**
|
||||||
* Format date as today string (e.g., "Monday\nJanuary 15")
|
* Format date as today string (e.g., "Monday\nJanuary 15")
|
||||||
*/
|
*/
|
||||||
function formatTodayString(date) {
|
function formatTodayString(date, weekday = "long", month = "long") {
|
||||||
const formatted = date
|
const formatted = date
|
||||||
.toLocaleDateString(undefined, { weekday: 'long', month: 'long', day: 'numeric' })
|
.toLocaleDateString(undefined, { weekday, month, day: 'numeric' })
|
||||||
.replace(/,? /, '\n')
|
.replace(/,? /, '\n')
|
||||||
return formatted.charAt(0).toUpperCase() + formatted.slice(1)
|
return formatted.charAt(0).toUpperCase() + formatted.slice(1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user