diff --git a/assets/controllers/nostr_preview_controller.js b/assets/controllers/nostr_preview_controller.js new file mode 100644 index 0000000..09d4348 --- /dev/null +++ b/assets/controllers/nostr_preview_controller.js @@ -0,0 +1,52 @@ +import { Controller } from '@hotwired/stimulus'; + +export default class extends Controller { + static values = { + identifier: String, + type: String, + decoded: String, + fullMatch: String + } + + static targets = ['container'] + + async connect() { + await this.fetchPreview(); + } + + async fetchPreview() { + try { + // Show loading indicator + this.containerTarget.innerHTML = '
{{ tag[1] }}
+ {% endif %} + {% endfor %} +{{ preview.content }}
+ {% if preview.tags is defined and preview.tags|length > 0 %} ++ {% for tag in preview.tags %} + {% if tag[0] == 'textquoteselector' %} + {% for i in 1..tag|length-1 %} + {{ tag[i] }} + {% if not loop.last %} ++ {% endif %} +
+ {% endif %} + {% endfor %} + {% endif %} + {% endfor %} +
+ {% if preview.event.summary is defined %} + {{ preview.event.summary }} + {% else %} + {{ preview.event.content|length > 150 ? preview.event.content|slice(0, 150) ~ '...' : preview.event.content }} + {% endif %} +
+ {% else %} +{{ preview.content|length > 280 ? preview.content|slice(0, 280) ~ '...' : preview.content }}
+ {% endif %} +{{ preview.about|length > 150 ? preview.about|slice(0, 150) ~ '...' : preview.about }}
+ {% endif %} +{{ item.content }}
+#}
{# {{ article.content }}#}
{# #}
-