Check if page.description is empty before trying to use it
The article.html template, when the sharing button is enabled, uses the description of the page to generate the share link. However the end user may not want descriptions. If a page description is empty, the following error is thrown: ``` Error: Failed to build the site Error: Failed to render page '/home...index.md' Error: Reason: Failed to render 'article.html' Error: Reason: Filter call 'urlencode' failed Error: Reason: Filter `urlencode` was called on an incorrect value: got `null` but expected a String ``` We now check if the description is not empty before passing it to urlencode, and don't use it if it is not set
This commit is contained in:
@ -116,7 +116,7 @@
|
||||
{%- endif -%}
|
||||
<a id="go-to-top" href="#top" title="{{ macros_translate::translate(key='go_to_top', default='Go to Top', language_strings=language_strings) }}"><i class="icon"></i></a>
|
||||
{%- if config.extra.show_share_button -%}
|
||||
<a id="share" href="https://shareopenly.org/share/?url={{ page.permalink }}&text={{ page.description | urlencode }}" rel="{{ rel_attributes }}" title="{{ macros_translate::translate(key='share', default='Share', language_strings=language_strings) }}"><i class="icon"></i></a>
|
||||
<a id="share" href="https://shareopenly.org/share/?url={{ page.permalink }}{%- if page.description -%}&text={{ page.description | urlencode }}{%- endif -%}" rel="{{ rel_attributes }}" title="{{ macros_translate::translate(key='share', default='Share', language_strings=language_strings) }}"><i class="icon"></i></a>
|
||||
{%- endif -%}
|
||||
{%- if config.extra.issues_url -%}
|
||||
<a id="issue" href="{{ config.extra.issues_url }}" rel="{{ rel_attributes }}" title="{{ macros_translate::translate(key='file_an_issue', default='File an Issue', language_strings=language_strings) }}"><i class="icon"></i></a>
|
||||
|
Reference in New Issue
Block a user