superinteractive / statamic-super-sections
Reusable Blade component support for Statamic Super Sections, pages, articles, and Bard/replicator sets.
Package info
github.com/superinteractive/statamic-super-sections
Type:statamic-addon
pkg:composer/superinteractive/statamic-super-sections
Requires
- php: ^8.4
- statamic/cms: ^5.0 || ^6.0
Requires (Dev)
- laravel/pint: ^1.24
- mockery/mockery: ^1.6
- orchestra/testbench: ^8.36 || ^9.15 || ^10.8 || ^11.0
- pestphp/pest: ^2.36 || ^3.8 || ^4.0
- pestphp/pest-plugin-laravel: ^2.4 || ^3.0 || ^4.0
- phpunit/phpunit: ^10.5 || ^11.5 || ^12.0
- statamic/eloquent-driver: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Reusable Laravel Blade component primitives for rendering Statamic section rows from pages, articles, Bard sets, replicators, and similar structured content.
Installation
composer require superinteractive/statamic-super-sections
The addon is discovered automatically by Laravel and Statamic.
Rendering Sections
Render page and article section rows with the package-provided collection components:
<x-super::page-sections :sections="$sections" /> <x-super::article-sections :sections="$sections" />
Attributes passed to the collection component are applied to the wrapper <div>:
<x-super::page-sections :sections="$sections" class="space-y-12" />
The super:: namespace applies only to the package-owned collection wrappers. Individual section components remain app-owned, class-backed Blade components:
App\View\Components\PageSections\Hero
App\View\Components\ArticleSections\Text
Child component names stay un-namespaced:
page-sections.hero
article-sections.text
Set Preview Images
Statamic 6+ only. On Statamic 5 the package does not change set previews.
Put the preview images in resources/set-previews/. Refer to them by filename in the set's image: key:
sets: hero: image: hero-page-section.jpg
The package registers a set_previews disk with root resources/set-previews, unless the project already defines that disk. It also sets statamic.assets.set_preview_images to the set_previews container. Remove both from the project config. A project cannot override this setting.
The project keeps the container. With the file container driver, put this in the asset containers directory, for example resources/_statamic/asset-containers/set_previews.yaml:
title: "Set Previews" disk: set_previews allow_uploads: false allow_downloading: false allow_renaming: false allow_moving: false create_folders: false sort_by: basename sort_dir: asc
Eloquent asset driver
When statamic.eloquent-driver.assets.driver is eloquent, the package replaces the Eloquent driver's asset repository. Preview images then load from the disk and never need database rows, so do not run statamic:eloquent:sync-assets for them. All other containers still use the Eloquent driver.
The package replaces only the driver's own repository. If the project or another addon binds its own asset repository, the package leaves it in place. Make that repository extend SuperInteractive\StatamicSuperSections\Assets\AssetRepository, so preview images still load without database rows:
use SuperInteractive\StatamicSuperSections\Assets\AssetRepository as SectionsAssetRepository; class AssetRepository extends SectionsAssetRepository { // Project overrides. }
A repository that does not extend it serves preview images only when they have database rows.
File asset driver
Statamic writes metadata files next to the images the first time a preview loads. Add this to .gitignore:
/resources/set-previews/.meta
Permissions
Every Control Panel user has the view ability on files in the preview container, so roles need no view set_previews assets permission. view also allows viewing a file's details and downloading it, even with allow_downloading: false. Users still need access cp. All other abilities and containers keep their normal permissions.
Local Development
When developing this package with the Super Statamic Starter Kit source app, work from the package repository:
cd Packages/statamic-super-sections
Field Resolver Conventions
SectionFieldResolver keeps Statamic values close to their native form until a section component asks for a specific normalized value.
Field handles are passed to Blade section components as Laravel-compatible attributes:
button_textbecomesbutton-text, which maps to$buttonText.column_1becomescolumn1, which maps to$column1.hero_image_2becomeshero-image2, which maps to$heroImage2.
Repeatable rows are filtered only when every value is blank. null, false, empty strings, whitespace-only strings, and empty arrays are blank. 0 and "0" are filled values and are preserved.
Link Href Policy
Link URLs are trimmed before output. Relative paths, anchors, and the schemes http, https, mailto, and tel are allowed.
The resolver rejects blank hrefs, protocol-relative URLs, control characters, and schemes outside the allowlist such as javascript:, data:, and sms:.
This is an allowlist for safe editorial href output, not a full URL validator. Projects that need additional schemes should extend the addon with an explicit configuration surface before allowing those schemes.