preload-only-body
This commit is contained in:
parent
fcc7d19f59
commit
ae207a02f2
|
@ -9,7 +9,6 @@
|
||||||
"build": "vinxi build",
|
"build": "vinxi build",
|
||||||
"start": "vinxi start",
|
"start": "vinxi start",
|
||||||
"codegen": "graphql-codegen",
|
"codegen": "graphql-codegen",
|
||||||
"deploy": "graphql-codegen && npm run typecheck && npm run build && vercel",
|
|
||||||
"e2e": "npx playwright test --project=webkit",
|
"e2e": "npx playwright test --project=webkit",
|
||||||
"fix": "npx @biomejs/biome check src/. --write && stylelint **/*.{scss,css} --fix",
|
"fix": "npx @biomejs/biome check src/. --write && stylelint **/*.{scss,css} --fix",
|
||||||
"format": "npx @biomejs/biome format src/. --write",
|
"format": "npx @biomejs/biome format src/. --write",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { RouteSectionProps, createAsync } from '@solidjs/router'
|
import { RouteSectionProps, createAsync } from '@solidjs/router'
|
||||||
import { ErrorBoundary, Suspense, createMemo, createSignal, onMount } from 'solid-js'
|
import { ErrorBoundary, Suspense, createMemo, createReaction, createSignal, onMount } from 'solid-js'
|
||||||
import { FourOuFourView } from '~/components/Views/FourOuFour'
|
import { FourOuFourView } from '~/components/Views/FourOuFour'
|
||||||
import { Loading } from '~/components/_shared/Loading'
|
import { Loading } from '~/components/_shared/Loading'
|
||||||
import { gaIdentity } from '~/config/config'
|
import { gaIdentity } from '~/config/config'
|
||||||
|
@ -17,10 +17,7 @@ const fetchShout = async (slug: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const route = {
|
export const route = {
|
||||||
load: async ({ params }: RouteSectionProps<{ article: Shout }>) => {
|
load: async ({ params }: RouteSectionProps<{ article: Shout }>) => await fetchShout(params.slug)
|
||||||
const article = await fetchShout(params.slug)
|
|
||||||
return { article }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ArticlePage = (props: RouteSectionProps<{ article: Shout }>) => {
|
export const ArticlePage = (props: RouteSectionProps<{ article: Shout }>) => {
|
||||||
|
@ -31,13 +28,28 @@ export const ArticlePage = (props: RouteSectionProps<{ article: Shout }>) => {
|
||||||
() => `${article()?.authors?.[0]?.name || t('Discours')}: ${article()?.title || ''}`
|
() => `${article()?.authors?.[0]?.name || t('Discours')}: ${article()?.title || ''}`
|
||||||
)
|
)
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
if(gaIdentity) {
|
||||||
try {
|
try {
|
||||||
|
console.info('[routes.slug] mounted, connecting ga...')
|
||||||
await loadGAScript(gaIdentity)
|
await loadGAScript(gaIdentity)
|
||||||
initGA(gaIdentity)
|
initGA(gaIdentity)
|
||||||
console.debug('Google Analytics connected successfully')
|
console.debug('Google Analytics connected successfully')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to connect Google Analytics:', error)
|
console.warn('Failed to connect Google Analytics:', error)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// docs: `a side effect that is run the first time the expression
|
||||||
|
// wrapped by the returned tracking function is notified of a change`
|
||||||
|
createReaction(() => {
|
||||||
|
if (article()) {
|
||||||
|
window.gtag?.('event', 'page_view', {
|
||||||
|
page_title: article()?.title,
|
||||||
|
page_location: window.location.href,
|
||||||
|
page_path: window.location.pathname,
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary fallback={(_err) => <FourOuFourView />}>
|
<ErrorBoundary fallback={(_err) => <FourOuFourView />}>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user