mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-08-28 03:25:42 -05:00
templated posts on home.
This commit is contained in:
@@ -37,11 +37,18 @@ header h3 {
|
||||
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
|
||||
position: relative;
|
||||
margin-left: 3em;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.smallCard h3 {
|
||||
font-size: 1.5em;
|
||||
margin: 0;
|
||||
}
|
||||
.smallCard p {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* specific */
|
||||
.smallCardWidth {
|
||||
|
||||
@@ -89,9 +89,9 @@ blogPostSchema.statics.getPost = function(date, slug, callback) {
|
||||
blogPostSchema.statics.latestPostsShortTemlate = function(amount, callback) {
|
||||
blogPostModel.find({}).sort({'meta.date': 'desc'}).exec(function(err, posts) {
|
||||
if (err) return callback(err);
|
||||
let out = [];
|
||||
for (let i = 0, l = posts.length; i < ( amount+1 < l ? amount+1 : l); i++)
|
||||
out += posts[i].postShortTemplate();
|
||||
const out = [];
|
||||
for (let i = 0, l = posts.length; i < ( amount+1 < l ? amount : l); i++)
|
||||
out.push(posts[i].postShortTemplate());
|
||||
callback(err, out);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,13 +9,19 @@ for routes on the root path
|
||||
// imports
|
||||
const router = require('express').Router();
|
||||
const utilHelper = require('../helpers/util');
|
||||
const blogPostModel = require('../models/blog-post').blogPostModel;
|
||||
|
||||
// display home page
|
||||
router.get('/', (req, res) => {
|
||||
res.render('home', {
|
||||
user: utilHelper.templateReadyUser(req),
|
||||
locales: utilHelper.getLocales(),
|
||||
page: 'home'
|
||||
// needs callback because mongoose is inconsistent
|
||||
blogPostModel.latestPostsShortTemlate(2, (err, result) => {
|
||||
console.log(typeof result);
|
||||
res.render('home', {
|
||||
user: utilHelper.templateReadyUser(req),
|
||||
locales: utilHelper.getLocales(),
|
||||
posts: result,
|
||||
page: 'home'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -85,20 +85,15 @@
|
||||
<button class="btn">ERROR</button>
|
||||
</div>
|
||||
<div class="cont-flex">
|
||||
{{#each posts }}
|
||||
<div class="smallCardWidth">
|
||||
<div class="smallCard">
|
||||
<h3 class="txt-smallHeading">Super cool</h3>
|
||||
<p>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea</p>
|
||||
<button class="btn-alt">ERROR</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="smallCardWidth">
|
||||
<div class="smallCard">
|
||||
<h3 class="txt-smallHeading">Super cool</h3>
|
||||
<p>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea</p>
|
||||
<button class="btn-alt">ERROR</button>
|
||||
<h3 class="txt-smallHeading">{{ this.title }}</h3>
|
||||
<p>{{ this.content }}</p>
|
||||
<a href="/news/{{ this.url }}" class="btn-alt">ERROR</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/each }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user