feat: modularise JS map, publication, carousel

BREAKING CHANGES:

site.Params.icon.pack.ai -> site.Params.extensions.academicons.enable
site.Params.map -> site.Params.features.map
site.Params.features.privacy_pack -> site.Params.features.privacy_pack.enable
site.Params.marketing and site.Params.seo combined and restructured.

Performance improvements:

Only include pub JS and cite model if site has publications.

Only include carousel JS if site uses Slider widget.

Only include map JS if site uses maps (sets map provider).
This commit is contained in:
George Cushen 2022-01-22 15:26:57 +00:00
commit 2ccc34471c
23 changed files with 353 additions and 315 deletions

View file

@ -13,12 +13,19 @@ appearance:
# SEO # SEO
seo: marketing:
site_type: Person seo:
local_business_type: '' site_type: Person
org_name: '' local_business_type: ''
description: '' org_name: ''
twitter: '' description: ''
twitter: ''
analytics:
google_analytics: ''
baidu_tongji: ''
verification:
google: ''
baidu: ''
# Site header # Site header
@ -46,13 +53,5 @@ locale:
# Site features # Site features
features: features:
privacy_pack: false privacy_pack:
enable: false
require_isotope: false
marketing:
google_analytics: ''
google_tag_manager: ''
google_site_verification: ''
baidu_site_verification: ''
baidu_tongji: ''

View file

@ -2,6 +2,6 @@
# Generate Wowchemy CMS # Generate Wowchemy CMS
type: wowchemycms type: wowchemycms
outputs: outputs:
- wowchemycms_config - wowchemycms_config
- HTML - HTML
--- ---

View file

@ -13,7 +13,7 @@ title: Mei's Slide Decks 👩🏼‍🏫
subtitle: An example of writing _open_ slides with Markdown subtitle: An example of writing _open_ slides with Markdown
content: content:
# Choose the taxonomy from `config.yaml` to display (e.g. tags, categories) # Choose the taxonomy from `config.yaml` to display (e.g. tags, categories)
taxonomy: tags taxonomy: tags
# Choose how many tags you would like to display (0 = all tags) # Choose how many tags you would like to display (0 = all tags)
count: 20 count: 20

View file

@ -47,6 +47,7 @@ slides:
Inline code: `variable` Inline code: `variable`
Code block: Code block:
```python ```python
porridge = "blueberry" porridge = "blueberry"
if porridge == "blueberry": if porridge == "blueberry":
@ -98,16 +99,20 @@ Add speaker notes to your presentation
```markdown ```markdown
{{%/* speaker_note */%}} {{%/* speaker_note */%}}
- Only the speaker can read these notes - Only the speaker can read these notes
- Press `S` key to view - Press `S` key to view
{{%/* /speaker_note */%}} {{%/* /speaker_note */%}}
``` ```
Press the `S` key to view the speaker notes! Press the `S` key to view the speaker notes!
{{< speaker_note >}} {{< speaker_note >}}
- Only the speaker can read these notes - Only the speaker can read these notes
- Press `S` key to view - Press `S` key to view
{{< /speaker_note >}} {{< /speaker_note >}}
--- ---

View file

@ -3,6 +3,6 @@ module github.com/wowchemy/starter-academic/exampleSite
go 1.15 go 1.15
require ( require (
github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms/v5 v5.0.0-20220109160354-be9e2fde4a4f // indirect github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms/v5@main
github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5 v5.0.0-20220109160354-be9e2fde4a4f // indirect github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5@main
) )

View file

@ -0,0 +1,25 @@
/* ---------------------------------------------------------------------------
* Normalize Bootstrap Carousel Slide Heights.
* --------------------------------------------------------------------------- */
function normalizeCarouselSlideHeights() {
let carousels = document.querySelectorAll('.carousel');
carousels.forEach((carousel) => {
let items = carousel.querySelector('.carousel-item');
let maxHeight = Math.max.apply(
null,
items
.map(function () {
return this.outerHeight();
})
.get(),
);
items.forEach((item) => {
item.style.minHeight = maxHeight + 'px';
});
});
}
window.addEventListener('load', normalizeCarouselSlideHeights);
window.addEventListener('resize', normalizeCarouselSlideHeights);
window.addEventListener('orientationchange', normalizeCarouselSlideHeights);

