diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.js | 10 | ||||
-rw-r--r-- | src/app.js | 2 | ||||
-rw-r--r-- | src/responders.js | 18 | ||||
-rw-r--r-- | src/templates/list.html (renamed from src/templates/taxon.html) | 0 |
4 files changed, 20 insertions, 10 deletions
diff --git a/src/actions.js b/src/actions.js index 7c7482f..e6d7f98 100644 --- a/src/actions.js +++ b/src/actions.js @@ -12,6 +12,13 @@ function home(config, posts) { }; } +function posts(config, posts) { + const postsArray = Array.from(posts.values()); + return async function(ctx, next) { + responders.list(ctx, config, null, "Posts", postsArray); + }; +} + function highlightTheme(config) { const theme = config.posts.code.theme; const themeFile = path.resolve( @@ -47,7 +54,7 @@ function taxonGenerator(config, term, items) { const taxonItems = items.get(value); - responders.taxon(ctx, config, term, value, taxonItems); + responders.list(ctx, config, term, value, taxonItems); }; } @@ -62,6 +69,7 @@ async function serveFiles(ctx) { module.exports = { home, + posts, highlightTheme, post, taxonGenerator, diff --git a/src/app.js b/src/app.js index 6be44bd..b6d8beb 100644 --- a/src/app.js +++ b/src/app.js @@ -21,6 +21,8 @@ module.exports = async function() { router.get("home", "/", actions.home(config, Posts.posts)); + router.get("posts", "/post", actions.posts(config, Posts.posts)); + router.get( "highlight-theme", "/css/code.css", diff --git a/src/responders.js b/src/responders.js index 48d1949..75850f8 100644 --- a/src/responders.js +++ b/src/responders.js @@ -37,7 +37,7 @@ const templates = { layout: templateReader("layout"), home: templateReader("home", baseIndentLevel), post: templateReader("post", baseIndentLevel), - taxon: templateReader("taxon", baseIndentLevel) + list: templateReader("list", baseIndentLevel) }; function title(siteTitle, pageTitle) { @@ -97,25 +97,25 @@ module.exports = { ); }, - post(ctx, config, post) { + list(ctx, config, listType, listName, posts) { ctx.type = "html"; ctx.body = layout( config, - post.data.get("title"), - hyperfast(templates.post, renderPost(ctx)(post)) + Case.title(listName), + hyperfast(templates.list, { + ".h-entry": posts.map(renderPost(ctx)) + }) ); }, - taxon(ctx, config, term, value, taxonItems) { + post(ctx, config, post) { ctx.type = "html"; ctx.body = layout( config, - Case.title(value), - hyperfast(templates.taxon, { - ".h-entry": taxonItems.map(renderPost(ctx)) - }) + post.data.get("title"), + hyperfast(templates.post, renderPost(ctx)(post)) ); } }; diff --git a/src/templates/taxon.html b/src/templates/list.html index 44244e5..44244e5 100644 --- a/src/templates/taxon.html +++ b/src/templates/list.html |