Index: includes/meta/social.tmpl |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/includes/meta/social.tmpl |
@@ -0,0 +1,63 @@ |
+{% set social_media_meta = [ |
+ ('og:url', |
juliandoucette
2018/01/30 04:04:40
NIT: I'm really not digging this
('multi',
line
ire
2018/01/30 08:19:08
I don't think it's very ideal either, but I also t
juliandoucette
2018/01/31 19:03:22
Acknowledged.
|
+ og_url, |
+ get_canonical_url(page)), |
+ ('og:type', |
juliandoucette
2018/01/30 04:04:40
NIT: I think the default is website and we don't n
ire
2018/01/30 08:19:08
I doesn't seem that this data is implied without b
juliandoucette
2018/01/31 19:03:21
Acknowledged.
|
+ og_type, |
+ 'website'), |
+ ('og:site_name', |
+ og_site_name, |
+ get_string('name', 'site') if has_string('name', 'site') else None), |
ire
2018/01/26 11:33:59
I changed this to use the same site name string as
juliandoucette
2018/01/30 04:04:39
NIT: `condition and output` can replace `output if
juliandoucette
2018/01/30 04:04:40
Acknowledged.
ire
2018/01/30 08:19:08
Are you saying a valid way to write this is `has_s
juliandoucette
2018/01/31 19:03:21
Yes. But apparently you can also just drop the `el
ire
2018/02/01 09:07:01
The line `has_string('name', 'site') and get_strin
|
+ ('og:title', |
+ og_title, |
ire
2018/01/26 11:33:59
Should `og_title` be translated as well (since tit
juliandoucette
2018/01/30 04:04:40
Yes.
ire
2018/01/30 08:19:08
Done.
|
+ title | translate('title', 'Meta data') if title else None), |
+ ('og:description', |
+ og_description, |
+ description | translate('page-description', 'Meta data') if description else None), |
+ ('og:image', |
+ og_image, |
+ featured_img_url), |
+ ('og:image:alt', |
+ og_image_alt, |
+ featured_img_alt), |
+ ('og:locale', |
+ og_locale, |
+ locale | to_og_locale), |
+ |
+ ('twitter:site', |
+ twitter_site, |
+ config.get('social', 'twitter') if config.has_option('social', 'twitter') else '@eyeo'), |
ire
2018/01/26 11:33:59
I think the site's twitter username, facebook id,
juliandoucette
2018/01/30 04:04:40
NIT: Long line
juliandoucette
2018/01/30 04:04:40
Acknowledged.
ire
2018/01/30 08:19:08
I can't think of any better way to write this than
juliandoucette
2018/01/31 19:03:21
Acknowledged.
|
+ ('twitter:card', |
+ twitter_card, |
+ 'summary_large_image' if og_image or twitter_image or featured_img_url else 'summary'), |
+ ('twitter:image', |
juliandoucette
2018/01/30 04:04:40
NIT: We may not want to add og:image and twitter:i
ire
2018/01/30 08:19:08
Ack. But there's no reason to exclude it now, is t
juliandoucette
2018/01/31 19:03:21
We should not maintain code that we do not and pro
ire
2018/02/01 09:07:01
It will be used for pages that already have a feat
|
+ twitter_image, |
+ featured_img_url), |
+ ('twitter:image:alt', |
+ twitter_image_alt, |
+ featured_img_alt), |
+ |
+ ('fb:app_id', |
+ facebook_id, |
+ config.get('social', 'facebook_id') if config.has_option('social', 'facebook_id') else None), |
+ |
+ ('p:domain_verify', |
+ pinterest_id, |
+ config.has_option('social', 'pinterest_id') if config.has_option('social', 'pinterest_id') else None), |
+] %} |
+ |
+{% macro meta_tag(property, content, defaultContent=None) -%} |
juliandoucette
2018/01/30 04:04:40
NIT: We could use this macro elsewhere if you sepa
ire
2018/01/30 08:19:07
Done.
|
+ {% if content or defaultContent %} |
+ <meta property='{{ property }}' content='{{ content or defaultContent }}'> |
+ {% endif %} |
+{%- endmacro %} |
+ |
+{% for property, content, defaultContent in social_media_meta %} |
juliandoucette
2018/01/30 04:04:40
NIT: You could use a for in loop here instead of d
ire
2018/01/30 08:19:08
That seems more messy to me. I think it's better t
juliandoucette
2018/01/31 19:03:21
Acknowledged.
|
+ {{ meta_tag(property, content, defaultContent) }} |
+{% endfor %} |
+ |
+{% for alternate_locale in available_locales %} |
+ {% if alternate_locale != locale %} |
+ {{ meta_tag(('og:locale:alternate', alternate_locale | to_og_locale)) }} |
juliandoucette
2018/01/30 04:04:40
Detail: This implementation is correct but it does
ire
2018/01/30 08:19:08
Ack. I think you're right it should go into standa
|
+ {% endif %} |
+{% endfor %} |