forked from deepStateMirrors/tabi
✨ feat(iine): add like buttons (#550)
This commit is contained in:
parent
79b5dcf9a7
commit
daa8b1a412
48 changed files with 505 additions and 8 deletions
|
@ -7,6 +7,9 @@ content="default-src 'self'
|
|||
{%- set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus -%}
|
||||
{%- set hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk -%}
|
||||
{%- set isso_enabled = config.extra.isso.enabled_for_all_posts or page.extra.isso -%}
|
||||
{%- if page -%}
|
||||
{%- set iine_enabled = macros_settings::evaluate_setting_priority(setting="iine", page=page, default_global_value=false) == "true" -%}
|
||||
{%- endif -%}
|
||||
{%- if page -%}
|
||||
{%- set mermaid_enabled = macros_settings::evaluate_setting_priority(setting="mermaid", page=page, default_global_value=false) == "true" -%}
|
||||
{%- endif -%}
|
||||
|
@ -50,7 +53,7 @@ content="default-src 'self'
|
|||
{%- set script_src = script_src ~ " " ~ " utteranc.es" -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if mermaid_enabled and not serve_local_mermaid -%}
|
||||
{%- if (mermaid_enabled and not serve_local_mermaid) or iine_enabled -%}
|
||||
{%- set script_src = script_src ~ " " ~ " cdn.jsdelivr.net" -%}
|
||||
{%- endif -%}
|
||||
|
||||
|
@ -59,6 +62,11 @@ content="default-src 'self'
|
|||
{%- set connect_src = connect_src ~ " webmention.io" -%}
|
||||
{%- endif -%}
|
||||
|
||||
{#- Check if iine like buttons are enabled to allow the necessary domains -#}
|
||||
{%- if iine_enabled -%}
|
||||
{%- set connect_src = connect_src ~ " vhiweeypifbwacashxjz.supabase.co" -%}
|
||||
{%- endif -%}
|
||||
|
||||
{#- Append WebSocket for Zola serve mode -#}
|
||||
{%- if config.mode == "serve" -%}
|
||||
{%- set connect_src = connect_src ~ " ws:" -%}
|
||||
|
|
|
@ -81,3 +81,8 @@
|
|||
{%- if macros_settings::evaluate_setting_priority(setting="footnote_backlinks", page=page_s, section=section_s, default_global_value=false) == "true" -%}
|
||||
<script defer src="{{ get_url(path='js/footnoteBacklinks.min.js', trailing_slash=false | safe )}}"></script>
|
||||
{%- endif -%}
|
||||
|
||||
{# Add iine.js for the like button #}
|
||||
{%- if macros_settings::evaluate_setting_priority(setting="iine", page=page_s, section=section_s, default_global_value=false) == "true" -%}
|
||||
<script defer src="https://cdn.jsdelivr.net/gh/welpo/iine@main/iine.mini.js"></script>
|
||||
{%- endif -%}
|
||||
|
|
33
templates/partials/iine_button.html
Normal file
33
templates/partials/iine_button.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{% import "macros/settings.html" as macros_settings %}
|
||||
{%- set button_icon = button_icon | default(value=macros_settings::evaluate_setting_priority(setting="iine_icon", page=page | default(value=""), section=section | default(value=""), default_global_value="heart")) -%}
|
||||
{%- if config.extra.iine_unified_languages and lang != config.default_language -%}
|
||||
{%- set unified_slug = page.path | replace(from='/' ~ lang ~ '/', to='/') -%}
|
||||
{%- set slug = slug | default(value=unified_slug) -%}
|
||||
{%- else -%}
|
||||
{%- set slug = slug | default(value=page.path) -%}
|
||||
{%- endif -%}
|
||||
{%- if label -%}
|
||||
{%- set final_label = label -%}
|
||||
{%- elif language_strings -%}
|
||||
{%- set final_label = macros_translate::translate(key="like_this_post", default="Like this post", language_strings=language_strings) -%}
|
||||
{%- else -%}
|
||||
{%- set final_label = "Like this post" -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if button_icon == "heart" -%}
|
||||
{%- set icon_display = "♥️" -%}
|
||||
{%- elif button_icon == "thumbs_up" -%}
|
||||
{%- set icon_display = "👍" -%}
|
||||
{%- elif button_icon == "upvote" -%}
|
||||
{%- set icon_display = "⬆️" -%}
|
||||
{%- else -%}
|
||||
{%- set icon_display = button_icon -%}
|
||||
{%- endif -%}
|
||||
|
||||
<form method="post" action="https://vhiweeypifbwacashxjz.supabase.co/rest/v1/rpc/increment_hits?apikey=sb_publishable_EoB7MFJhCmb6PiAk-GPJ4w_PGhQ44Ru" class="iine-form">
|
||||
<input type="hidden" name="page_slug" value="{%- if slug -%}{{ slug }}{%- else -%}{{ current_url | default(value=page.path) }}{%- endif -%}">
|
||||
<button class="iine-button" type="submit"
|
||||
{%- if slug %} data-slug="{{ slug }}"{% endif %}
|
||||
{%- if button_icon %} data-icon="{{ button_icon }}"{% endif %}
|
||||
aria-label="{{ final_label }}" title="{{ final_label }}">{{ icon_display }}</button>
|
||||
</form>
|
Loading…
Add table
Add a link
Reference in a new issue