Skip to main content

contexts/posts-list

The posts-list context.

Attributes

Name Type Description
filters dict A dictionary containing the details of any filters being used to filter the list of posts.
filters.search dict A dictionary containing the details of a search.
filters.search.query str The search query.
filters.tags list A list of any tags being used as a filter.
filters.tags[].feed_url str The tag’s RSS feed URL.
filters.tags[].id str The unique id of the tag.
filters.tags[].title str The title of the tag.
filters.tags[].url str The url of the tag.
pagination dict A dictionary containing data about paginating the list of posts.
pagination.first str The URL to the first page of the pagination.
pagination.has_next bool Whether there is a next page of the pagination.
pagination.has_pages bool Whether the list of posts is paginated.
pagination.has_prev bool Whether there is a previous page of the pagination.
pagination.items_count int The total number of posts across all pages of the pagination.
pagination.items_per_page int The number of posts per pages of the pagination.
pagination.last str The URL to the last page of the pagination.
pagination.next str The URL to the next page of the pagination from the current page.
pagination.pages_count int The total number of pages of the pagination.
pagination.page_number int The current page number of the pagination.
pagination.prev str The URL to the previous page of the pagination from the current page.
posts list A list of the posts to be displayed.
posts[].authors list A list of the post’s authors.
posts[].authors[].avatar str The author’s avatar URL.
posts[].authors[].bio str The author’s bio.
posts[].authors[].id str The author’s unique id.
posts[].authors[].name str The author’s name.
posts[].content str The post’s content.
posts[].created_at datetime The post’s date and time it was created.
posts[].excerpt str The post’s excerpt.
posts[].id str The post’s unique id.
posts[].images list A list of the post’s images. Note that these are all the images uploaded to the post in the Typed Dashboard and not just the subset of which are included in the post’s content.
posts[].images[].id str The image’s unique id.
posts[].images[].url str The image’s URL.
posts[].linked_url str The post’s linked URL.
posts[].published_at datetime The post’s date and time it was published.
posts[].tags list A list of the post’s tags.
posts[].tags[].id str The tag’s unique id.
posts[].tags[].title str The tag’s title.
posts[].tags[].url str The tag’s URL.
posts[].title str The post’s title.
posts[].updated_at datetime The post’s date and time it was last updated.
posts[].url str The post’s URL.

Description

The post-list context is used when rendering the post-list template.

Examples

{
  'filters': {
    'search': {},
    'tags': []
  },
  'pagination': {
    'first': '?page=1',
    'has_next': True,
    'has_pages': True,
    'has_prev': True,
    'items_count': 27,
    'items_per_page': 5,
    'last': '?page=6'
    'next': '?page=4',
    'pages_count': 6,
    'page_number': 3,
    'prev': '?page=2',
  },
  'posts': [
    {
      'authors': [
        {
          'avatar': 'https://avatars.typed.com/d07eed0c-9185-4fb8-8cc1-e5cb19a44e16/avatar.jpg',
          'bio': '<p>I make <strong>amazing</strong> coffee.</p>',
          'id': '46695d0b-6d4a-447e-a740-a1dc06e80baf',
          'name': 'The Coffee Master'
        }
      ],
      'content': '<p>Some people are lactose-intolerant and can’t drink milk. If that’s you, then here’s the 5 best alternatives to classic moo-moo milk.</p><ol><li><a href="http://www.bonsoy.com">Bonsoy</a></li><li>Home-made Almond Milk</li><li><a href="http://www.oatly.com/products/international/foamable/">Oatly Foamable</a></li><li>Barista style Alpro (it’s pretty shoddy, but it’ll do in a pinch)</li><li>Go for an espresso instead.</li></ol><p>That’s it, if you have any suggestions please get in touch.</p>',
      'created_at': datetime(2015, 10, 26, 10, 39, 51, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>),
      'excerpt': '<p>Some people are lactose-intolerant and can’t drink milk. If that’s you, then here’s the 5 best alternatives to classic moo-moo milk.</p>',
      'id': 'dd852700-5c89-479f-b695-874137225872',
      'images': [
        {
          'id': 'ebcc4cb4-728d-4d85-8acb-c07877c9d159',
          'url': 'https://images.typed.com/ebcc4cb4-728d-4d85-8acb-c07877c9d159/image.jpg'
        }
      ],
      'linked_url': 'http://www.bonsoy.com',
      'published_at': datetime(2015, 10, 26, 12, 00, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>),
      'tags': [
        {
          'id': '569b38ef-61c9-43f5-a82c-6cd6edaea0aa',
          'title': 'Review',
          'url': '/tags/review'
        }
      ],
      'title': 'Top 5 Alternatives to Milk in Coffee',
      'updated_at': datetime(2015, 10, 26, 11, 18, 24, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>),
      'url': '/blog/top-5-alternatives-to-milk-in-coffee'
    }
  ]
}

Search Performed

An example of how filters is populated when a search is performed.

{
  'filters': {
    'search': {
      'query': 'coffee grinder'
    },
    'tags': []
  },
  ...
}

Viewing a Tag

An example of how filters is populated when a tag is being viewed.

{
  'filters': {
    'search': {},
    'tags': [
      {
        'feed_url': '/tags/review/feed',
        'id': '569b38ef-61c9-43f5-a82c-6cd6edaea0aa',
        'title': 'Review',
        'url': '/tags/review'
      }
    ]
  },
  ...
}