Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

statamic-with-eloquent静态与雄辩

Agent Skill

statamic-with-eloquent 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

329

周安装

14

GitHub Stars

公开资料未说明

下载量

115
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:statamic-with-eloquent(静态与雄辩)
来源仓库:https://github.com/jordidolphiq/statamic-with-eloquent-skill
仓库路径:skills/statamic-with-eloquent
安装命令:
npx skills add https://github.com/jordidolphiq/statamic-with-eloquent-skill --skill statamic-with-eloquent
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/jordidolphiq/statamic-with-eloquent-skill --skill statamic-with-eloquent

简介

statamic-with-eloquent 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 适用于需要根据关键词或任务场景进行信息检索的场景,如静态站点生成、Laravel 集成。
  • 通过 npx skills add 命令从 GitHub 仓库安装,需结合原始 README 确认具体用法。
  • 安装前建议确认权限范围和维护状态,注意是否会触发联网或文件读写操作。
  • 建议核验来源仓库内容,确保功能与预期一致后再投入实际使用。

SKILL.md

Statamic CMS Development

When to Apply

Activate this skill when:

  • Creating or editing Statamic collections, blueprints, fieldsets, or globals
  • Working with Statamic entries, taxonomies, or navigations
  • Building page templates or content block partials
  • Creating or modifying View Composers for Statamic views
  • Working with Bard, Replicator, or other Statamic fieldtypes
  • Querying content via Statamic facades
  • Running php please commands

Documentation

Use search-docs with packages: ["statamic/cms"] for version-specific Statamic documentation.

Blade-Only Templating

This project uses Blade exclusively — no Antlers. All templates are .blade.php files. Statamic variables are accessed as regular PHP variables in Blade.

{{-- Correct: Blade syntax --}}
<h1>{{ $title }}</h1>

{{-- WRONG: Antlers syntax — never use this --}}
{{ title }}

Eloquent Driver

This project uses the Statamic Eloquent Driver with a hybrid storage strategy. Check config/statamic/eloquent-driver.php to see which resources use eloquent (database) vs file (disk).

  • Entries, terms, globals variables, nav trees, revisions → stored in database
  • Blueprints, fieldsets, collections, forms → stored as YAML files on disk
  • All Eloquent tables use a configurable prefix (see STATAMIC_ELOQUENT_PREFIX env var)

Always query content via Statamic facades — they abstract the storage driver.

Querying Content

Use Statamic facades, never raw DB queries:

use Statamic\Facades\Entry;
use Statamic\Facades\GlobalSet;
use Statamic\Facades\Collection;
use Statamic\Facades\Term;

// Query entries from a collection
$entries = Entry::query()
    ->where('collection', 'pages')
    ->where('status', 'published')
    ->get();

// Find a single entry
$entry = Entry::find($id);

// Get a global set's values
$globalData = GlobalSet::findByHandle('footer')?->inCurrentSite()?->values();

// Collection tree (hierarchical content)
$tree = Collection::findByHandle('knowledge_base')?->structure()?->in('default');
$page = $tree->find($entryId);
$parent = $page?->parent();

Field Access in Blade Templates (Critical)

Statamic injects entry fields into Blade templates. This is the primary way data reaches templates and how you should access it. There are two patterns:

1. Top-Level Variables (Most Common)

Statamic cascades all entry fields as individual Blade variables. Blueprint field handles become variable names directly:

{{-- Blueprint fields are available as top-level $variables --}}
{{ $title }}
{{ $hero_title ?? '' }}
{{ $hero_subtitle ?? '' }}

{{-- Always null-coalesce optional fields --}}
@if ($hero_intro ?? false)
    {!! $hero_intro !!}
@endif

{{-- Replicator/Bard fields are iterable --}}
@foreach ($page_content as $set)
    @include('partials.sets.' . $set->type, [...$set])
@endforeach

{{-- Pre-unwrapped blocks (from View Composers) --}}
@foreach ($blocks ?? [] as $block)
    @include("partials.sets.{$block['type']}", $block)
@endforeach

2. Via the $page Entry Object

The current entry is also available as $page. Use this for accessing the entry directly:

{{-- Dynamic property access on the entry --}}
<h1>{{ $page->title }}</h1>
<h2>{{ $page->subtitle }}</h2>

{{-- Conditionals on entry fields --}}
@if ($page->hero_title && $page->show_hero)
    @include('partials.hero')
@endif

{{-- URL and metadata --}}
<a href="{{ $page->url() }}">{{ $page->title }}</a>

Which to Use

  • Top-level $variables — Use for fields that may need null-coalescing or when passing to components. This is what Statamic injects by default.
  • $page->field — Use when you need to access the entry object directly, check multiple fields, or when the field name might conflict with a Blade variable.
  • $entry->get('field') — Use in PHP code (View Composers, helpers) to avoid PHPStan ignores.

