Slightly prettier analytics URL
This commit is contained in:
+2
-2
@@ -196,8 +196,8 @@ with a "could not be loaded" message.
|
|||||||
Because it is a real page, fetch-navigation handles it like any other internal
|
Because it is a real page, fetch-navigation handles it like any other internal
|
||||||
link: clicking the 📊 pen (or any link to `/_a`) fetches the server-rendered
|
link: clicking the 📊 pen (or any link to `/_a`) fetches the server-rendered
|
||||||
HTML, swaps the dynamic regions and mounts the Vue analytics app in place. The
|
HTML, swaps the dynamic regions and mounts the Vue analytics app in place. The
|
||||||
range selector updates the URL query string (`?range=week` etc.) so links to
|
range selector updates the URL hash (`#week` etc.) so links to a specific
|
||||||
a specific range can be shared.
|
range can be shared.
|
||||||
|
|
||||||
`AnalyticsView.vue` is no longer a full-screen overlay; the `body.analytics-open`
|
`AnalyticsView.vue` is no longer a full-screen overlay; the `body.analytics-open`
|
||||||
page-chrome hiding and `#/analytics/<range>` hash routing have been removed.
|
page-chrome hiding and `#/analytics/<range>` hash routing have been removed.
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ const range = ref(RANGES[props.initialRange] ? props.initialRange : 'week')
|
|||||||
// Keep the URL shareable when the range changes.
|
// Keep the URL shareable when the range changes.
|
||||||
watch(range, (r) => {
|
watch(range, (r) => {
|
||||||
const url = new URL(location.href)
|
const url = new URL(location.href)
|
||||||
url.searchParams.set('range', r)
|
url.hash = r
|
||||||
history.replaceState(null, '', url)
|
history.replaceState(null, '', url)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ let app = null
|
|||||||
export function mount(container) {
|
export function mount(container) {
|
||||||
if (app) return
|
if (app) return
|
||||||
app = createApp(AnalyticsView, {
|
app = createApp(AnalyticsView, {
|
||||||
initialRange: new URLSearchParams(location.search).get('range') || 'week',
|
initialRange: location.hash.slice(1) || 'week',
|
||||||
})
|
})
|
||||||
app.mount(container)
|
app.mount(container)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user