Google analytics & fix for whitespace
This commit is contained in:
parent
0bb121ad11
commit
10c06b661c
6 changed files with 90 additions and 80 deletions
|
@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file.
|
||||||
- Hooks names updated for consistency
|
- Hooks names updated for consistency
|
||||||
- Added class parameter for responsive images
|
- Added class parameter for responsive images
|
||||||
- Added `images::image()` macro and `image_original` shortcode for images that don't want resizing (eg: animated gifs)
|
- Added `images::image()` macro and `image_original` shortcode for images that don't want resizing (eg: animated gifs)
|
||||||
|
- Added Google Analytics to `config.toml` see: `config.extra.google_analytics_tag_id`
|
||||||
|
- Fixes issues with unnecessary whitespace in templates
|
||||||
|
|
||||||
## [1.0]
|
## [1.0]
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ anchors = "on"
|
||||||
# Place your avatar in your /static folder
|
# Place your avatar in your /static folder
|
||||||
avatar = "/inky.png"
|
avatar = "/inky.png"
|
||||||
|
|
||||||
|
# Your Google Analytics measurement id ("G-XXXXXXXXXX")
|
||||||
|
# google_analytics_tag_id = "";
|
||||||
|
|
||||||
keywords = "zola, theme, ink, hugo-ink"
|
keywords = "zola, theme, ink, hugo-ink"
|
||||||
|
|
||||||
search_enabled = false
|
search_enabled = false
|
||||||
|
|
|
@ -12,12 +12,22 @@
|
||||||
{%- block og_preview -%}
|
{%- block og_preview -%}
|
||||||
{{ social::og_preview() }}
|
{{ social::og_preview() }}
|
||||||
{%-endblock og_preview -%}
|
{%-endblock og_preview -%}
|
||||||
{% block rss %}
|
{% block rss -%}
|
||||||
<link rel="alternate"
|
<link rel="alternate"
|
||||||
type="application/rss+xml"
|
type="application/rss+xml"
|
||||||
title="{{config.title}}"
|
title="{{config.title}}"
|
||||||
href="{{ get_url(path='atom.xml',trailing_slash=false)|safe}}"> {%
|
href="{{ get_url(path='atom.xml',trailing_slash=false)|safe}}">
|
||||||
endblock %}
|
{% endblock rss -%}
|
||||||
|
{% if config.extra.google_analytics_tag_id -%}
|
||||||
|
<!-- Google Analytics tag (gtag.js) -->
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ config.extra.google_analytics_tag_id }}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', '{{ config.extra.google_analytics_tag_id }}');
|
||||||
|
</script>
|
||||||
|
{% endif -%}
|
||||||
<link rel="preconnect"
|
<link rel="preconnect"
|
||||||
href="https://fonts.googleapis.com">
|
href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect"
|
<link rel="preconnect"
|
||||||
|
@ -35,13 +45,13 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
{% if config.extra.avatar %}
|
{% if config.extra.avatar -%}
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<a href="/">
|
<a href="/">
|
||||||
{{ images::responsive_image(path="", src=config.extra.avatar, default_size=128, sizes=[64,128,256], alt=config.title ) }}
|
{{ images::responsive_image(path="", src=config.extra.avatar, default_size=128, sizes=[64,128,256], alt=config.title ) }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
<a class="site-name"
|
<a class="site-name"
|
||||||
href="/">
|
href="/">
|
||||||
<h1>{{ config.title }}</h1>
|
<h1>{{ config.title }}</h1>
|
||||||
|
@ -51,63 +61,63 @@
|
||||||
</div>
|
</div>
|
||||||
<nav>
|
<nav>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
{% for menu_link in config.extra.menu_links %}
|
{% for menu_link in config.extra.menu_links -%}
|
||||||
{% set link_url = menu_link.url | replace(from="$BASE_URL", to=config.base_url) %}
|
{% set link_url = menu_link.url | replace(from="$BASE_URL", to=config.base_url) -%}
|
||||||
<a {% if current_url and current_url==link_url %}class="active" {% endif %}
|
<a {% if current_url and current_url==link_url %}class="active" {% endif %}
|
||||||
href="{{ link_url | safe}} ">{{menu_link.name}}</a>
|
href="{{ link_url | safe}} ">{{menu_link.name}}</a>
|
||||||
{% endfor %}
|
{% endfor -%}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
{% block content %}
|
{% block content -%}
|
||||||
{% endblock %}
|
{% endblock -%}
|
||||||
</article>
|
</article>
|
||||||
<footer>
|
<footer>
|
||||||
<div class="social">
|
<div class="social">
|
||||||
<ul>
|
<ul>
|
||||||
{# Github #}
|
{# Github #}
|
||||||
{% if config.extra.link_github_username %}
|
{% if config.extra.link_github_username -%}
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/{{ config.extra.link_github_username }}"
|
<a href="https://github.com/{{ config.extra.link_github_username }}"
|
||||||
title="Github" rel="me"><i data-feather="github"></i></a>
|
title="Github" rel="me"><i data-feather="github"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
|
|
||||||
{# Mastadon #}
|
{# Mastadon #}
|
||||||
{% if config.extra.link_mastodon_url %}
|
{% if config.extra.link_mastodon_url -%}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ config.extra.link_mastodon_url }}"
|
<a href="{{ config.extra.link_mastodon_url }}"
|
||||||
title="Mastodon" rel="me"><i data-feather="message-square"></i></a>
|
title="Mastodon" rel="me"><i data-feather="message-square"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
|
|
||||||
{# Twitter #}
|
{# Twitter #}
|
||||||
{% if config.extra.link_twitter_username %}
|
{% if config.extra.link_twitter_username -%}
|
||||||
<li>
|
<li>
|
||||||
<a href="https://twitter.com/{{ config.extra.link_twitter_username }}"
|
<a href="https://twitter.com/{{ config.extra.link_twitter_username }}"
|
||||||
title="Twitter"
|
title="Twitter"
|
||||||
rel="me"><i data-feather="twitter"></i></a>
|
rel="me"><i data-feather="twitter"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
|
|
||||||
{# Instagram #}
|
{# Instagram #}
|
||||||
{% if config.extra.link_instagram_username %}
|
{% if config.extra.link_instagram_username -%}
|
||||||
<li>
|
<li>
|
||||||
<a href="https://www.instagram.com/jimmyff_art/{{ config.extra.link_instagram_username }}"
|
<a href="https://www.instagram.com/jimmyff_art/{{ config.extra.link_instagram_username }}"
|
||||||
title="Medium"
|
title="Medium"
|
||||||
rel="me"><i data-feather="instagram"></i></a>
|
rel="me"><i data-feather="instagram"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
|
|
||||||
{# Medium #}
|
{# Medium #}
|
||||||
{% if config.extra.link_medium_username %}
|
{% if config.extra.link_medium_username -%}
|
||||||
<li>
|
<li>
|
||||||
<a href="https://medium.com/@{{ config.extra.link_medium_username }}"
|
<a href="https://medium.com/@{{ config.extra.link_medium_username }}"
|
||||||
title="Medium"
|
title="Medium"
|
||||||
rel="me"><i data-feather="file-text"></i></a>
|
rel="me"><i data-feather="file-text"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
|
|
||||||
{# RSS feed #}
|
{# RSS feed #}
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
|
|
||||||
{% extends "base.html" %} {% block content %}
|
{% extends "base.html" -%}
|
||||||
|
{% block content -%}
|
||||||
<h1 class="title">{{ section.title }}</h1>
|
<h1 class="title">{{ section.title }}</h1>
|
||||||
|
|
||||||
<article>{{ section.content | safe }}</article>
|
<article>{{ section.content | safe }}</article>
|
||||||
|
{% for year, posts in section.pages | group_by(attribute="year") -%}
|
||||||
{% for year, posts in section.pages | group_by(attribute="year") %}
|
|
||||||
<ul class="gallery flat">
|
<ul class="gallery flat">
|
||||||
<h2 class="archive-year">{{ year }}</h2>
|
<h2 class="archive-year">{{ year }}</h2>
|
||||||
{% for post in posts %}
|
{% for post in posts -%}
|
||||||
{% if post.extra.images %}
|
{% if post.extra.images -%}
|
||||||
{% for image in post.extra.images %}
|
{% for image in post.extra.images -%}
|
||||||
{# { set image = resize_image(path=post.path ~ image, width=256, height=256, format=config.extra.image_format, quality=config.extra.thumbnail_quality) %} #}
|
{# { set image = resize_image(path=post.path ~ image, width=256, height=256, format=config.extra.image_format, quality=config.extra.thumbnail_quality) %} #}
|
||||||
<li class="thumbnail">
|
<li class="thumbnail">
|
||||||
<a href="{{ post.permalink | safe }}" title="{{ post.title }} - {{ post.date }}">
|
<a href="{{ post.permalink | safe }}" title="{{ post.title }} - {{ post.date }}">
|
||||||
{{ images::responsive_thumbnail(path=post.colocated_path, src=image, default_size=128, sizes=[128,256], alt=post.title ~ " - " ~ post.date ) }}
|
{{ images::responsive_thumbnail(path=post.colocated_path, src=image, default_size=128, sizes=[128,256], alt=post.title ~ " - " ~ post.date ) -}}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor -%}
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
{% endfor %}
|
{% endfor -%}
|
||||||
</ul>
|
</ul>
|
||||||
{% endfor %} {% endblock content %}
|
{% endfor -%}
|
||||||
|
{% endblock content -%}
|
||||||
|
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
|
||||||
{% macro image(path, src, alt, class="") %}
|
{% macro image(path, src, alt, class="") -%}
|
||||||
<img alt="{{ alt }}" title="{{ alt }}" src="{{ get_url(path=path ~ src) | safe }}" class="{{ class }}" />
|
<img alt="{{ alt }}" title="{{ alt }}" src="{{ get_url(path=path ~ src) | safe }}" class="{{ class }}" />
|
||||||
{% endmacro image %}
|
{% endmacro image -%}
|
||||||
|
|
||||||
{#
|
{#
|
||||||
Original author: crepererum https://github.com/getzola/even/pull/48/files
|
Original author: crepererum https://github.com/getzola/even/pull/48/files
|
||||||
Adapted to Inky template by jimmyff
|
Adapted to Inky template by jimmyff
|
||||||
#}
|
#}
|
||||||
|
|
||||||
{% macro responsive_image(path, src, alt, default_size, sizes, class="") %}
|
{% macro responsive_image(path, src, alt, default_size, sizes, class="") -%}
|
||||||
{% if config.extra.image_resizing_disabled and config.extra.image_resizing_disabled == true %}
|
{% if config.extra.image_resizing_disabled and config.extra.image_resizing_disabled == true -%}
|
||||||
{{ image(path=path, src=src, alt=alt, class=class) }}
|
{{ image(path=path, src=src, alt=alt, class=class) -}}
|
||||||
{% else %}
|
{% else -%}
|
||||||
{% set abspath = path ~ src %}
|
{% set abspath = path ~ src -%}
|
||||||
{% set meta = get_image_metadata(path=abspath) %}
|
{% set meta = get_image_metadata(path=abspath) -%}
|
||||||
{% set width = meta.width %}
|
{% set width = meta.width -%}
|
||||||
{% set srcset_list = [] %}
|
{% set srcset_list = [] -%}
|
||||||
{% for s in sizes %}
|
{% for s in sizes -%}
|
||||||
{% if width >= s %}
|
{% if width >= s -%}
|
||||||
{% set resized = resize_image(format=config.extra.image_format, path=abspath, width=s, op="fit_width", quality=config.extra.image_quality) %}
|
{% set resized = resize_image(format=config.extra.image_format, path=abspath, width=s, op="fit_width", quality=config.extra.image_quality) -%}
|
||||||
{% set element = resized.url ~ " " ~ s ~ "w" %}
|
{% set element = resized.url ~ " " ~ s ~ "w" -%}
|
||||||
{% set_global srcset_list = srcset_list | concat(with=[element]) %}
|
{% set_global srcset_list = srcset_list | concat(with=[element]) -%}
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
{% endfor %}
|
{% endfor -%}
|
||||||
{% set default_resized = resize_image(format=config.extra.image_format, path=abspath, width=default_size, op="fit_width", quality=config.extra.image_quality) %}
|
{% set default_resized = resize_image(format=config.extra.image_format, path=abspath, width=default_size, op="fit_width", quality=config.extra.image_quality) -%}
|
||||||
<img alt="{{ alt }}" title="{{ alt }}" src="{{ default_resized.url | safe }}" srcset="{{ srcset_list | join(sep=", ") | safe }}" class="{{ class }}" />
|
<img alt="{{ alt }}" title="{{ alt }}" src="{{ default_resized.url | safe }}" srcset="{{ srcset_list | join(sep=", ") | safe }}" class="{{ class }}" />
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
{% endmacro responsive_image %}
|
{% endmacro responsive_image -%}
|
||||||
|
|
||||||
|
|
||||||
{% macro responsive_thumbnail(path, src, alt, default_size, sizes, class="") %}
|
{% macro responsive_thumbnail(path, src, alt, default_size, sizes, class="") -%}
|
||||||
{% if config.extra.image_resizing_disabled and config.extra.image_resizing_disabled == true %}
|
{% if config.extra.image_resizing_disabled and config.extra.image_resizing_disabled == true -%}
|
||||||
{{ image(path=path, src=src, alt=alt, class=class) }}
|
{{ image(path=path, src=src, alt=alt, class=class) -}}
|
||||||
{% else %}
|
{% else -%}
|
||||||
{% set abspath = path ~ src %}
|
{% set abspath = path ~ src -%}
|
||||||
{% set meta = get_image_metadata(path=abspath) %}
|
{% set meta = get_image_metadata(path=abspath) -%}
|
||||||
{% set width = meta.width %}
|
{% set width = meta.width -%}
|
||||||
{% set srcset_list = [] %}
|
{% set srcset_list = [] -%}
|
||||||
{% for s in sizes %}
|
{% for s in sizes -%}
|
||||||
{% if width >= s %}
|
{% if width >= s -%}
|
||||||
{% set resized = resize_image(format=config.extra.image_format, path=abspath, width=s, height=s, op="fill", quality=config.extra.thumbnail_quality) %}
|
{% set resized = resize_image(format=config.extra.image_format, path=abspath, width=s, height=s, op="fill", quality=config.extra.thumbnail_quality) -%}
|
||||||
{% set element = resized.url ~ " " ~ s ~ "w" %}
|
{% set element = resized.url ~ " " ~ s ~ "w" -%}
|
||||||
{% set_global srcset_list = srcset_list | concat(with=[element]) %}
|
{% set_global srcset_list = srcset_list | concat(with=[element]) -%}
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
{% endfor %}
|
{% endfor -%}
|
||||||
{% set default_resized = resize_image(format=config.extra.image_format, path=abspath, width=default_size, height=default_size, op="fill", quality=config.extra.thumbnail_quality) %}
|
{% set default_resized = resize_image(format=config.extra.image_format, path=abspath, width=default_size, height=default_size, op="fill", quality=config.extra.thumbnail_quality) -%}
|
||||||
<img alt="{{ alt }}" title="{{ alt }}" src="{{ default_resized.url | safe }}" srcset="{{ srcset_list | join(sep=", ") | safe }}" class="{{ class }}" />
|
<img alt="{{ alt }}" title="{{ alt }}" src="{{ default_resized.url | safe }}" srcset="{{ srcset_list | join(sep=", ") | safe }}" class="{{ class }}" />
|
||||||
{% endif %}
|
{% endif -%}
|
||||||
{% endmacro responsive_thumbnail %}
|
{% endmacro responsive_thumbnail -%}
|
|
@ -1,16 +1,12 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" -%}
|
||||||
|
{% block title -%}
|
||||||
{% block title %}
|
|
||||||
{{ config.title }} | {{page.title}}
|
{{ config.title }} | {{page.title}}
|
||||||
{% endblock title %}
|
{% endblock title -%}
|
||||||
|
{% block content -%}
|
||||||
{% block content %}
|
|
||||||
<h1 class="title">
|
<h1 class="title">
|
||||||
{{ page.title }}
|
{{ page.title }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
{{ page.content | safe }}
|
{{ page.content | safe }}
|
||||||
</article>
|
</article>
|
||||||
|
{% endblock content -%}
|
||||||
{% endblock content %}
|
|
Loading…
Reference in a new issue