saber-query-posts

0.0.3 • Public • Published

saber-query-posts

Query posts and inject them to page props. Useful when you're writing a blog.

Install

yarn add saber-query-posts

Usage

In your saber-config.yml:

plugins:
  - resolve: saber-query-posts
    options:
      # Inject all posts to specific pages as `posts` prop
      injectPostsTo: / # Default value

Tags Page

It will automatically generate tags map /tag/:tag when you're using tags in page attributes, e.g. in a Markdown post:

---
title: hello
date: 2019-01-01
tags:
  - life
  - random
---

hello

Then it will generate /tag/life and /tag/random pages.

Options

injectPostsTo

  • Type: string string[] (permalinks)
  • Default: /

Inject all posts to specific pages.

tagsMap

  • Type: { [name: string]: string }

Map tag name to permalink's :tag part, by default :tag will be the tag name.

For example:

{
  tagsMap: {
    'c++': 'cpp'
  }
}

categoriesMap

[TODO]

Categories are NOT IMPLEMENTED YET. I'm also not sure if we really need this since we already have tags.

License

MIT.

Readme

Keywords

Package Sidebar

Install

npm i saber-query-posts

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

8.59 kB

Total Files

5

Last publish

Collaborators

  • egoist