Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
shu-keep-moving committed Dec 1, 2024
2 parents 9c38cd2 + a16aa7d commit b800d39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 1 addition & 3 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@

<!-- Scripts -->

{% unless site.theme_mode %}
<script src="{{ '/assets/js/dist/theme.min.js' | relative_url }}"></script>
{% endunless %}
<script src="{{ '/assets/js/dist/theme.min.js' | relative_url }}"></script>

{% include js-selector.html lang=lang %}

Expand Down
14 changes: 8 additions & 6 deletions _includes/pageviews/goatcounter.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!-- Display GoatCounter pageviews -->
<script>
let pv = document.getElementById('pageviews');
document.addEventListener('DOMContentLoaded', () => {
const pv = document.getElementById('pageviews');

if (pv !== null) {
const uri = location.pathname.replace(/\/$/, '');
const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${encodeURIComponent(uri)}.json`;
if (pv !== null) {
const uri = location.pathname.replace(/\/$/, '');
const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${encodeURIComponent(uri)}.json`;

fetch(url)
fetch(url)
.then((response) => response.json())
.then((data) => {
const count = data.count.replace(/\s/g, '');
Expand All @@ -15,5 +16,6 @@
.catch((error) => {
pv.innerText = '1';
});
}
}
});
</script>
13 changes: 8 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const DIST = 'assets/js/dist';
const banner = `/*!
* ${pkg.name} v${pkg.version} | © ${pkg.since} ${pkg.author} | ${pkg.license} Licensed | ${pkg.homepage}
*/`;

const frontmatter = `---\npermalink: /:basename\n---\n`;

const isProd = process.env.BUILD === 'production';

let hasWatched = false;

function cleanup() {
fs.rmSync(DIST, { recursive: true, force: true });
console.log(`> Directory "${DIST}" has been cleaned.`);
Expand All @@ -39,6 +39,11 @@ function build(
{ src = SRC_DEFAULT, jekyll = false, outputName = null } = {}
) {
const input = `${src}/${filename}.js`;
const shouldWatch = hasWatched ? false : true;

if (!hasWatched) {
hasWatched = true;
}

return {
input,
Expand All @@ -49,9 +54,7 @@ function build(
banner,
sourcemap: !isProd && !jekyll
},
watch: {
include: input
},
...(shouldWatch && { watch: { include: `${SRC_DEFAULT}/**/*.js` } }),
plugins: [
babel({
babelHelpers: 'bundled',
Expand Down

0 comments on commit b800d39

Please sign in to comment.