const router = require('express').Router()
const fs = require('fs')
const _ = require('lodash')
const mw = require('../server/middlewares')
const util = require('../server/util')

router.param('slug', mw.getPostBySlug)

router.get('/', mw.getBlogPosts, (req, res) => {
  res.render('blog', { title: 'Blog — yarmo.eu' })
})
router.get('/blog', mw.getBlogPosts, (req, res) => {
  res.render('blog', { title: 'Blog — yarmo.eu' })
})
router.get('/blog/:s', (req, res) => {
  res.redirect(`/post/${req.params.s}`)
})
router.get('/notes', mw.getNotes, (req, res) => {
  res.render('notes', { title: 'Notes — yarmo.eu' })
})
router.get('/notes/:s', (req, res) => {
  res.redirect(`/post/${req.params.s}`)
})
router.get('/post/:slug', (req, res) => {
  res.render('post', { title: `${res.locals.post.title} — yarmo.eu` })
})
router.get('/blogroll', (req, res) => {
  res.render('blogroll', { title: 'Blogroll — yarmo.eu' })
})
router.get('/feeds', (req, res) => {
  res.render('feeds', { title: 'Feeds — yarmo.eu' })
})
router.get('/about', (req, res) => {
  res.render('about', { title: 'About me — yarmo.eu' })
})
router.get('/work', (req, res) => {
  res.render('work', { title: 'Work — yarmo.eu' })
})
router.get('/contact', (req, res) => {
  res.render('contact', { title: 'Contact — yarmo.eu' })
})
router.get('/now', (req, res) => {
  res.render('now', { title: 'Now — yarmo.eu' })
})
router.get('/uses', (req, res) => {
  res.render('uses', { title: 'Uses — yarmo.eu' })
})
router.get('/music', (req, res) => {
  res.render('music', { title: 'Music — yarmo.eu' })
})
router.get('/vinyl', mw.getVinyl, (req, res) => {
  res.render('vinyl', { title: 'Vinyl — yarmo.eu' })
})
router.get('/pgp', (req, res) => {
  res.render('pgp', { title: 'PGP — yarmo.eu' })
})

module.exports = router
