Add ability to hide posts

This commit is contained in:
Chris Josten 2020-06-27 16:48:26 +02:00
parent 7ee1664698
commit 561bcdc366
2 changed files with 7 additions and 0 deletions

View file

@ -7,6 +7,8 @@ import std.stdio;
import dyaml;
import vibe.vibe;
import utils;
/**
* Exception thrown when a page has syntax errors e.g.
@ -34,6 +36,8 @@ class Page {
protected string m_title;
protected string m_content;
protected string m_contentSource;
protected bool m_hidden;
/**
* Option for the markdown parser: the amount of levels the header found in the markdown should
@ -71,6 +75,7 @@ class Page {
*/
@safe
protected void loadHeader(Node headerNode){
this.m_hidden = headerNode.getOr!bool("hidden", false);
if (headerNode.containsKey("title")) {
this.m_title = headerNode["title"].as!string;
} else {
@ -124,4 +129,5 @@ class Page {
@property string slug() { return m_slug; }
@property string content() { return m_content; }
@property string contentSource() { return m_contentSource; }
@property bool isHidden() { return m_hidden; }
}

View file

@ -37,6 +37,7 @@ void initPages(T, string sortPred)(ref T[string] array, ref T*[] sortedRange, co
void sortThings() {
sortedRange = sort!(sortPred)(array.values)
.filter!(x => !x.isHidden)
.map!"&a".array;
logf("sorted: %s", sortedRange);
}