View file

@ -0,0 +1,76 @@
/*************************************************
* Wowchemy
* https://github.com/wowchemy/wowchemy-hugo-themes
*
* Wowchemy Maps
**************************************************/
// Initialize Google Maps or OpenStreetMap via Leaflet.
function initMap() {
if ($('#map').length) {
let map_provider = $('#map-provider').val();
let lat = $('#map-lat').val();
let lng = $('#map-lng').val();
let zoom = parseInt($('#map-zoom').val());
let address = $('#map-dir').val();
let api_key = $('#map-api-key').val();
if (map_provider === 'google') {
let map = new GMaps({
div: '#map',
lat: lat,
lng: lng,
zoom: zoom,
zoomControl: true,
zoomControlOpt: {
style: 'SMALL',
position: 'TOP_LEFT',
},
streetViewControl: false,
mapTypeControl: false,
gestureHandling: 'cooperative',
});
map.addMarker({
lat: lat,
lng: lng,
click: function () {
let url = 'https://www.google.com/maps/place/' + encodeURIComponent(address) + '/@' + lat + ',' + lng + '/';
window.open(url, '_blank');
},
title: address,
});
} else {
let map = new L.map('map').setView([lat, lng], zoom);
if (map_provider === 'mapbox' && api_key.length) {
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution:
'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
tileSize: 512,
maxZoom: 18,
zoomOffset: -1,
id: 'mapbox/streets-v11',
accessToken: api_key,
}).addTo(map);
} else {
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
}).addTo(map);
}
let marker = L.marker([lat, lng]).addTo(map);
let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N';
marker.bindPopup(
address +
'<p><a href="https://www.openstreetmap.org/directions?engine=osrm_car&route=' +
url +
'">Routing via OpenStreetMap</a></p>',
);
}
}
}
document.addEventListener('DOMContentLoaded', function () {
// Initialise street maps if necessary.
initMap();
});

View file

