feat: add support for goatcounter and migrate to statistics config
This commit is contained in:
parent
cb9f917b06
commit
dee65f247b
2 changed files with 45 additions and 7 deletions
|
@ -85,11 +85,18 @@ export const siteConfig = {
|
||||||
},
|
},
|
||||||
// umami analytics
|
// umami analytics
|
||||||
// by enabling this, you can track the visitors of your site
|
// by enabling this, you can track the visitors of your site
|
||||||
|
siteAnalytics: {
|
||||||
|
enabled: false, // enable analytics
|
||||||
|
type: 'umami', // 'umami', 'goatcounter'
|
||||||
umami: {
|
umami: {
|
||||||
enabled: false, // enable umami analytics
|
instanceDomain: 'cloud.umami.is', // the domain of the umami instance, usually your-umami-instance.com (default: official cloud.umami.is)
|
||||||
instanceDomain: 'cloud.umami.is', // the url of the umami script, usually your-umami-instance.com (default: official cloud.umami.is)
|
|
||||||
websiteId: 'your-website-id', // the id of your website in umami, get it from your umami dashboard
|
websiteId: 'your-website-id', // the id of your website in umami, get it from your umami dashboard
|
||||||
},
|
},
|
||||||
|
goatcounter: {
|
||||||
|
// provide solutions for tracking visitors without Javascript
|
||||||
|
instanceDomain: 'yourcodehere.goatcounter.com', // the domain of the goatcounter instance, usually your-goatcounter-instance.com
|
||||||
|
},
|
||||||
|
},
|
||||||
// neko
|
// neko
|
||||||
// by enabling this, you can add a neko that follows cursor to your site
|
// by enabling this, you can add a neko that follows cursor to your site
|
||||||
// this will load script from webneko.net
|
// this will load script from webneko.net
|
||||||
|
|
|
@ -18,7 +18,11 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const noscript = siteConfig.noClientJavaScript
|
const noscript = siteConfig.noClientJavaScript
|
||||||
const umami = siteConfig.umami
|
|
||||||
|
const statisticsEnabled = siteConfig.siteAnalytics.enabled
|
||||||
|
const statisticsType = siteConfig.siteAnalytics.type
|
||||||
|
const umamiConfig = siteConfig.siteAnalytics.umami
|
||||||
|
const goatCounterConfig = siteConfig.siteAnalytics.goatcounter
|
||||||
|
|
||||||
const defaultTitle = siteConfig.title
|
const defaultTitle = siteConfig.title
|
||||||
const formattedRootPath = defaultTitle.toLowerCase().replace(/\s+/g, '-');
|
const formattedRootPath = defaultTitle.toLowerCase().replace(/\s+/g, '-');
|
||||||
|
@ -68,6 +72,7 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description =
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="floating">
|
<div class="floating">
|
||||||
<BackToTop/>
|
<BackToTop/>
|
||||||
|
|
||||||
{noscript ? <ThemeSwitcher_CSSOnly/> : <ThemeSwitcher/>}
|
{noscript ? <ThemeSwitcher_CSSOnly/> : <ThemeSwitcher/>}
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -75,7 +80,33 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description =
|
||||||
<p>Powered by <a href="https://git.gb0.dev/gb/mercury" target="_blank"><Logo width={16} height={16} /> mercury</a></p>
|
<p>Powered by <a href="https://git.gb0.dev/gb/mercury" target="_blank"><Logo width={16} height={16} /> mercury</a></p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
{umami.enabled && <script defer src=`https://${umami.instanceDomain}/script.js` data-website-id={umami.websiteId}></script>}
|
{statisticsEnabled && statisticsType === 'umami' && (
|
||||||
|
<script
|
||||||
|
is:inline
|
||||||
|
defer
|
||||||
|
src={`https://${umamiConfig.instanceDomain}/script.js`}
|
||||||
|
data-website-id={umamiConfig.websiteId}
|
||||||
|
></script>
|
||||||
|
)}
|
||||||
|
{statisticsEnabled && statisticsType === 'goatcounter' && (
|
||||||
|
<>
|
||||||
|
{noscript ? (
|
||||||
|
<img src={`https://${goatCounterConfig.instanceDomain}/count?p=/${Astro.url.pathname}`} alt="Analytics" />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<script
|
||||||
|
is:inline
|
||||||
|
async
|
||||||
|
data-goatcounter={`https://${goatCounterConfig.instanceDomain}/count`}
|
||||||
|
src={`https://${goatCounterConfig.instanceDomain}/count.js`}
|
||||||
|
></script>
|
||||||
|
<noscript>
|
||||||
|
<img src={`https://${goatCounterConfig.instanceDomain}/count?p=/${Astro.url.pathname}`} alt="Analytics" />
|
||||||
|
</noscript>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{ (siteConfig.neko.enabled && !noscript) &&
|
{ (siteConfig.neko.enabled && !noscript) &&
|
||||||
<>
|
<>
|
||||||
<script is:inline define:vars={{ nekoType }}>
|
<script is:inline define:vars={{ nekoType }}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue