diff --git a/config.toml b/config.toml index 5c39ecd..bb79fe3 100644 --- a/config.toml +++ b/config.toml @@ -128,4 +128,11 @@ disqus = { enabled=false, short_name="" } # generate Table of Contents for all articles # Table of Contents can be generated for individual articles # by adding `ToC = true` in [extra] section in frontmatter -# ToC = true \ No newline at end of file +# ToC = true + +# Twitter metadata +# the website used in the card footer +# twitter_site="@username_website" +# for the actual author of the page +# (it can be overwrited specifying a custom `twitter_user` in [extra] in frontmatter) +# twitter_user="@username_user" diff --git a/templates/index.html b/templates/index.html index cfbf5bf..767fd6d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,6 +27,10 @@ {{ social::og_preview() }} {%- endblock og_preview -%} + {%- block twitter_preview -%} + {{ social::twitter_preview() }} + {%- endblock twitter_preview -%} + {%- block fonts -%} {{ head::fonts() }} {%- endblock fonts -%} diff --git a/templates/macros/social.html b/templates/macros/social.html index 14fada5..6bf0e8f 100644 --- a/templates/macros/social.html +++ b/templates/macros/social.html @@ -5,11 +5,47 @@ {%- endif -%} - {%- if config.extra.og_preview_img -%} + + {%- if section -%} + {%- if config.extra.og_preview_img -%} - {%- endif -%} + {%- endif -%} + + {%- elif page -%} + {%- if page.extra.og_image -%} + + {%- elif config.extra.og_preview_img -%} + + {%- endif -%} + {%- endif -%}{# ./if section #} {% endmacro og_preview %} +{% macro twitter_preview() %} + {%- if page -%} + {% if page.extra.og_image %} + + {% else %} + + {%- endif -%} + {% else %} + + {%- endif -%} + + {% if config.extra.twitter_site -%} + + {%- endif -%} + + {% if page %} + {%- if page.extra.twitter_user -%} + + {%- elif config.extra.twitter_user -%} + + {%- endif -%}{# ./if page.extra.twitter_user #} + {%- elif config.extra.twitter_user %} + + {%- endif %}{# ./if page #} +{% endmacro twitter_preview %} + {% macro og_description() %} {%- if section -%} {%- if section.description -%}