@ -0,0 +1,162 @@
/*************************************************
* Wowchemy
* https://github.com/wowchemy/wowchemy-hugo-themes
*
* Wowchemy Publications
**************************************************/
// Active publication filters.
let pubFilters = {};
// Search term.
let searchRegex;
// Filter values (concatenated).
let filterValues;
// Publication container.
let $grid_pubs = $('#container-publications');
// Initialise Isotope publication layout if required.
if ($grid_pubs.length) {
$grid_pubs.isotope({
itemSelector: '.isotope-item',
percentPosition: true,
masonry: {
// Use Bootstrap compatible grid layout.
columnWidth: '.grid-sizer',
},
filter: function () {
let $this = $(this);
let searchResults = searchRegex ? $this.text().match(searchRegex) : true;
let filterResults = filterValues ? $this.is(filterValues) : true;
return searchResults && filterResults;
},
});
// Filter by search term.
let $quickSearch = $('.filter-search').keyup(
debounce(function () {
searchRegex = new RegExp($quickSearch.val(), 'gi');
$grid_pubs.isotope();
}),
);
$('.pub-filters').on('change', function () {
let $this = $(this);
// Get group key.
let filterGroup = $this[0].getAttribute('data-filter-group');
// Set filter for group.
pubFilters[filterGroup] = this.value;
// Combine filters.
filterValues = concatValues(pubFilters);
// Activate filters.
$grid_pubs.isotope();
// If filtering by publication type, update the URL hash to enable direct linking to results.
if (filterGroup === 'pubtype') {
// Set hash URL to current filter.
let url = $(this).val();
if (url.substr(0, 9) === '.pubtype-') {
window.location.hash = url.substr(9);
} else {
window.location.hash = '';
}
}
});
}
// Debounce input to prevent spamming filter requests.
function debounce(fn, threshold) {
let timeout;
threshold = threshold || 100;
return function debounced() {
clearTimeout(timeout);
let args = arguments;
let _this = this;
function delayed() {
fn.apply(_this, args);
}
timeout = setTimeout(delayed, threshold);
};
}
// Flatten object by concatenating values.
function concatValues(obj) {
let value = '';
for (let prop in obj) {
value += obj[prop];
}
return value;
}
// Filter publications according to hash in URL.
function filter_publications() {
// Check for Isotope publication layout.
if (!$grid_pubs.length) return;
let urlHash = window.location.hash.replace('#', '');
let filterValue = '*';
// Check if hash is numeric.
if (urlHash != '' && !isNaN(urlHash)) {
filterValue = '.pubtype-' + urlHash;
}
// Set filter.
let filterGroup = 'pubtype';
pubFilters[filterGroup] = filterValue;
filterValues = concatValues(pubFilters);
// Activate filters.
$grid_pubs.isotope();
// Set selected option.
$('.pubtype-select').val(filterValue);
}
document.addEventListener('DOMContentLoaded', function () {
// Enable publication filter for publication index page.
if ($('.pub-filters-select')) {
filter_publications();
// Useful for changing hash manually (e.g. in development):
// window.addEventListener('hashchange', filter_publications, false);
}
// Load citation modal on 'Cite' click.
$('.js-cite-modal').click(function (e) {
e.preventDefault();
let filename = $(this).attr('data-filename');
let modal = $('#modal');
modal.find('.modal-body code').load(filename, function (response, status, xhr) {
if (status == 'error') {
let msg = 'Error: ';
$('#modal-error').html(msg + xhr.status + ' ' + xhr.statusText);
} else {
$('.js-download-cite').attr('href', filename);
}
});
modal.modal('show');
});
// Copy citation text on 'Copy' click.
$('.js-copy-cite').click(function (e) {
e.preventDefault();
// Get text to copy.
let citation = document.querySelector('#modal .modal-body').innerHTML;
navigator.clipboard
.writeText(citation)
.then(function () {
console.debug('Citation copied!');
})
.catch(function () {
console.error('Citation copy failed!');
});
});
});

View file

