added views icon and some alignment changes and code refactoring
This commit is contained in:
parent
8d08147c91
commit
fd8c860d35
@ -1,36 +1,32 @@
|
||||
<em id="postvisitcounter">
|
||||
<i class="fa fa-eye fa-fw me-1" {% if include.tooltip %} title="{{site.data.locales[include.lang].post.views}}"
|
||||
data-bs-toggle="tooltip" data-bs-placement="bottom" {% endif %}></i>
|
||||
<em id="visit-count">
|
||||
</em>
|
||||
|
||||
<!-- <script defer>
|
||||
function postvisits(response) {
|
||||
document.getElementById('postvisitcounter').innerText = response.value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script async src="http://localhost:5016/GetCounter/test?callback=postvisits"></script> -->
|
||||
|
||||
<script>
|
||||
function ajax(url) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = function() {
|
||||
resolve(this.responseText);
|
||||
};
|
||||
xhr.onerror = reject;
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
document.getElementById("postvisitcounter").style.visibility = "hidden";
|
||||
function ajax(url) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = function () {
|
||||
resolve(this.responseText);
|
||||
};
|
||||
xhr.onerror = reject;
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
|
||||
var siteId = "{{ site.id }}";
|
||||
var postId = "{{ page.title }}";
|
||||
var siteId = "{{ site.id }}";
|
||||
var postId = "{{ page.title }}";
|
||||
|
||||
ajax("{{site.custom-config.blog-services.service_url}}/GetPostViews?siteId="+ siteId + "&postId=" + postId)
|
||||
.then(function(result) {
|
||||
console.log(result); // Code depending on result
|
||||
document.getElementById('postvisitcounter').innerText = result;
|
||||
})
|
||||
.catch(function() {
|
||||
// An error occurred
|
||||
});
|
||||
ajax("{{site.custom-config.blog-services.service_url}}/GetPostViews?siteId=" + siteId + "&postId=" + postId)
|
||||
.then(function (result) {
|
||||
console.log(result); // Code depending on result
|
||||
document.getElementById('visit-count').innerText = result;
|
||||
document.getElementById("postvisitcounter").style.visibility = "visible";
|
||||
})
|
||||
.catch(function () {
|
||||
// An error occurred
|
||||
});
|
||||
</script>
|
||||
@ -2,11 +2,11 @@
|
||||
layout: page
|
||||
refactor: true
|
||||
panel_includes:
|
||||
- toc
|
||||
- toc
|
||||
tail_includes:
|
||||
- related-posts
|
||||
- post-nav
|
||||
- comments
|
||||
- related-posts
|
||||
- post-nav
|
||||
- comments
|
||||
---
|
||||
|
||||
{% include lang.html %}
|
||||
@ -14,65 +14,70 @@ tail_includes:
|
||||
<h1 data-toc-skip>{{ page.title }}</h1>
|
||||
|
||||
<div class="post-meta text-muted">
|
||||
<!-- published date -->
|
||||
<span>
|
||||
{{ site.data.locales[lang].post.posted }}
|
||||
{% include datetime.html date=page.date tooltip=true lang=lang %}
|
||||
</span>
|
||||
|
||||
<!-- lastmod date -->
|
||||
{% if page.last_modified_at and page.last_modified_at != page.date %}
|
||||
<span>
|
||||
{{ site.data.locales[lang].post.updated }}
|
||||
{% include datetime.html date=page.last_modified_at tooltip=true lang=lang %}
|
||||
</span>
|
||||
{% endif %}
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<!-- published date -->
|
||||
<span>
|
||||
{{ site.data.locales[lang].post.posted }}
|
||||
{% include datetime.html date=page.date tooltip=true lang=lang %}
|
||||
</span>
|
||||
|
||||
<!-- lastmod date -->
|
||||
{% if page.last_modified_at and page.last_modified_at != page.date %}
|
||||
<span>
|
||||
{{ site.data.locales[lang].post.updated }}
|
||||
{% include datetime.html date=page.last_modified_at tooltip=true lang=lang %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- post counter -->
|
||||
<span>
|
||||
{{ site.data.locales[lang].post.views }}
|
||||
{% include post-counter.html %}
|
||||
</span>
|
||||
<div id="postvisitcounter">
|
||||
<!-- {{ site.data.locales[lang].post.views }} -->
|
||||
{% include post-counter.html tooltip=true lang=lang %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if page.image %}
|
||||
{% capture src %}src="{{ page.image.path | default: page.image }}"{% endcapture %}
|
||||
{% capture class %}class="preview-img{% if page.image.no_bg %}{{ ' no-bg' }}{% endif %}"{% endcapture %}
|
||||
{% capture alt %}alt="{{ page.image.alt | xml_escape | default: "Preview Image" }}"{% endcapture %}
|
||||
{% capture src %}src="{{ page.image.path | default: page.image }}"{% endcapture %}
|
||||
{% capture class %}class="preview-img{% if page.image.no_bg %}{{ ' no-bg' }}{% endif %}"{% endcapture %}
|
||||
{% capture alt %}alt="{{ page.image.alt | xml_escape | default: "Preview Image" }}"{% endcapture %}
|
||||
|
||||
{% capture lqip %}
|
||||
{% if page.image.lqip %}
|
||||
lqip="{{ page.image.lqip }}"
|
||||
{% endif %}
|
||||
{% endcapture %}
|
||||
{% capture lqip %}
|
||||
{% if page.image.lqip %}
|
||||
lqip="{{ page.image.lqip }}"
|
||||
{% endif %}
|
||||
{% endcapture %}
|
||||
|
||||
<div class="mt-3 mb-3">
|
||||
<img {{ src }} {{ class }} {{ alt }} w="1200" h="630" {{ lqip | strip }}>
|
||||
{%- if page.image.alt -%}
|
||||
<figcaption class="text-center pt-2 pb-2">{{ page.image.alt }}</figcaption>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
<div class="mt-3 mb-3">
|
||||
<img {{ src }} {{ class }} {{ alt }} w="1200" h="630" {{ lqip | strip }}>
|
||||
{%- if page.image.alt -%}
|
||||
<figcaption class="text-center pt-2 pb-2">{{ page.image.alt }}</figcaption>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<!-- author(s) -->
|
||||
<span>
|
||||
{% if page.author %}
|
||||
{% assign authors = page.author %}
|
||||
{% assign authors = page.author %}
|
||||
{% elsif page.authors %}
|
||||
{% assign authors = page.authors %}
|
||||
{% assign authors = page.authors %}
|
||||
{% endif %}
|
||||
|
||||
{{ site.data.locales[lang].post.written_by }}
|
||||
|
||||
<em>
|
||||
{% if authors %}
|
||||
{% if authors %}
|
||||
{% for author in authors %}
|
||||
<a href="{{ site.data.authors[author].url }}">{{ site.data.authors[author].name }}</a>
|
||||
{% unless forloop.last %}</em>, <em>{% endunless %}
|
||||
<a href="{{ site.data.authors[author].url }}">{{ site.data.authors[author].name }}</a>
|
||||
{% unless forloop.last %}</em>, <em>{% endunless %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% else %}
|
||||
<a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</em>
|
||||
</span>
|
||||
|
||||
@ -96,8 +101,8 @@ tail_includes:
|
||||
<div class="post-meta mb-3">
|
||||
<i class="far fa-folder-open fa-fw me-1"></i>
|
||||
{% for category in page.categories %}
|
||||
<a href='{{ site.baseurl }}/categories/{{ category | slugify | url_encode }}/'>{{ category }}</a>
|
||||
{%- unless forloop.last -%}, {%- endunless -%}
|
||||
<a href='{{ site.baseurl }}/categories/{{ category | slugify | url_encode }}/'>{{ category }}</a>
|
||||
{%- unless forloop.last -%}, {%- endunless -%}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
@ -106,12 +111,11 @@ tail_includes:
|
||||
{% if page.tags.size > 0 %}
|
||||
<div class="post-tags">
|
||||
<i class="fa fa-tags fa-fw me-1"></i>
|
||||
{% for tag in page.tags %}
|
||||
<a href="{{ site.baseurl }}/tags/{{ tag | slugify | url_encode }}/"
|
||||
class="post-tag no-text-decoration" >
|
||||
{{- tag -}}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% for tag in page.tags %}
|
||||
<a href="{{ site.baseurl }}/tags/{{ tag | slugify | url_encode }}/" class="post-tag no-text-decoration">
|
||||
{{- tag -}}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@ -121,13 +125,13 @@ tail_includes:
|
||||
|
||||
{% if site.data.locales[lang].copyright.license.template %}
|
||||
|
||||
{% capture _replacement %}
|
||||
<a href="{{ site.data.locales[lang].copyright.license.link }}">
|
||||
{{ site.data.locales[lang].copyright.license.name }}
|
||||
</a>
|
||||
{% endcapture %}
|
||||
{% capture _replacement %}
|
||||
<a href="{{ site.data.locales[lang].copyright.license.link }}">
|
||||
{{ site.data.locales[lang].copyright.license.name }}
|
||||
</a>
|
||||
{% endcapture %}
|
||||
|
||||
{{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }}
|
||||
{{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
@ -136,4 +140,4 @@ tail_includes:
|
||||
|
||||
</div><!-- .post-tail-bottom -->
|
||||
|
||||
</div><!-- div.post-tail-wrapper -->
|
||||
</div><!-- div.post-tail-wrapper -->
|
||||
Loading…
Reference in New Issue
Block a user