Blog Settings and Posts
Last edit: Jul 14, 2023
Blog settings and posts are fetched with GraphQL queries. The flexibility of GraphQL gives you the possibility to implement any search functionality you need. Every Property added to the fields will be available to add to the installed queries.
Example: Get blog posts GraphQL query
You can fetch blog settings with:
{%- graphql g = 'modules/dashboard_blog/get_blog_instance' -%}
You can fetch all post details with:
{%- graphql g = 'modules/dashboard_blog/get_blog_posts' -%}
modules/dashboard_blog/get_blog_posts.graphql
query get_blog_posts($per_page: Int = 20, $page: Int, $title: String, $id: ID, $slug: String, $published_at_lte: String, $published_at_lt: String, $published_at_gt: String, $published_at_gte: String, $tags: [String!], $blog_instance_id: String) {
blog_posts: records(
per_page: $per_page,
page: $page,
filter: {
id: { value: $id },
table: { value: "blog_post" },
properties: [
{ name: "tags", value_in: $tags },
{ name: "blog_instance_id", value: $blog_instance_id },
{ name: "title", value: $title },
{ name: "slug", value: $slug },
{ name: "published_at", range: { lte: $published_at_lte } },
{ name: "published_at", range: { lt: $published_at_lt } },
{ name: "published_at", range: { gt: $published_at_gt } },
{ name: "published_at", range: { gte: $published_at_gte } }
]
}
sort: [
{
properties: [
{
name: "published_at",
order: DESC
}
]
}
]
) {
current_page
per_page
total_entries
total_pages
has_next_page
has_previous_page
results {
id
user {
id
}
created_at
author_name: property(name: "author_name")
blog_instance_id: property(name: "blog_instance_id")
author_biography: property(name: "author_biography")
content: property(name: "content")
excerpt: property(name: "excerpt")
published_at: property(name: "published_at")
title: property(name: "title")
slug: property(name: "slug")
tags: property_array(name: "tags")
hero_image: image(name: "hero_image") {
normal: url(version: "normal")
thumb: url(version: "thumb")
transformed: url(version: "transformed")
}
author_avatar: image(name: "author_avatar") {
thumb: url(version: "thumb")
}
}
}
}