From a06f744ec1d1b04741ae64ee5fb0b520536b6796 Mon Sep 17 00:00:00 2001 From: Mischa Date: Fri, 19 Jun 2026 22:47:23 +0200 Subject: [PATCH] feat: add scrolly-section shortcode (Scrollama-driven sticky image steps) --- .../shortcodes/ScrollySectionShortcode.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 plugins/story-blocks/shortcodes/ScrollySectionShortcode.php diff --git a/plugins/story-blocks/shortcodes/ScrollySectionShortcode.php b/plugins/story-blocks/shortcodes/ScrollySectionShortcode.php new file mode 100644 index 0000000..077829e --- /dev/null +++ b/plugins/story-blocks/shortcodes/ScrollySectionShortcode.php @@ -0,0 +1,42 @@ +shortcode->getHandlers()->add('scrolly-section', function (ShortcodeInterface $sc) { + $plugin = $this->grav['plugins']->getPlugin('story-blocks'); + $page = $plugin ? $plugin->getCurrentPage() : null; + + $imageName = $sc->getParameter('image', ''); + $alt = htmlspecialchars($sc->getParameter('alt', ''), ENT_QUOTES); + $caption = htmlspecialchars($sc->getParameter('caption', ''), ENT_QUOTES); + $content = $sc->getContent(); /* raw inner content — Scrollama JS splits on
*/ + $imageUrl = ($page && $imageName) ? $page->url() . '/' . $imageName : $imageName; + + $captionHtml = $caption + ? '

' . $caption . '

' + : ''; + + return << + +
+
+ {$content} +
+
+ +HTML; + }); + } +}