make external links open in new tab

This commit is contained in:
timurgordon
2022-08-25 14:09:11 +03:00
parent 18a96f0adc
commit 22a94bfe70
4 changed files with 4374 additions and 9 deletions

View File

@@ -10,8 +10,10 @@ Parameters:
-->
<!-- This fixes link paths in prod -->
{% if page %}
{% if "](" in body %}
{% set body_arr = body | split(pat="](") %}
{% set body = body_arr[0] %}
{% for i in body_arr %}
@@ -33,10 +35,12 @@ Parameters:
{% endif %}
<!-- This fixes image paths in local -->
<!-- makes external links in row open in new tabs-->
{% set body = body | markdown | replace(from='href="', to='target="_blank" href="') | safe %}
{% set base_url = get_url(path="")%}
{% set body = body | markdown | replace(from='target="_blank" href="' ~ base_url , to='href="' ~ base_url) | safe %}
<!-- Splits body to columns -->
{% set columns = body | safe | markdown | split(pat="|||") %}
{% set row_class = "relative pt-6 p-4 flex flex-col sm:grid sm:grid-cols-2 sm:gap-10 xl:flex xl:flex-row"%}
@@ -109,10 +113,12 @@ Parameters:
{% set row_class = row_class ~ "w-screen -mx-8 sm:-mx-12 md:-mx-16 lg:-mx-20" %}
{% endif %}
{% set url = body | split(pat="href=") | slice(start=1) | first | split(pat=">") | first | trim_start_matches(pat='"') %}
<div class="{{row_class}}" style="{{styles}}" id="{{row_id}}">
{% for column in columns%}
{% for column in columns %}
<!-- Hides empty columns if displayed vertically in small screen -->
{% if column | as_str | length < 10 %}
<div class="hidden md:block flex-1 md:mb-0 md:mx-8 sm:flex-1">