<file_sep>const Article = require('../entities/articles/models/article.model');
const BlogSystem = require('../entities/blogSystem/core');
const blogSystem = new BlogSystem();

module.exports = function () {
    var developmentMode = process.env.NODE_ENV == 'production' ? false : true;
    class BlogController {
        index(req, res) {
            return blogSystem.renderTheme(res, 'index');
        }

        async article(req, res) {
            try {
                const slug = req.params.slug;
                const articlePath = await blogSystem.findArticle(slug);
                const article = new Article()
                    .load(await blogSystem.readArticle(articlePath, slug));
            
                const adasd = await blogSystem.getPosts();
                return blogSystem.renderTheme(res, 'articles', article);
            } catch(e){
                return res.status(e.statusCode).send(e.message);
            }
        }
    
    }

    return new BlogController();
}<file_sep># MintBook
Basic blog system that every post is a file in markdown

```sh
npm run start
```
<file_sep>class Article {
    constructor(title, description, createdAt, author, category, content) {
        this.title = title;
        this.description = description;
        this.createdAt = createdAt;
        this.author = author;
        this.category = category;
        this.content = content;
        this.slug;
    }

    /**
    * Returns an instance of Article with the parsed content loaded into it.
    * @param {object} parsedContent        A object with the markdown content parsed with the yaml-front-matter.
    */
    load(parsedContent) {
        this.title = parsedContent.title || '';
        this.description = parsedContent.description || '';
        this.createdAt = parsedContent.createdAt ? parsedContent.createdAt.toLocaleDateString() : '';
        this.author = parsedContent.author || '';
        this.category = parsedContent.category || '';
        this.tags = parsedContent.tags ? (parsedContent.tags.length > 0 ? parsedContent.tags : []) : []
        this.heroimage = parsedContent.heroimage || ''
        this.content = parsedContent.__content || ''; 
        this.slug = parsedContent.slug;
        
        return this;
    }
}

module.exports = Article;<file_sep>---
title: Test article 2
description: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor sed do eiusmod tempor incididunt
createdAt: 2020-12-06
author: <NAME>
category: Test Category
tags:
  - test
  - Ay el mio
---

## Title
# Subtitle
**bold text** *italicized text*

```sh
npx ac-create-web my-app --install
cd my-app
npm run dev
```

1. First item
2. Second item
3. Third item

### My Great Heading {#custom-id}

- [x] Write the press release
- [ ] Update the website
- [ ] Contact the media

[LINK](https://www.example.com)

`Lorem ipsum` dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex

| Syntax | Description |
| ----------- | ----------- |
| Header | Title |
| Paragraph | Text 

![tag](./public/img/photo.jpg)

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis 
<file_sep>const http = require('http');
const dotenv = require('dotenv');
const fs = require('fs');
const path = require('path');
const helmet = require('helmet');
const express = require('express');
const packageJson = require('./package.json');
const app = express();
const BlogSystem = require('./src/entities/blogSystem/core');
const blogSystem = new BlogSystem();

app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, './src/templates'))
app.use(express.json());
app.use(express.urlencoded({
    extended: true
}));
app.use(helmet()); // Sending various http headers
app.use('/public', express.static('./src/public'));
dotenv.config();

//Routing Web
require('./src/routes/routes')(app);

const port = process.env.PORT || 8080;
let server = http.createServer(app);

console.log();
console.log(`Package Name: ${packageJson.name} v${packageJson.version}`);
console.log(`App mode: ${app.get('env')}`);
console.log('');
// Run server
server.listen(port, () => console.log(`Server corriendo en el puerto ${port}...`));
