aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/rules.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2019-04-27 02:56:52 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2019-04-28 21:58:06 +0200
commit2793a94367e7b163ff3738619a2a764f1c6645b7 (patch)
tree66c0b2b247cafebfb1216ccdfd7f8538f970e96a /src/blogc-make/rules.c
parent709b0132be333b5327bcbd1c39422edd6d19000c (diff)
downloadblogc-2793a94367e7b163ff3738619a2a764f1c6645b7.tar.gz
blogc-2793a94367e7b163ff3738619a2a764f1c6645b7.tar.bz2
blogc-2793a94367e7b163ff3738619a2a764f1c6645b7.zip
make: support posts sorting
Diffstat (limited to 'src/blogc-make/rules.c')
-rw-r--r--src/blogc-make/rules.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index f1a0be9..96cf51d 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -31,10 +31,16 @@ posts_ordering(bm_ctx_t *ctx, bc_trie_t *variables, const char *variable)
return; // something is wrong, let's not add any variable
const char *value = bm_ctx_settings_lookup_str(ctx, variable);
- if (value != NULL && ((0 == strcmp(value, "ASC")) || (0 == strcmp(value, "asc"))))
- return; // user explicitly asked for ASC
+ bool asc = 0 == strcasecmp(value, "asc");
+ bool sort = bc_str_to_bool(bm_ctx_settings_lookup(ctx, "posts_sort"));
- bc_trie_insert(variables, "FILTER_REVERSE", bc_strdup("1"));
+ if (sort) {
+ bc_trie_insert(variables, "FILTER_SORT", bc_strdup("1"));
+ }
+
+ if ((sort && asc) || (!sort && !asc)) {
+ bc_trie_insert(variables, "FILTER_REVERSE", bc_strdup("1"));
+ }
}