blog / blogs
Blog picker fields. Use blog for a single blog or blogs for a list. Returns the blog object(s) without articles.
Need articles too?
If you need the blog with its articles, use blog_articles instead.
Properties
| Property | Type | Required | Description |
|---|---|---|---|
type | "blog" or "blogs" | Yes | Single or multiple blogs |
label | string | Yes | Label shown in the builder |
default | string or array | No | "" for blog, [] for blogs |
Usage
- schema.json
- Template
- Output
{
"primary": {
"type": "blog",
"label": "Blog",
"default": ""
},
"list": {
"type": "blogs",
"label": "Blogs",
"default": []
}
}
{# Single blog #}
{% if widget.settings.primary %}
<h2>{{ widget.settings.primary.title }}</h2>
<p>{{ widget.settings.primary.articlesCount }} articles</p>
{% endif %}
{# Blogs list #}
{% for blog in widget.settings.list %}
<a href="/blog/{{ blog.handle }}">{{ blog.title }}</a>
{% endfor %}
Each blog object includes:
{
"_id": "691f38a8a60232b8a1049823",
"title": "Store News",
"handle": "store-news",
"articlesCount": 8
}
Interactive Preview
Interactive Preview
Store News
8 articles
Live Output
{
"primary": {
"_id": "691f38a8a60232b8a1049823",
"title": "Store News",
"handle": "store-news",
"articlesCount": 8
}
}