miaEngiadina / elm-ghost / Ghost.Params

This module is used for any kind of configuration that is associated with requests, such as limiting the number of results, filtering, order, etc..

See https://docs.ghost.org/api/content/ for further information on all settings.

empty : Params

Initialise an empty Parameter record. This is a shortcut for:

Params Nothing Nothing Nothing Nothing Nothing Nothing

fields : String -> Params -> Params

fields takes in a string of comma-separated fields, that will be returned by ghost. Since it allows to filter any kind of field, such as "id", "title", "url", "authors", etc. all ghost types are defined as Maybe types.

Params.empty
|> Params.fields "url,id" -- everything else is dissmissed
|> ...

See: https://docs.ghost.org/api/content/#fields

filter : String -> Params -> Params

Takes in a string of comma-separated filters, to fine tune the response.

Params.empty
|> Params.filter "featured:true,tag:getting-started"
|> ...

See: https://docs.ghost.org/api/content/#filter

include : String -> Params -> Params

include takes a string of comma-separated parameters, such as:

* Posts & Pages: authors, tags
* Authors: count.posts
* Tags: count.posts

Params.empty
|> Params.include "authors,count.posts"
|> ...

which allow to fine tune the returned result.

See: https://docs.ghost.org/api/content/#include

limit : Basics.Int -> Params -> Params

Limit the number of records returned, the default value is 15, the nagative value -1 will return all results.

Params.empty
|> Params.limit 2
|> ...

See: https://docs.ghost.org/api/content/#limit

order : String -> Params -> Params

Define the sort order:

Params.empty
|> Params.order "published_at DESC"
|> ...

See: https://docs.ghost.org/api/content/#order

page : Basics.Int -> Params -> Params

By default, the first 15 records are returned.

Params.empty
|> Params.limit 2
|> Params.page 2
|> ...

See: https://docs.ghost.org/api/content/#order

toString : Params -> String

Used internally only, to generate a string from all parameters.


type alias Params =
{ include : Maybe String
, fields : Maybe String
, filter : Maybe String
, limit : Maybe String
, order : Maybe String
, page : Maybe String 
}

A basic record for all ghost related fine tune settings.