From 08489bb6b3ead6ab1006b835151f3bf6b9c04eda Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 26 Nov 2024 06:53:13 +0900 Subject: [PATCH] =?UTF-8?q?Google=20Analytics=E3=81=AE=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E6=9D=A1=E4=BB=B6=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++- astro.config.ts | 3 +++ src/components/Header/index.astro | 2 +- src/layouts/Base.astro | 27 ++++++++++--------- .../[characterId]/[...descriptionType].astro | 9 ++++--- src/pages/nemo/index.astro | 10 +++++-- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index b98c64a7..364708c5 100644 --- a/README.md +++ b/README.md @@ -119,13 +119,15 @@ pnpm run generateThumb ## TODO +- [ ] ボイボ寮ページで背景が読まれてないかも +- [ ] Nemo のヘッダーのとこの見た目が変 +- [ ] Nemo の背景が重い - [ ] sitemap の比較、dev が含まれてないことを確認 - [ ] ニュースの RSS? - [ ] Bulma の scss が重い - [ ] canonical URL が以前と一致することを確認 - [ ] Google Analytics の疎通チェック - [ ] たぶん font-smoothing が効いてないけど macOS でちゃんと動くか確認 -- [ ] Google Analytics を Partytown にしたい issue 作る、sendEvent が Partytown 上からしかできなくなるのをどう解決するか ## なんとなくのコーディングルールメモ diff --git a/astro.config.ts b/astro.config.ts index 612c0b51..42a470fa 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -18,11 +18,14 @@ export default defineConfig({ filter: (page) => !page.includes("/dev/"), }), react(), + /* + // ViewTransitions を使う場合gtagがうまく動かない。ページの移動のたびにロードされてしまう。 partytown({ config: { forward: ["dataLayer.push"], // for `gtag` }, }), + */ ], vite: { diff --git a/src/components/Header/index.astro b/src/components/Header/index.astro index 692c0c0c..e62c3985 100644 --- a/src/components/Header/index.astro +++ b/src/components/Header/index.astro @@ -25,7 +25,7 @@ const iconUrl = (await getImage({ src: iconImage, width: 64 })).src; &.is-black { // FIXME: is-blackで影が変わらないBulmaのバグ - box-shadow: 0 2px 0 0 hsl(0deg, 0%, 4%); + box-shadow: 0 2px 0 0 hsl(0deg, 0%, 4%) !important; } } diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 39472962..b08b500b 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -42,7 +42,6 @@ const { } = Astro.props; const noindex = import.meta.env.PREVIEW || noindex_; -const isProduction = import.meta.env.PROD; // imageとimageAltが片方だけ指定されている場合はエラーを出す if ((_image == undefined) != (imageAlt == undefined)) { @@ -55,6 +54,12 @@ const imageUrl = _image : (await getImage({ src: _image })).src // importされた画像を取得する : undefined; const hasImage = imageUrl != undefined && imageAlt != undefined; + +// Google Analytics。実際のページ以外では読み込まない。 +const googleAnalyticsSrc = + import.meta.env.DEV || import.meta.env.PREVIEW + ? undefined + : `https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`; --- @@ -101,20 +106,18 @@ const hasImage = imageUrl != undefined && imageAlt != undefined; {/* Google Analytics */} - - + diff --git a/src/pages/dormitory/[characterId]/[...descriptionType].astro b/src/pages/dormitory/[characterId]/[...descriptionType].astro index 70661e82..597ce142 100644 --- a/src/pages/dormitory/[characterId]/[...descriptionType].astro +++ b/src/pages/dormitory/[characterId]/[...descriptionType].astro @@ -18,7 +18,7 @@ export const getStaticPaths = (async () => { }) satisfies GetStaticPaths; type Props = InferGetStaticPropsType; -import { Image } from "astro:assets"; +import { getImage, Image } from "astro:assets"; import { faHome } from "@fortawesome/free-solid-svg-icons"; @@ -30,6 +30,7 @@ import PlayButton from "@components/PlayButton/index.astro"; import { callNameInfos } from "@constants/characterInfos/callNameInfo"; import { getProductPageUrl } from "@constants/url"; +import backgroundImage from "../images/nc238325.jpg"; const { characterInfo, descriptionType } = Astro.props; const characterKey = characterInfo.key; @@ -37,6 +38,8 @@ const descriptionNames = { profile: "プロフィール", calls: "呼び方", } satisfies Record<(typeof descriptionTypes)[number], string>; + +const backgroundImageUrl = `url(${(await getImage({ src: backgroundImage })).src})`; --- -