Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Update index.twig
Browse files Browse the repository at this point in the history
Fixed a bug in the url display due to (possibly) a bug in the trim() function.
  • Loading branch information
kerns authored Jul 25, 2022
1 parent c43e3be commit a79d194
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion templates/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@
{# Example of setting/requesting/testing and filtering vars in Twig #}
{% set url = craft.app.request.absoluteUrl %}
{% set protocol = 'https://' in url ? 'https' : 'http' %}
{% set url = craft.app.request.absoluteUrl|trim('https://') %}

{# Example of simple if/else conditional in Twig #}
{% if protocol == 'https' %}
{% set url = craft.app.request.absoluteUrl|replace('/^https:?\\/\\//', '') %}
{% set animationArray = [
{ src: 'https://assets10.lottiefiles.com/packages/lf20_pkanqwys.json', size:'h-72', position:'left-0 -top-64' },
{ src: 'https://assets9.lottiefiles.com/packages/lf20_nxsyeqbd.json', size:'h-64', position:'left-0 -top-64' },
{ src: 'https://assets2.lottiefiles.com/packages/lf20_vwly0biq.json', size:'h-72', position:'left-0 -top-64 mt-2' },
{ src: 'https://assets1.lottiefiles.com/packages/lf20_rovf9gzu.json', size:'h-96', position:'left-0 -top-80' }
] %}
{% else %}
{% set url = craft.app.request.absoluteUrl|replace('/^http:?\\/\\//', '') %}
{% set animationArray = [
{ src: 'https://assets8.lottiefiles.com/packages/lf20_3ki8odep.json', size:'h-96', position:'left-0 -top-80' },
] %}
{% endif %}

{# Remove the trailing / #}
{% set url = url|trim('/') %}

{# Example of selecting a random item from an array in Twig #}
{% set animation = shuffle(animationArray) | first %}
Expand Down

0 comments on commit a79d194

Please sign in to comment.