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,10 +85,17 @@ export const siteConfig = {
|
|||
},
|
||||
// umami analytics
|
||||
// by enabling this, you can track the visitors of your site
|
||||
umami: {
|
||||
enabled: false, // enable umami analytics
|
||||
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
|
||||
siteAnalytics: {
|
||||
enabled: false, // enable analytics
|
||||
type: 'umami', // 'umami', 'goatcounter'
|
||||
umami: {
|
||||
instanceDomain: 'cloud.umami.is', // the domain of the umami instance, 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
|
||||
},
|
||||
goatcounter: {
|
||||
// provide solutions for tracking visitors without Javascript
|
||||
instanceDomain: 'yourcodehere.goatcounter.com', // the domain of the goatcounter instance, usually your-goatcounter-instance.com
|
||||
},
|
||||
},
|
||||
// neko
|
||||
// by enabling this, you can add a neko that follows cursor to your site
|
||||
|
|
|
@ -18,7 +18,11 @@ interface Props {
|
|||
}
|
||||
|
||||
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 formattedRootPath = defaultTitle.toLowerCase().replace(/\s+/g, '-');
|
||||
|
@ -68,6 +72,7 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description =
|
|||
<footer class="footer">
|
||||
<div class="floating">
|
||||
<BackToTop/>
|
||||
|
||||
{noscript ? <ThemeSwitcher_CSSOnly/> : <ThemeSwitcher/>}
|
||||
</div>
|
||||
<div class="container">
|
||||
|
@ -75,10 +80,36 @@ 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>
|
||||
</div>
|
||||
</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) &&
|
||||
<>
|
||||
<script is:inline define:vars={{ nekoType }}>
|
||||
<script is:inline define:vars={{ nekoType }}>
|
||||
window.NekoType = nekoType;
|
||||
</script>
|
||||
<script is:inline src="https://webneko.net/n20171213.js"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue