From 2ccc34471cfaf6902be85b8dede72a1cc17c79c3 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 22 Jan 2022 15:26:57 +0000 Subject: [PATCH] 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). --- .../config/_default/params.yaml | 31 +-- .../markdown-slides/content/admin/index.md | 4 +- starters/markdown-slides/content/home/tags.md | 2 +- .../content/slides/example/index.md | 5 + starters/markdown-slides/go.mod | 4 +- wowchemy/assets/js/wowchemy-carousel.js | 25 ++ wowchemy/assets/js/wowchemy-map.js | 76 +++++ wowchemy/assets/js/wowchemy-publication.js | 162 +++++++++++ wowchemy/assets/js/wowchemy.js | 260 ------------------ wowchemy/layouts/_default/baseof.html | 2 - wowchemy/layouts/partials/cookie_consent.html | 2 +- .../partials/functions/get_author_name.html | 2 +- wowchemy/layouts/partials/jsonld/article.html | 2 +- .../layouts/partials/jsonld/business.html | 6 +- wowchemy/layouts/partials/jsonld/main.html | 2 +- .../partials/marketing/baidu_tongji.html | 2 +- .../partials/marketing/google_analytics.html | 4 +- .../marketing/google_tag_manager.html | 5 +- .../partials/marketing/microsoft_clarity.html | 5 +- .../layouts/partials/page_author_card.html | 2 +- wowchemy/layouts/partials/site_head.html | 20 +- wowchemy/layouts/partials/site_js.html | 35 ++- .../layouts/partials/widgets/contact.html | 10 +- 23 files changed, 353 insertions(+), 315 deletions(-) create mode 100644 wowchemy/assets/js/wowchemy-carousel.js create mode 100644 wowchemy/assets/js/wowchemy-map.js create mode 100644 wowchemy/assets/js/wowchemy-publication.js diff --git a/starters/markdown-slides/config/_default/params.yaml b/starters/markdown-slides/config/_default/params.yaml index 2fd3b216..35564bf1 100644 --- a/starters/markdown-slides/config/_default/params.yaml +++ b/starters/markdown-slides/config/_default/params.yaml @@ -13,12 +13,19 @@ appearance: # SEO -seo: - site_type: Person - local_business_type: '' - org_name: '' - description: '' - twitter: '' +marketing: + seo: + site_type: Person + local_business_type: '' + org_name: '' + description: '' + twitter: '' + analytics: + google_analytics: '' + baidu_tongji: '' + verification: + google: '' + baidu: '' # Site header @@ -46,13 +53,5 @@ locale: # Site features features: - privacy_pack: false - -require_isotope: false - -marketing: - google_analytics: '' - google_tag_manager: '' - google_site_verification: '' - baidu_site_verification: '' - baidu_tongji: '' + privacy_pack: + enable: false diff --git a/starters/markdown-slides/content/admin/index.md b/starters/markdown-slides/content/admin/index.md index 04c96f80..fda4a485 100644 --- a/starters/markdown-slides/content/admin/index.md +++ b/starters/markdown-slides/content/admin/index.md @@ -2,6 +2,6 @@ # Generate Wowchemy CMS type: wowchemycms outputs: -- wowchemycms_config -- HTML + - wowchemycms_config + - HTML --- diff --git a/starters/markdown-slides/content/home/tags.md b/starters/markdown-slides/content/home/tags.md index 011cd5b0..ed91a319 100644 --- a/starters/markdown-slides/content/home/tags.md +++ b/starters/markdown-slides/content/home/tags.md @@ -13,7 +13,7 @@ title: Mei's Slide Decks 👩🏼‍🏫 subtitle: An example of writing _open_ slides with Markdown 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 # Choose how many tags you would like to display (0 = all tags) count: 20 diff --git a/starters/markdown-slides/content/slides/example/index.md b/starters/markdown-slides/content/slides/example/index.md index 975170c8..6341f49c 100644 --- a/starters/markdown-slides/content/slides/example/index.md +++ b/starters/markdown-slides/content/slides/example/index.md @@ -47,6 +47,7 @@ slides: Inline code: `variable` Code block: + ```python porridge = "blueberry" if porridge == "blueberry": @@ -98,16 +99,20 @@ Add speaker notes to your presentation ```markdown {{%/* speaker_note */%}} + - Only the speaker can read these notes - Press `S` key to view + {{%/* /speaker_note */%}} ``` Press the `S` key to view the speaker notes! {{< speaker_note >}} + - Only the speaker can read these notes - Press `S` key to view + {{< /speaker_note >}} --- diff --git a/starters/markdown-slides/go.mod b/starters/markdown-slides/go.mod index fe55fe31..eb9c21ff 100644 --- a/starters/markdown-slides/go.mod +++ b/starters/markdown-slides/go.mod @@ -3,6 +3,6 @@ module github.com/wowchemy/starter-academic/exampleSite go 1.15 require ( - github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms/v5 v5.0.0-20220109160354-be9e2fde4a4f // indirect - github.com/wowchemy/wowchemy-hugo-modules/wowchemy/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@main ) diff --git a/wowchemy/assets/js/wowchemy-carousel.js b/wowchemy/assets/js/wowchemy-carousel.js new file mode 100644 index 00000000..741c863e --- /dev/null +++ b/wowchemy/assets/js/wowchemy-carousel.js @@ -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); diff --git a/wowchemy/assets/js/wowchemy-map.js b/wowchemy/assets/js/wowchemy-map.js new file mode 100644 index 00000000..d4a93d4e --- /dev/null +++ b/wowchemy/assets/js/wowchemy-map.js @@ -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 © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + 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: '© OpenStreetMap', + }).addTo(map); + } + let marker = L.marker([lat, lng]).addTo(map); + let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N'; + marker.bindPopup( + address + + '

Routing via OpenStreetMap

', + ); + } + } +} + +document.addEventListener('DOMContentLoaded', function () { + // Initialise street maps if necessary. + initMap(); +}); diff --git a/wowchemy/assets/js/wowchemy-publication.js b/wowchemy/assets/js/wowchemy-publication.js new file mode 100644 index 00000000..69c0018a --- /dev/null +++ b/wowchemy/assets/js/wowchemy-publication.js @@ -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!'); + }); + }); +}); diff --git a/wowchemy/assets/js/wowchemy.js b/wowchemy/assets/js/wowchemy.js index 2c17056a..2994a205 100644 --- a/wowchemy/assets/js/wowchemy.js +++ b/wowchemy/assets/js/wowchemy.js @@ -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 © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', - 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: '© OpenStreetMap', - }).addTo(map); - } - let marker = L.marker([lat, lng]).addTo(map); - let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N'; - marker.bindPopup( - address + - '

Routing via OpenStreetMap

', - ); - } - } -} - /* --------------------------------------------------------------------------- * 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. * --------------------------------------------------------------------------- */ @@ -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. let githubReleaseSelector = '.js-github-release'; if ($(githubReleaseSelector).length > 0) { @@ -678,11 +423,6 @@ darkModeMediaQuery.addEventListener('change', (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. $('body').on('mouseenter mouseleave', '.dropdown', function (e) { var dropdown = $(e.target).closest('.dropdown'); diff --git a/wowchemy/layouts/_default/baseof.html b/wowchemy/layouts/_default/baseof.html index 501ad5bd..50e92494 100644 --- a/wowchemy/layouts/_default/baseof.html +++ b/wowchemy/layouts/_default/baseof.html @@ -57,8 +57,6 @@ {{ end }} - {{ partial "citation" . }} - {{ partial "site_js" . }} diff --git a/wowchemy/layouts/partials/cookie_consent.html b/wowchemy/layouts/partials/cookie_consent.html index 3d01bf54..e5a797b4 100644 --- a/wowchemy/layouts/partials/cookie_consent.html +++ b/wowchemy/layouts/partials/cookie_consent.html @@ -1,4 +1,4 @@ -{{ if site.Params.features.privacy_pack }} +{{ if site.Params.features.privacy_pack.enable }} {{ $scr := .Scratch }} {{ $js := site.Data.assets.js }} {{ $css := site.Data.assets.css }} diff --git a/wowchemy/layouts/partials/functions/get_author_name.html b/wowchemy/layouts/partials/functions/get_author_name.html index 7e3b7436..72e64cc3 100644 --- a/wowchemy/layouts/partials/functions/get_author_name.html +++ b/wowchemy/layouts/partials/functions/get_author_name.html @@ -3,7 +3,7 @@ {{ $page := . }} {{/* 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_username := "" }} diff --git a/wowchemy/layouts/partials/jsonld/article.html b/wowchemy/layouts/partials/jsonld/article.html index 698a5dc6..e3c202af 100644 --- a/wowchemy/layouts/partials/jsonld/article.html +++ b/wowchemy/layouts/partials/jsonld/article.html @@ -9,7 +9,7 @@ {{ end }} {{ $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 -}} {{ end }} diff --git a/wowchemy/layouts/partials/marketing/microsoft_clarity.html b/wowchemy/layouts/partials/marketing/microsoft_clarity.html index 47e624fc..b49ef9a4 100644 --- a/wowchemy/layouts/partials/marketing/microsoft_clarity.html +++ b/wowchemy/layouts/partials/marketing/microsoft_clarity.html @@ -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 }} {{ end }} diff --git a/wowchemy/layouts/partials/page_author_card.html b/wowchemy/layouts/partials/page_author_card.html index bdfb1ae3..bc5924c8 100644 --- a/wowchemy/layouts/partials/page_author_card.html +++ b/wowchemy/layouts/partials/page_author_card.html @@ -1,6 +1,6 @@ {{ $page := .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) -}} {{/* Check an author profile exists. */}} diff --git a/wowchemy/layouts/partials/site_head.html b/wowchemy/layouts/partials/site_head.html index 33f51e11..4db9abe6 100644 --- a/wowchemy/layouts/partials/site_head.html +++ b/wowchemy/layouts/partials/site_head.html @@ -33,17 +33,17 @@ {{ end }} {{ end }} - {{ if site.Params.marketing.google_optimize | and hugo.IsProduction }} - + {{ if site.Params.marketing.analytics.google_optimize | and hugo.IsProduction }} + {{- end -}} - {{ with site.Params.marketing.google_site_verification }} + {{ with site.Params.marketing.verification.google }} {{- end -}} - {{ with site.Params.marketing.baidu_site_verification }} + {{ with site.Params.marketing.verification.baidu }} {{- end -}} - {{ with site.Params.marketing.bing_site_verification }} + {{ with site.Params.marketing.verification.bing }} {{- end -}} @@ -68,8 +68,8 @@ {{ $desc = .Params.abstract }} {{ else if .IsPage }} {{ $desc = .Summary }} - {{ else if site.Params.seo.org_name }} - {{ $desc = site.Params.seo.org_name }} + {{ else if site.Params.marketing.seo.org_name }} + {{ $desc = site.Params.marketing.seo.org_name }} {{ else }} {{ $desc = $superuser_role }} {{ end }} @@ -113,7 +113,7 @@ {{ else }} {{ $scr.Set "use_cdn" 1 }} - {{ if site.Params.icon.pack.ai }} + {{ if site.Params.extensions.academicons.enable }} {{ printf "" (printf $css.academicons.url $css.academicons.version) $css.academicons.sri | safeHTML }} {{ end }} @@ -165,7 +165,7 @@ {{ end }} {{/* Maps CSS. */}} - {{ $map_provider := lower site.Params.map.provider }} + {{ $map_provider := lower site.Params.features.map.provider }} {{ if in (slice "mapnik" "mapbox") $map_provider }} {{ printf "" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }} {{ end }} @@ -272,7 +272,7 @@ {{ if ne $title site.Title }}{{ $title = printf "%s | %s" $title site.Title }}{{ end }} {{ end }} - {{ with site.Params.seo.twitter }} + {{ with site.Params.marketing.seo.twitter }} {{ end }} diff --git a/wowchemy/layouts/partials/site_js.html b/wowchemy/layouts/partials/site_js.html index 8a06f2b8..5433a191 100644 --- a/wowchemy/layouts/partials/site_js.html +++ b/wowchemy/layouts/partials/site_js.html @@ -44,9 +44,9 @@ {{ end }} {{/* Maps JS. */}} - {{ $map_provider := lower site.Params.map.provider }} + {{ $map_provider := lower site.Params.features.map.provider }} {{ if eq $map_provider "google" }} - + {{ if ($scr.Get "use_cdn") }} {{ printf "" (printf $js.gmaps.url $js.gmaps.version) $js.gmaps.sri | safeHTML }} {{ end }} @@ -171,4 +171,35 @@ {{- end -}} + {{/* 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 -}} + + {{- 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 -}} + + {{- 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 -}} + + {{- end -}} + {{ partial "custom_js" . }} diff --git a/wowchemy/layouts/partials/widgets/contact.html b/wowchemy/layouts/partials/widgets/contact.html index 0e5d0883..9f729581 100644 --- a/wowchemy/layouts/partials/widgets/contact.html +++ b/wowchemy/layouts/partials/widgets/contact.html @@ -60,7 +60,7 @@
- {{ if and $use_netlify_form $use_netlify_captcha }} + {{ if and $use_netlify_form $use_netlify_captcha }}
{{ else if and $use_formspree_form $use_formspree_captcha }}
@@ -150,14 +150,14 @@ - {{ if and site.Params.map.provider $data.coordinates.latitude }} + {{ if and site.Params.features.map.provider $data.coordinates.latitude }}
- + - - + +
{{ end }}