Important: Fields Are Value Objects

All field variables in templates are Statamic\Fields\Value objects, not raw PHP values. Blade's {{}} syntax calls __toString() automatically for simple fields, but for complex fields (arrays, relationships) you must handle them explicitly:

{{-- Simple fields: Value auto-casts to string in {{ }} --}}
{{ $title }}

{{-- Complex fields: use unwrap() or check type --}}
@php $items = unwrap($usps ?? []) @endphp
@foreach ($items as $item)
    <li>{{ $item['text'] }}</li>
@endforeach

Value Object Handling in PHP

In PHP code (View Composers, helpers), Statamic wraps field data in Statamic\Fields\Value and Statamic\Fields\Values objects. These must be unwrapped explicitly.

Checking and Unwrapping Values

use Statamic\Fields\Value;

// Check if a field is a Value with actual content
if ($field instanceof Value && $field->value()) {
    $raw = $field->value();  // Get the underlying data
}

// For relationship fields (entries fieldtype)
if ($entries instanceof Value && $entries->value()) {
    foreach ($entries as $entry) {
        // Each $entry is a Statamic Entry object
    }
}

Field Access in PHP Code

// Preferred in PHP — no PHPStan ignores needed
$value = $entry->get('field_name');

// Dynamic property access — works but needs @phpstan-ignore
$title = $entry->title;  // @phpstan-ignore property.notFound

Blueprints

Blueprints are YAML files in resources/blueprints/. They define the field structure for collections, globals, navigations, and asset containers.

Common Fieldtypes

FieldtypeDescription
textSingle-line text
textareaMulti-line text
bardRich text editor with sets
replicatorRepeatable content blocks
entriesRelationship to other entries
assetsFile/image upload
toggleBoolean
selectDropdown
colorColor picker
linkURL or entry reference
iconIcon picker
taxonomyTaxonomy term relationship
gridTable-like repeating rows

Blueprint Conventions

  • Use import for shared fieldsets (e.g., hero, seo)
  • Group fields into tabs: main, seo, sidebar
  • Use required: true on essential fields
  • Handles use snake_case
tabs:
  main:
    sections:
      - fields:
          - handle: title
            field:
              type: text
              required: true
          - import: page_blocks
  seo:
    sections:
      - import: seo

Content Blocks (Replicator Pattern)

Content blocks are Replicator sets rendered as Blade partials. Each block type has a corresponding partial:

@foreach ($page_content as $set)
    @include('partials.sets.' . $set->type, [...$set])
@endforeach

When creating a new block:

  1. Add the set definition to the Replicator field in the blueprint
  2. Create the Blade partial (e.g., block_<name>.blade.php)

View Composers

Use View Composers to enrich Statamic template data with additional queries or transformations:

use Illuminate\Contracts\View\View;
use Illuminate\View\Composer as ViewComposer;

class PageComposer implements ViewComposer
{
    public function compose(View $view): void
    {
        $data = $view->getData();

        // Transform or add data
        $view->with('extraData', $this->fetchRelated($data));
    }
}

Register in a ServiceProvider:

View::composer('pages.show', PageComposer::class);

Asset Handling

Statamic asset fields can return different types. Always handle defensively:

// Asset field might be a Value, an Asset object, an array, or a string path
$asset = $entry->get('logo');

// Safe resolution patterns:
if ($asset instanceof Value) {
    $asset = $asset->value();
}

// If it's an array of assets, take the first
if (is_array($asset) && isset($asset[0])) {
    $asset = $asset[0];
}

// Get the URL
$url = $asset?->url();

Navigation

Navigations are hierarchical structures for building site menus. They support entry references, hardcoded URLs, and text-only nodes — all managed via drag-and-drop in the CP.

Storage

  • Nav definitionscontent/navigation/<handle>.yaml (file driver)
  • Tree data → stored via Eloquent (navigation_trees driver)
  • Blueprintsresources/blueprints/navigation/<handle>.yaml (file driver)

Rendering Navs in Blade (Preferred)

Always prefer the <statamic:nav:handle> Blade tag. It handles entry resolution, URL generation, and variable scoping automatically — no manual Nav::find() or resolveNavEntry() needed for standard menus.

<ul>
    <statamic:nav:footer_main>
        <li>
            <a href="{{ $url }}" @if ($is_current || $is_parent) class="active" @endif>
                {{ $title }}
            </a>
        </li>
    </statamic:nav:footer_main>
</ul>

Available Variables Inside the Tag

VariableTypeDescription
$urlstringResolved URL (entry URL or hardcoded)
$titlestringItem title (nav override or entry title)
$is_currentboolWhether this is the exact current page
$is_parentboolWhether this is a parent of the current page
$is_entryboolWhether the item references an entry
$is_externalboolWhether the URL is external
$childrenarrayChild nav items
$depthintCurrent nesting level
Custom fieldsmixedAny fields from the nav blueprint

