Skip to content

Commit 083b2e8

Browse files
committed
Add plausible through metadata
1 parent b5812d2 commit 083b2e8

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

packages/gatsby-theme-iterative/gatsby-config.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ module.exports = ({
171171
}
172172
],
173173
siteMetadata: {
174-
author: 'Iterative',
175-
siteUrl: 'https://cml.dev',
176-
titleTemplate: ''
174+
author: '',
175+
siteUrl: '',
176+
titleTemplate: '',
177+
plausibleSrc: 'https://plausible.io/js/plausible.outbound-links.js',
178+
plausibleDomain: ''
177179
}
178180
})

packages/gatsby-theme-iterative/src/components/Page/DefaultSEO/index.tsx

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import { Script } from 'gatsby'
32
import Helmet from 'react-helmet'
43

54
import { MetaProps } from '../../SEO'
@@ -17,11 +16,15 @@ const metaImage = {
1716

1817
const DefaultSEO: React.FC<IDefaultSEOProps> = ({ pathname }) => {
1918
const siteMeta = getSiteMeta()
20-
const siteUrl = siteMeta.siteUrl
21-
const metaTitle = siteMeta.title
22-
const metaTitleTemplate = siteMeta.titleTemplate
23-
const metaDescription = siteMeta.description
24-
const metaKeywords = siteMeta.keywords
19+
const {
20+
siteUrl,
21+
titleTemplate,
22+
title: metaTitle,
23+
description: metaDescription,
24+
keywords: metaKeywords,
25+
plausibleDomain,
26+
plausibleSrc
27+
} = siteMeta
2528
const fullUrl = siteUrl + pathname
2629

2730
const meta: MetaProps[] = [
@@ -104,32 +107,29 @@ const DefaultSEO: React.FC<IDefaultSEOProps> = ({ pathname }) => {
104107
]
105108

106109
return (
107-
<>
108-
<Helmet
109-
htmlAttributes={{
110-
lang: 'en'
111-
}}
112-
defaultTitle={metaTitle}
113-
titleTemplate={metaTitleTemplate || `%s | ${metaTitle}`}
114-
meta={meta}
115-
link={[
116-
{
117-
rel: 'mask-icon',
118-
href: '/safari-pinned-tab.svg',
119-
color: '#13adc7'
120-
},
121-
{
122-
rel: 'canonical',
123-
href: fullUrl
124-
}
125-
]}
126-
/>
127-
<Script
128-
defer
129-
data-domain="dvc.org"
130-
src="https://plausible.io/js/plausible.outbound-links.js"
131-
/>
132-
</>
110+
<Helmet
111+
htmlAttributes={{
112+
lang: 'en'
113+
}}
114+
defaultTitle={metaTitle}
115+
titleTemplate={titleTemplate || `%s | ${metaTitle}`}
116+
meta={meta}
117+
link={[
118+
{
119+
rel: 'mask-icon',
120+
href: '/safari-pinned-tab.svg',
121+
color: '#13adc7'
122+
},
123+
{
124+
rel: 'canonical',
125+
href: fullUrl
126+
}
127+
]}
128+
>
129+
{plausibleDomain ? (
130+
<script defer data-domain={plausibleDomain} src={plausibleSrc} />
131+
) : null}
132+
</Helmet>
133133
)
134134
}
135135

packages/gatsby-theme-iterative/src/queries/siteMeta.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ interface ISiteMeta {
66
keywords: string
77
siteUrl: string
88
titleTemplate: string
9+
plausibleDomain: string
10+
plausibleSrc: string
911
}
1012

1113
export default function siteMeta(): ISiteMeta {
@@ -21,6 +23,8 @@ export default function siteMeta(): ISiteMeta {
2123
keywords
2224
siteUrl
2325
titleTemplate
26+
plausibleDomain
27+
plausibleSrc
2428
}
2529
}
2630
}

0 commit comments

Comments
 (0)