Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuireu committed Dec 10, 2023
1 parent 91d424a commit cf5ea0b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
7 changes: 6 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import netlify from "@astrojs/netlify/functions";

export default defineConfig({
site: 'https://biancafiore.me',
integrations: [mdx(), sitemap(), react(), partytown()],
integrations: [mdx(), sitemap(), react(),
partytown({
config: {
forward: ["dataLayer.push"],
},
})],
output: "server",
adapter: netlify(),
vite: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"packageManager": "[email protected]",
"description": "A portfolio for the best content writer ever",
"version": "2.0.0",
"type": "module",
"author": "Ferran Buireu <[email protected]>",
"engines": {
"node": ">=20.10.0"
Expand Down
19 changes: 19 additions & 0 deletions src/components/BaseHead.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import '../styles/index.css'
import '@fontsource/zilla-slab';
import '@fontsource-variable/literata';
import {ViewTransitions} from "astro:transitions";
import { loadEnv } from "vite";
interface Props {
title: string;
Expand All @@ -11,8 +13,12 @@ interface Props {
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const { title, description, image = '/blog-placeholder-1.jpg' } = Astro.props;
const { PUBLIC_GOOGLE_ANALYTICS_ID } = loadEnv(process.env.NODE_ENV, process.cwd(), "");
console.log("PUBLIC_GOOGLE_ANALYTICS_ID", PUBLIC_GOOGLE_ANALYTICS_ID)
---

<head>
<meta name="generator" content={Astro.generator} />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
Expand All @@ -31,3 +37,16 @@ const { title, description, image = '/blog-placeholder-1.jpg' } = Astro.props;
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
<meta property="twitter:image" content={new URL(image, Astro.url)} />
<ViewTransitions />
<script
type="text/partytown"
src=`https://www.googletagmanager.com/gtag/js?id=${import.meta.env.PUBLIC_GOOGLE_ANALYTICS_ID}`></script>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", PUBLIC_GOOGLE_ANALYTICS_ID);
</script>
</head>
8 changes: 8 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

interface ImportMetaEnv {
readonly PUBLIC_GOOGLE_ANALYTICS_ID: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
14 changes: 7 additions & 7 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
import { ViewTransitions } from 'astro:transitions';
---

<!-- todo: import alias -->
<!-- todo: fix env file to load gtag-->
<!-- todo: prettierc-->
<!-- todo: eslint-->

<!doctype html>
<html lang="en">
<head>
<BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
<ViewTransitions />
</head>
<BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
<body>
<Header title={SITE_TITLE} />
<Header title={SITE_TITLE} client:load/>
<main>
<h1>🧑‍🚀 Hello, Astronaut!</h1>
<input type="search" placeholder="heheheh">
<p>
Welcome to the official <a href="https://astro.build/">Astro</a> blog starter template. This
template serves as a lightweight, minimally-styled starting point for anyone looking to
Expand Down

0 comments on commit cf5ea0b

Please sign in to comment.