@ -129,194 +129,6 @@ $(document).on('click', '.navbar-collapse.show', function (e) {
} }
}); });
/* ---------------------------------------------------------------------------
* Filter publications.
* --------------------------------------------------------------------------- */
// Active publication filters.
let pubFilters = {};
// Search term.
let searchRegex;
// Filter values (concatenated).
let filterValues;
// Publication container.
let $grid_pubs = $('#container-publications');
// Initialise Isotope publication layout if required.
if ($grid_pubs.length) {
$grid_pubs.isotope({
itemSelector: '.isotope-item',
percentPosition: true,
masonry: {
// Use Bootstrap compatible grid layout.
columnWidth: '.grid-sizer',
},
filter: function () {
let $this = $(this);
let searchResults = searchRegex ? $this.text().match(searchRegex) : true;
let filterResults = filterValues ? $this.is(filterValues) : true;
return searchResults && filterResults;
},
});
// Filter by search term.
let $quickSearch = $('.filter-search').keyup(
debounce(function () {
searchRegex = new RegExp($quickSearch.val(), 'gi');
$grid_pubs.isotope();
}),
);
$('.pub-filters').on('change', function () {
let $this = $(this);
// Get group key.
let filterGroup = $this[0].getAttribute('data-filter-group');
// Set filter for group.
pubFilters[filterGroup] = this.value;
// Combine filters.
filterValues = concatValues(pubFilters);
// Activate filters.
$grid_pubs.isotope();
// If filtering by publication type, update the URL hash to enable direct linking to results.
if (filterGroup === 'pubtype') {
// Set hash URL to current filter.
let url = $(this).val();
if (url.substr(0, 9) === '.pubtype-') {
window.location.hash = url.substr(9);
} else {
window.location.hash = '';
}
}
});
}
// Debounce input to prevent spamming filter requests.
function debounce(fn, threshold) {
let timeout;
threshold = threshold || 100;
return function debounced() {
clearTimeout(timeout);
let args = arguments;
let _this = this;
function delayed() {
fn.apply(_this, args);
}
timeout = setTimeout(delayed, threshold);
};
}
// Flatten object by concatenating values.
function concatValues(obj) {
let value = '';
for (let prop in obj) {
value += obj[prop];
}
return value;
}
// Filter publications according to hash in URL.
function filter_publications() {
// Check for Isotope publication layout.
if (!$grid_pubs.length) return;
let urlHash = window.location.hash.replace('#', '');
let filterValue = '*';
// Check if hash is numeric.
if (urlHash != '' && !isNaN(urlHash)) {
filterValue = '.pubtype-' + urlHash;
}
// Set filter.
let filterGroup = 'pubtype';
pubFilters[filterGroup] = filterValue;
filterValues = concatValues(pubFilters);
// Activate filters.
$grid_pubs.isotope();
// Set selected option.
$('.pubtype-select').val(filterValue);
}
/* ---------------------------------------------------------------------------
* Google Maps or OpenStreetMap via Leaflet.
* --------------------------------------------------------------------------- */
function initMap() {
if ($('#map').length) {
let map_provider = $('#map-provider').val();
let lat = $('#map-lat').val();
let lng = $('#map-lng').val();
let zoom = parseInt($('#map-zoom').val());
let address = $('#map-dir').val();
let api_key = $('#map-api-key').val();
if (map_provider === 'google') {
let map = new GMaps({
div: '#map',
lat: lat,
lng: lng,
zoom: zoom,
zoomControl: true,
zoomControlOpt: {
style: 'SMALL',
position: 'TOP_LEFT',
},
streetViewControl: false,
mapTypeControl: false,
gestureHandling: 'cooperative',
});
map.addMarker({
lat: lat,
lng: lng,
click: function () {
let url = 'https://www.google.com/maps/place/' + encodeURIComponent(address) + '/@' + lat + ',' + lng + '/';
window.open(url, '_blank');
},
title: address,
});
} else {
let map = new L.map('map').setView([lat, lng], zoom);
if (map_provider === 'mapbox' && api_key.length) {
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution:
'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
tileSize: 512,
maxZoom: 18,
zoomOffset: -1,
id: 'mapbox/streets-v11',
accessToken: api_key,
}).addTo(map);
} else {
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
}).addTo(map);
}
let marker = L.marker([lat, lng]).addTo(map);
let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N';
marker.bindPopup(
address +
'<p><a href="https://www.openstreetmap.org/directions?engine=osrm_car&route=' +
url +
'">Routing via OpenStreetMap</a></p>',
);
}
}
}
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------
* GitHub API. * GitHub API.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
@ -373,29 +185,6 @@ function toggleSearchDialog() {
} }
} }
/* ---------------------------------------------------------------------------
* Normalize Bootstrap Carousel Slide Heights.
* --------------------------------------------------------------------------- */
function normalizeCarouselSlideHeights() {
$('.carousel').each(function () {
// Get carousel slides.
let items = $('.carousel-item', this);
// Reset all slide heights.
items.css('min-height', 0);
// Normalize all slide heights.
let maxHeight = Math.max.apply(
null,
items
.map(function () {
return $(this).outerHeight();
})
.get(),
);
items.css('min-height', maxHeight + 'px');
});
}
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------
* Fix Hugo's Goldmark output and Mermaid code blocks. * Fix Hugo's Goldmark output and Mermaid code blocks.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
@ -561,50 +350,6 @@ $(window).on('load', function () {
} }
} }
// Enable publication filter for publication index page.
if ($('.pub-filters-select')) {
filter_publications();
// Useful for changing hash manually (e.g. in development):
// window.addEventListener('hashchange', filter_publications, false);
}
// Load citation modal on 'Cite' click.
$('.js-cite-modal').click(function (e) {
e.preventDefault();
let filename = $(this).attr('data-filename');
let modal = $('#modal');
modal.find('.modal-body code').load(filename, function (response, status, xhr) {
if (status == 'error') {
let msg = 'Error: ';
$('#modal-error').html(msg + xhr.status + ' ' + xhr.statusText);
} else {
$('.js-download-cite').attr('href', filename);
}
});
modal.modal('show');
});
// Copy citation text on 'Copy' click.
$('.js-copy-cite').click(function (e) {
e.preventDefault();
// Get selection.
let range = document.createRange();
let code_node = document.querySelector('#modal .modal-body');
range.selectNode(code_node);
window.getSelection().addRange(range);
try {
// Execute the copy command.
document.execCommand('copy');
} catch (e) {
console.log('Error: citation copy failed.');
}
// Remove selection.
window.getSelection().removeRange(range);
});
// Initialise Google Maps if necessary.
initMap();
// Print latest version of GitHub projects. // Print latest version of GitHub projects.
let githubReleaseSelector = '.js-github-release'; let githubReleaseSelector = '.js-github-release';
if ($(githubReleaseSelector).length > 0) { if ($(githubReleaseSelector).length > 0) {
@ -678,11 +423,6 @@ darkModeMediaQuery.addEventListener('change', (event) => {
onMediaQueryListEvent(event); onMediaQueryListEvent(event);
}); });
// Normalize Bootstrap carousel slide heights for Slider widget instances.
window.addEventListener('load', normalizeCarouselSlideHeights);
window.addEventListener('resize', normalizeCarouselSlideHeights);
window.addEventListener('orientationchange', normalizeCarouselSlideHeights);
// Automatic main menu dropdowns on mouse over. // Automatic main menu dropdowns on mouse over.
$('body').on('mouseenter mouseleave', '.dropdown', function (e) { $('body').on('mouseenter mouseleave', '.dropdown', function (e) {
var dropdown = $(e.target).closest('.dropdown'); var dropdown = $(e.target).closest('.dropdown');

View file

@ -57,8 +57,6 @@
{{ end }} {{ end }}
</div> </div>
{{ partial "citation" . }}
{{ partial "site_js" . }} {{ partial "site_js" . }}
</body> </body>

View file

@ -1,4 +1,4 @@
{{ if site.Params.features.privacy_pack }} {{ if site.Params.features.privacy_pack.enable }}
{{ $scr := .Scratch }} {{ $scr := .Scratch }}
{{ $js := site.Data.assets.js }} {{ $js := site.Data.assets.js }}
{{ $css := site.Data.assets.css }} {{ $css := site.Data.assets.css }}

View file

@ -3,7 +3,7 @@
{{ $page := . }} {{ $page := . }}
{{/* Get publisher as fall back. */}} {{/* Get publisher as fall back. */}}
{{ $publisher := site.Params.seo.org_name | default site.Title }} {{ $publisher := site.Params.marketing.seo.org_name | default site.Title }}
{{ $author := "" }} {{ $author := "" }}
{{ $author_username := "" }} {{ $author_username := "" }}

View file

@ -9,7 +9,7 @@
{{ end }} {{ end }}
{{ $author := partial "functions/get_author_name" $page }} {{ $author := partial "functions/get_author_name" $page }}
{{ $publisher := site.Params.seo.org_name | default site.Title }} {{ $publisher := site.Params.marketing.seo.org_name | default site.Title }}
{{ $logo_url := partial "functions/get_logo_url" $page -}} {{ $logo_url := partial "functions/get_logo_url" $page -}}
<script type="application/ld+json"> <script type="application/ld+json">

View file

@ -2,12 +2,12 @@
<script type="application/ld+json"> <script type="application/ld+json">
{ {
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": {{site.Params.seo.site_type | default site.Params.seo.site_type}}, "@type": {{site.Params.marketing.seo.site_type | default site.Params.marketing.seo.site_type}},
"@id": {{site.BaseURL}}, "@id": {{site.BaseURL}},
"name": {{site.Params.seo.org_name | default site.Title}}, "name": {{site.Params.marketing.seo.org_name | default site.Title}},
"logo": {{ partial "functions/get_logo_url" . }}, "logo": {{ partial "functions/get_logo_url" . }},
{{with $sharing_image}}"image": {{.Permalink}},{{end}} {{with $sharing_image}}"image": {{.Permalink}},{{end}}
{{ if (eq site.Params.seo.site_type "LocalBusiness") | and site.Params.coordinates }} {{ if (eq site.Params.marketing.seo.site_type "LocalBusiness") | and site.Params.coordinates }}
"geo": { "geo": {
"@type": "GeoCoordinates", "@type": "GeoCoordinates",
"latitude": {{site.Params.coordinates.latitude}}, "latitude": {{site.Params.coordinates.latitude}},

View file

@ -1,6 +1,6 @@
{{ $page := .page }} {{ $page := .page }}
{{ $summary := .summary }} {{ $summary := .summary }}
{{ $site_type := site.Params.seo.site_type | default "Person" }} {{ $site_type := site.Params.marketing.seo.site_type | default "Person" }}
{{- if $page.IsHome -}} {{- if $page.IsHome -}}

View file

@ -1,4 +1,4 @@
{{ $baidu_tongji := site.Params.marketing.baidu_tongji | default "" }} {{ $baidu_tongji := site.Params.marketing.analytics.baidu_tongji | default "" }}
{{ if hugo.IsProduction | and $baidu_tongji }} {{ if hugo.IsProduction | and $baidu_tongji }}
<script> <script>

View file

@ -1,8 +1,8 @@
{{ $ga := site.Params.marketing.google_analytics | default site.GoogleAnalytics | default "" }} {{ $ga := site.Params.marketing.analytics.google_analytics | default site.GoogleAnalytics | default "" }}
{{ if hugo.IsProduction | and $ga }} {{ if hugo.IsProduction | and $ga }}
{{ $gtag_config := cond site.Params.features.privacy_pack "{ 'anonymize_ip': true }" "{}" }} {{ $gtag_config := cond site.Params.features.privacy_pack.enable "{ 'anonymize_ip': true }" "{}" }}
<script async src="https://www.googletagmanager.com/gtag/js?id={{$ga}}"></script> <script async src="https://www.googletagmanager.com/gtag/js?id={{$ga}}"></script>
<script> <script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];

View file

@ -1,9 +1,10 @@
{{ if hugo.IsProduction | and site.Params.marketing.google_tag_manager }} {{ $gt := site.Params.marketing.analytics.google_tag_manager | default "" }}
{{ if hugo.IsProduction | and $gt }}
<script> <script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{site.Params.marketing.google_tag_manager}}'); })(window,document,'script','dataLayer','{{$gt}}');
</script> </script>
{{ end }} {{ end }}

View file

@ -1,9 +1,10 @@
{{ if hugo.IsProduction | and site.Params.marketing.microsoft_clarity }} {{ $clarity := site.Params.marketing.analytics.microsoft_clarity | default "" }}
{{ if hugo.IsProduction | and $clarity }}
<script> <script>
(function(c,l,a,r,i,t,y){ (function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", '{{site.Params.marketing.microsoft_clarity}}'); })(window, document, "clarity", "script", '{{$clarity}}');
</script> </script>
{{ end }} {{ end }}

View file

@ -1,6 +1,6 @@
{{ $page := .page }} {{ $page := .page }}
{{ $author_page := .author_page }} {{ $author_page := .author_page }}
{{ $site_type := site.Params.seo.site_type | default "Person" }} {{ $site_type := site.Params.marketing.seo.site_type | default "Person" }}
{{- $has_profile := not (eq nil $author_page.Params.superuser) -}} {{- $has_profile := not (eq nil $author_page.Params.superuser) -}}
{{/* Check an author profile exists. */}} {{/* Check an author profile exists. */}}

View file

@ -33,17 +33,17 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if site.Params.marketing.google_optimize | and hugo.IsProduction }} {{ if site.Params.marketing.analytics.google_optimize | and hugo.IsProduction }}
<script src="https://www.googleoptimize.com/optimize.js?id={{ site.Params.marketing.google_optimize }}"></script> <script src="https://www.googleoptimize.com/optimize.js?id={{ site.Params.marketing.analytics.google_optimize }}"></script>
{{- end -}} {{- end -}}
{{ with site.Params.marketing.google_site_verification }} {{ with site.Params.marketing.verification.google }}
<meta name="google-site-verification" content="{{ . }}" /> <meta name="google-site-verification" content="{{ . }}" />
{{- end -}} {{- end -}}
{{ with site.Params.marketing.baidu_site_verification }} {{ with site.Params.marketing.verification.baidu }}
<meta name="baidu-site-verification" content="{{ . }}" /> <meta name="baidu-site-verification" content="{{ . }}" />
{{- end -}} {{- end -}}
{{ with site.Params.marketing.bing_site_verification }} {{ with site.Params.marketing.verification.bing }}
<meta name="msvalidate.01" content="{{ . }}" /> <meta name="msvalidate.01" content="{{ . }}" />
{{- end -}} {{- end -}}
@ -68,8 +68,8 @@
{{ $desc = .Params.abstract }} {{ $desc = .Params.abstract }}
{{ else if .IsPage }} {{ else if .IsPage }}
{{ $desc = .Summary }} {{ $desc = .Summary }}
{{ else if site.Params.seo.org_name }} {{ else if site.Params.marketing.seo.org_name }}
{{ $desc = site.Params.seo.org_name }} {{ $desc = site.Params.marketing.seo.org_name }}
{{ else }} {{ else }}
{{ $desc = $superuser_role }} {{ $desc = $superuser_role }}
{{ end }} {{ end }}
@ -113,7 +113,7 @@
<link rel="stylesheet" href="{{ printf "/css/vendor/%s" ($scr.Get "vendor_css_filename") | relURL }}" /> <link rel="stylesheet" href="{{ printf "/css/vendor/%s" ($scr.Get "vendor_css_filename") | relURL }}" />
{{ else }} {{ else }}
{{ $scr.Set "use_cdn" 1 }} {{ $scr.Set "use_cdn" 1 }}
{{ if site.Params.icon.pack.ai }} {{ if site.Params.extensions.academicons.enable }}
{{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" media=\"print\" onload=\"this.media='all'\">" (printf $css.academicons.url $css.academicons.version) $css.academicons.sri | safeHTML }} {{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" media=\"print\" onload=\"this.media='all'\">" (printf $css.academicons.url $css.academicons.version) $css.academicons.sri | safeHTML }}
{{ end }} {{ end }}
@ -165,7 +165,7 @@
{{ end }} {{ end }}
{{/* Maps CSS. */}} {{/* Maps CSS. */}}
{{ $map_provider := lower site.Params.map.provider }} {{ $map_provider := lower site.Params.features.map.provider }}
{{ if in (slice "mapnik" "mapbox") $map_provider }} {{ if in (slice "mapnik" "mapbox") $map_provider }}
{{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" media=\"print\" onload=\"this.media='all'\">" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }} {{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" media=\"print\" onload=\"this.media='all'\">" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }}
{{ end }} {{ end }}
@ -272,7 +272,7 @@
{{ if ne $title site.Title }}{{ $title = printf "%s | %s" $title site.Title }}{{ end }} {{ if ne $title site.Title }}{{ $title = printf "%s | %s" $title site.Title }}{{ end }}
{{ end }} {{ end }}
<meta property="twitter:card" content="{{ $twitter_card }}" /> <meta property="twitter:card" content="{{ $twitter_card }}" />
{{ with site.Params.seo.twitter }} {{ with site.Params.marketing.seo.twitter }}
<meta property="twitter:site" content="@{{ . }}" /> <meta property="twitter:site" content="@{{ . }}" />
<meta property="twitter:creator" content="@{{ . }}" /> <meta property="twitter:creator" content="@{{ . }}" />
{{ end }} {{ end }}

View file

@ -44,9 +44,9 @@
{{ end }} {{ end }}
{{/* Maps JS. */}} {{/* Maps JS. */}}
{{ $map_provider := lower site.Params.map.provider }} {{ $map_provider := lower site.Params.features.map.provider }}
{{ if eq $map_provider "google" }} {{ if eq $map_provider "google" }}
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ site.Params.map.api_key }}"></script> <script async defer src="https://maps.googleapis.com/maps/api/js?key={{ site.Params.features.map.api_key }}"></script>
{{ if ($scr.Get "use_cdn") }} {{ if ($scr.Get "use_cdn") }}
{{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\"></script>" (printf $js.gmaps.url $js.gmaps.version) $js.gmaps.sri | safeHTML }} {{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\"></script>" (printf $js.gmaps.url $js.gmaps.version) $js.gmaps.sri | safeHTML }}
{{ end }} {{ end }}
@ -171,4 +171,35 @@
{{- end -}} {{- end -}}
<script src="{{ $js_bundle.RelPermalink }}"></script> <script src="{{ $js_bundle.RelPermalink }}"></script>
{{/* Maps */}}
{{ if site.Params.features.map.provider }}
{{ $js := resources.Get "js/wowchemy-map.js" | js.Build (dict "format" "esm" "minify" true) }}
{{- if hugo.IsProduction -}}
{{- $js = $js | fingerprint "md5" -}}
{{- end -}}
<script src="{{ $js.RelPermalink }}" type="module"></script>
{{- end -}}
{{/* Carousel */}}
{{ $hasCarousel := where site.Pages "Params.widget" "slider" }}
{{ if $hasCarousel }}
{{ $js := resources.Get "js/wowchemy-carousel.js" | js.Build (dict "format" "esm" "minify" true) }}
{{- if hugo.IsProduction -}}
{{- $js = $js | fingerprint "md5" -}}
{{- end -}}
<script src="{{ $js.RelPermalink }}" type="module"></script>
{{- end -}}
{{/* Publications */}}
{{ $hasPublications := where site.Pages "Type" "publication" }}
{{ if $hasPublications }}
{{ partial "citation" . }}
{{ $js := resources.Get "js/wowchemy-publication.js" | js.Build (dict "format" "esm" "minify" true) }}
{{- if hugo.IsProduction -}}
{{- $js = $js | fingerprint "md5" -}}
{{- end -}}
<script src="{{ $js.RelPermalink }}" type="module"></script>
{{- end -}}
{{ partial "custom_js" . }} {{ partial "custom_js" . }}

View file

@ -60,7 +60,7 @@
<div class="d-none"> <div class="d-none">
<label>Do not fill this field unless you are a bot: <input name="_gotcha"></label> <label>Do not fill this field unless you are a bot: <input name="_gotcha"></label>
</div> </div>
{{ if and $use_netlify_form $use_netlify_captcha }} {{ if and $use_netlify_form $use_netlify_captcha }}
<div class="form-group" data-netlify-recaptcha="true"></div> <div class="form-group" data-netlify-recaptcha="true"></div>
{{ else if and $use_formspree_form $use_formspree_captcha }} {{ else if and $use_formspree_form $use_formspree_captcha }}
<div class="g-recaptcha" data-sitekey="{{ $st.Params.content.form.formspree.captcha_key }}"></div> <div class="g-recaptcha" data-sitekey="{{ $st.Params.content.form.formspree.captcha_key }}"></div>
@ -150,14 +150,14 @@
</ul> </ul>
{{ if and site.Params.map.provider $data.coordinates.latitude }} {{ if and site.Params.features.map.provider $data.coordinates.latitude }}
<div class="d-none"> <div class="d-none">
<input id="map-provider" value="{{ lower site.Params.map.provider }}"> <input id="map-provider" value="{{ lower site.Params.features.map.provider }}">
<input id="map-lat" value="{{ $data.coordinates.latitude }}"> <input id="map-lat" value="{{ $data.coordinates.latitude }}">
<input id="map-lng" value="{{ $data.coordinates.longitude }}"> <input id="map-lng" value="{{ $data.coordinates.longitude }}">
<input id="map-dir" value="{{ $addr_formatted }}"> <input id="map-dir" value="{{ $addr_formatted }}">
<input id="map-zoom" value="{{ site.Params.map.zoom | default "15" }}"> <input id="map-zoom" value="{{ site.Params.features.map.zoom | default "15" }}">
<input id="map-api-key" value="{{ site.Params.map.api_key }}"> <input id="map-api-key" value="{{ site.Params.features.map.api_key }}">
</div> </div>
<div id="map"></div> <div id="map"></div>
{{ end }} {{ end }}