Skip to content

Commit

Permalink
perf: avoid post pageviews from shifting while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Apr 25, 2022
1 parent 6d35f5f commit 135a16f
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,46 @@ <h1 data-toc-skip>{{ page.title }}</h1>

<div class="post-meta text-muted">

<!-- author -->
<div>
{% capture author_name %}{{ site.data.authors[page.author].name | default: site.social.name }}{% endcapture %}
{% assign author_link = nil %}

{% if page.author %}
{% assign author_link = site.data.authors[page.author].url %}
{% elsif author_name == site.social.name %}
{% assign author_link = site.social.links[0] %}
<!-- published date -->
<span>
{{ site.data.locales[lang].post.posted }}
{% include datetime.html date=page.date tooltip=true %}
</span>

<!-- lastmod date -->
{% if page.last_modified_at %}
<span>
{{ site.data.locales[lang].post.updated }}
{% include datetime.html date=page.last_modified_at tooltip=true %}
</span>
{% endif %}

{{ site.data.locales[lang].post.written_by }}
<em>
{% if author_link %}
<a href="{{ author_link }}">{{ author_name }}</a>
{% else %}
{{ author_name }}
{% endif %}
</em>
</div>

<div class="d-flex">
<div>
<!-- published date -->
<span>
{{ site.data.locales[lang].post.posted }}
{% include datetime.html date=page.date tooltip=true %}
</span>
<div class="d-flex justify-content-between">
<!-- author -->
<span>
{% capture author_name %}{{ site.data.authors[page.author].name | default: site.social.name }}{% endcapture %}
{% assign author_link = nil %}

<!-- lastmod date -->
{% if page.last_modified_at %}
<span>
{{ site.data.locales[lang].post.updated }}
{% include datetime.html date=page.last_modified_at tooltip=true %}
</span>
{% if page.author %}
{% assign author_link = site.data.authors[page.author].url %}
{% elsif author_name == site.social.name %}
{% assign author_link = site.social.links[0] %}
{% endif %}

<!-- read time -->
{% include read-time.html content=content prompt=true %}
{{ site.data.locales[lang].post.written_by }}

<em>
{% if author_link %}
<a href="{{ author_link }}">{{ author_name }}</a>
{% else %}
{{ author_name }}
{% endif %}
</em>
</span>

<div>
<!-- page views -->
{% if site.google_analytics.pv.proxy_endpoint or site.google_analytics.pv.cache_path %}
<span>
Expand All @@ -84,6 +84,9 @@ <h1 data-toc-skip>{{ page.title }}</h1>
{{ site.data.locales[lang].post.pageview_measure }}
</span>
{% endif %}

<!-- read time -->
{% include read-time.html content=content prompt=true %}
</div>

</div> <!-- .d-flex -->
Expand Down

0 comments on commit 135a16f

Please sign in to comment.