← GDG /

#281 gdtest_sec_blog_user_index

#281 gdtest_sec_blog_user_index OK CONFIG
Blog section with user-provided index.qmd.
Blog section with a user-provided blog/index.qmd (table listing). Tests that Great Docs injects toc: false and body-classes: gd-blog-index into the user's index, hiding the TOC sidebar and copy-page widget.
View Site → Build Log ๐Ÿงช Test Coverage

Build Mode

● Has great-docs.yml

This package ships a pre-supplied config. The great-docs init step is skipped and great-docs build uses the spec-defined configuration directly. Tests specific config options and their rendered output.

Dimensions

N4
N4Blog sectionsections

Source Files

๐Ÿ“ blog/
๐Ÿ“ first-post/
๐Ÿ“„ index.qmd
---
title: First Post
author: Alice
date: 2024-03-01
categories: [announcements]
description: Our very first blog post.
image: post-banner.svg
---

This is the first post on our blog.

![](post-banner.svg)

## Getting Started

We're excited to share our work with you.
๐Ÿ“„ post-banner.svg
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="60"><rect width="300" height="60" fill="#5cb85c" rx="6"/><text x="150" y="38" text-anchor="middle" fill="white" font-size="18" font-family="sans-serif">First Post</text></svg>
๐Ÿ“ second-post/
๐Ÿ“„ index.qmd
---
title: Second Post
author: Bob
date: 2024-04-15
categories: [updates]
description: A follow-up with new features.
---

Here's what we've been working on.

## New Features

- Improved performance
- Better error messages
๐Ÿ“„ blog-header.svg
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="80"><rect width="400" height="80" fill="#4a90d9" rx="8"/><text x="200" y="48" text-anchor="middle" fill="white" font-size="24" font-family="sans-serif">Blog</text></svg>
๐Ÿ“„ index.qmd
---
title: Blog
listing:
  type: table
  sort: "date desc"
  feed: true
  contents:
    - "**.qmd"
---

![](./blog-header.svg)

Welcome to our blog.
๐Ÿ“ gdtest_sec_blog_user_index/
๐Ÿ“„ __init__.py
"""Test package for blog section with user index."""

from .core import publish, draft

__all__ = ["publish", "draft"]
๐Ÿ“„ core.py
"""Core blog helpers."""


def publish(title: str, body: str) -> dict:
    """Publish a blog post.

    Parameters
    ----------
    title : str
        The post title.
    body : str
        The post body.

    Returns
    -------
    dict
        The published post record.

    Examples
    --------
    >>> publish("Hello", "World")
    {'title': 'Hello', 'body': 'World', 'status': 'published'}
    """
    return {"title": title, "body": body, "status": "published"}


def draft(title: str) -> dict:
    """Create a draft post.

    Parameters
    ----------
    title : str
        The draft title.

    Returns
    -------
    dict
        The draft post record.

    Examples
    --------
    >>> draft("WIP")
    {'title': 'WIP', 'status': 'draft'}
    """
    return {"title": title, "status": "draft"}
๐Ÿ“„ great-docs.yml
sections:
  - title: Blog
    dir: blog
    type: blog