Skip to content

Commit

Permalink
feat(template): simplify thumbnail logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sparanoid committed Jan 6, 2017
1 parent dc9831c commit bb811b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
1 change: 0 additions & 1 deletion TODOS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Todos

- Try load-grunt-config
- Cleanup thumb fetching method for `amsf_page_thumb` in `_amsf.html`
31 changes: 23 additions & 8 deletions _app/_includes/_amsf.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@
{% endcapture %}

{% comment %}
Page thumbnail
First image in post
TODO: https://regex101.com/r/N2hoxV/1
{% endcomment %}
{% assign amsf_site_logo = "/logo.png" | prepend: amsf_site_base %}
{% capture amsf_post_first_image %}
{% capture amsf_page_first_image %}
{% assign hero_image = page.content | match_regex: '<img .*?src="([^"]+)"' %}
{% if hero_image == nil %}
{% assign hero_image = amsf_site_logo %}
Expand All @@ -228,17 +228,32 @@
{% endif %}
{% endcapture %}

{% capture amsf_page_thumb %}
{% comment %}
Page thumbnail
Regex: https://regex101.com/r/AmwvYE/2
{% endcomment %}
{% capture amsf_page_thumbnail_src %}
{% assign protocal = page.thumbnail | match_regex: '^((?:https?:)?\/\/)' %}
{% if protocal == null %}
{% if page.thumbnail-local %}
{{ amsf_user_assets | prepend: amsf_site_base }}/{{ page.thumbnail }}
{% else %}
{{ site.file }}/{{ page.thumbnail }}
{% endif %}
{% else %}
{{ page.thumbnail }}
{% endif %}
{% endcapture %}

{% capture amsf_page_thumbnail %}
{% if page.thumb_force_logo %}
{{ amsf_site_logo }}
{% elsif page.thumb %}
{{ site.file }}/thumb/{{ page.thumb }}
{% elsif page.thumb_url %}
{{ page.thumb_url }}
{% elsif page.thumbnail %}
{{ amsf_page_thumbnail_src }}
{% elsif page.heading-bg %}
{{ amsf_page_heading_bg_image_src }}
{% else %}
{{ amsf_post_first_image }}
{{ amsf_page_first_image }}
{% endif %}
{% endcapture %}

Expand Down
2 changes: 1 addition & 1 deletion _app/_includes/themes/curtana/includes/open-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta property="og:title" content="{{ amsf_page_title }}">
<meta property="og:url" content="{{ amsf_page_url }}">
<meta property="og:description" content="{{ amsf_site_desc | strip }}">
<meta property="og:image" content="{{ amsf_page_thumb | strip }}">
<meta property="og:image" content="{{ amsf_page_thumbnail | strip }}">

<meta name="twitter:card" content="{{ amsf_page_type_twitter | strip }}">

Expand Down

0 comments on commit bb811b0

Please sign in to comment.