Nested Children with @recursive_children

For multi-level navs, use @recursive_children to repeat the tag contents for child items:

<ul>
    <statamic:nav:main_navigation>
        <li>
            <a href="{{ $url }}">{{ $title }}</a>
            @if (count($children))
                <ul>
                    @recursive_children
                </ul>
            @endif
        </li>
    </statamic:nav:main_navigation>
</ul>

Tag Parameters

Control output with parameters on the tag:

<statamic:nav:main_navigation
    max_depth="2"
    include_home="true"
    select="title|url"
>
    ...
</statamic:nav:main_navigation>
  • max_depth — Limit nesting depth (performance optimization)
  • include_home — Include the home page in the tree
  • show_unpublished — Include unpublished entries
  • select — Limit fields retrieved (pipe-separated, improves performance)

When to Use Nav::find() Instead

The <statamic:nav> tag covers most cases. Only fall back to the PHP facade when you need to pre-process nav data before rendering — e.g., serializing to JSON for Alpine.js, pre-rendering icons server-side, or building complex dropdown structures:

use Statamic\Facades\Nav;

$tree = Nav::find('main_navigation')?->in('default')?->tree() ?? [];

Each item in the tree is an array with keys: title, url, entry (UUID if linked), children, plus any custom blueprint fields. When using this approach, resolve items with the project's resolveNavEntry() helper:

$resolved = resolveNavEntry($item);
// Returns: ['url' => '/some-page', 'title' => 'Page Title']

The helper checks entry, reference, data.reference, and data.entry for an entry UUID, resolves it via Entry::find(), and falls back to the item's url field.

Note: Custom blueprint fields may appear at the top level or under data.*. Defensively check both:

$icon = $item['icon'] ?? ($item['data']['icon'] ?? null);

Nav Config Options

In the nav definition YAML (content/navigation/<handle>.yaml):

title: 'Main Navigation'
collections:          # Which collections appear in the CP entry selector
  - pages
  - integrations
max_depth: 2          # Maximum nesting depth

Best Practices

  • Use <statamic:nav> by default — It resolves entries, builds URLs, and provides $is_current/$is_parent automatically. Only use Nav::find() when you need PHP pre-processing.
  • Restrict collections — Configure collections in the nav YAML to limit which entries editors can link to.
  • Set max_depth — Match the frontend's rendering capability (e.g., 2 for a mega nav with one level of children).
  • Filter empty items — After manual resolution, filter out items where title is empty (entry may have been deleted).
  • Pre-process for Alpine/JS — When passing nav data to JavaScript, resolve entries and render server-side components (like icons) in PHP before encoding to JSON.

Routing

Statamic handles routing via collection URLs defined in each collection's YAML config. Custom middleware can control which requests Statamic handles.

Key config: config/statamic/routes.php

Artisan / Please Commands

Use php please for Statamic-specific operations:

php please make:collection      # Create a new collection
php please make:fieldset        # Create a reusable fieldset
php please make:nav             # Create a navigation
php please make:widget          # Create a CP dashboard widget
php please stache:refresh       # Rebuild the content cache
php please static:clear         # Clear static cache
php please support:details      # Debug Statamic setup info

PHPStan Considerations

Statamic's dynamic properties trigger PHPStan errors. Common patterns:

$entry->title           // @phpstan-ignore property.notFound
$entry->url()           // @phpstan-ignore method.notFound

Prefer $entry->get('field_name') in PHP code to avoid ignores. Dynamic property access is fine in Blade templates where PHPStan doesn't analyze.

Common Pitfalls

  1. Forgetting to unwrap Values — Statamic field data is wrapped in Value objects. Always unwrap before using in conditions or passing to components.
  2. Asset fields returning arrays — An assets field may return an array even for max_files: 1. Handle both single and array returns.
  3. Link fields with entry:: prefix — Link fieldtype stores entry references as entry::<uuid>. Resolve via Entry::find().
  4. Global sets need site context — Always chain ->inCurrentSite() when reading global set values for multi-site support.
  5. Tree/structure queries — Use Collection::findByHandle()->structure()->in('default') for hierarchical collections, not flat Entry::query().
  6. Bard content is augmented — Bard fields return augmented HTML when accessed as Values. Use ->value() for raw ProseMirror JSON.
  7. Component name conflicts — When using Flux UI alongside Statamic Blade components, watch for name collisions (e.g., header, footer). Register explicit Blade aliases if needed.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.45%
按下载量换算41

Claude

28.4%
按下载量换算33

Cursor

18.69%
按下载量换算21

Gemini CLI

8.79%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills