Skip to content

Commit 135a16f

Browse files
committed
perf: avoid post pageviews from shifting while loading
1 parent 6d35f5f commit 135a16f

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

_layouts/post.html

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,46 @@ <h1 data-toc-skip>{{ page.title }}</h1>
3535

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

38-
<!-- author -->
3938
<div>
40-
{% capture author_name %}{{ site.data.authors[page.author].name | default: site.social.name }}{% endcapture %}
41-
{% assign author_link = nil %}
42-
43-
{% if page.author %}
44-
{% assign author_link = site.data.authors[page.author].url %}
45-
{% elsif author_name == site.social.name %}
46-
{% assign author_link = site.social.links[0] %}
39+
<!-- published date -->
40+
<span>
41+
{{ site.data.locales[lang].post.posted }}
42+
{% include datetime.html date=page.date tooltip=true %}
43+
</span>
44+
45+
<!-- lastmod date -->
46+
{% if page.last_modified_at %}
47+
<span>
48+
{{ site.data.locales[lang].post.updated }}
49+
{% include datetime.html date=page.last_modified_at tooltip=true %}
50+
</span>
4751
{% endif %}
48-
49-
{{ site.data.locales[lang].post.written_by }}
50-
<em>
51-
{% if author_link %}
52-
<a href="{{ author_link }}">{{ author_name }}</a>
53-
{% else %}
54-
{{ author_name }}
55-
{% endif %}
56-
</em>
5752
</div>
5853

59-
<div class="d-flex">
60-
<div>
61-
<!-- published date -->
62-
<span>
63-
{{ site.data.locales[lang].post.posted }}
64-
{% include datetime.html date=page.date tooltip=true %}
65-
</span>
54+
<div class="d-flex justify-content-between">
55+
<!-- author -->
56+
<span>
57+
{% capture author_name %}{{ site.data.authors[page.author].name | default: site.social.name }}{% endcapture %}
58+
{% assign author_link = nil %}
6659

67-
<!-- lastmod date -->
68-
{% if page.last_modified_at %}
69-
<span>
70-
{{ site.data.locales[lang].post.updated }}
71-
{% include datetime.html date=page.last_modified_at tooltip=true %}
72-
</span>
60+
{% if page.author %}
61+
{% assign author_link = site.data.authors[page.author].url %}
62+
{% elsif author_name == site.social.name %}
63+
{% assign author_link = site.social.links[0] %}
7364
{% endif %}
7465

75-
<!-- read time -->
76-
{% include read-time.html content=content prompt=true %}
66+
{{ site.data.locales[lang].post.written_by }}
67+
68+
<em>
69+
{% if author_link %}
70+
<a href="{{ author_link }}">{{ author_name }}</a>
71+
{% else %}
72+
{{ author_name }}
73+
{% endif %}
74+
</em>
75+
</span>
7776

77+
<div>
7878
<!-- page views -->
7979
{% if site.google_analytics.pv.proxy_endpoint or site.google_analytics.pv.cache_path %}
8080
<span>
@@ -84,6 +84,9 @@ <h1 data-toc-skip>{{ page.title }}</h1>
8484
{{ site.data.locales[lang].post.pageview_measure }}
8585
</span>
8686
{% endif %}
87+
88+
<!-- read time -->
89+
{% include read-time.html content=content prompt=true %}
8790
</div>
8891

8992
</div> <!-- .d-flex -->

0 commit comments

Comments
 (0)