Commit fd06fc1e authored by Erick Hitter's avatar Erick Hitter

Load a different template/partial for image posts

Will allow featured image to be shown at a reasonable size, eventually.
parent 557aeb70
......@@ -48,13 +48,21 @@ app.get( '/api/:domain', function( req, res ) {
// Retrieve the latest post
client.posts().perPage( 1 ).orderby( 'date' ).order( 'desc' ).then( function( data ) {
res.render( 'partials/post', {
var partial = 'partials/post',
layout = 'single-post';
if ( 'undefined' !== typeof data[0].format && 'image' == data[0].format ) {
partial = 'partials/post-image';
layout = 'single-image';
}
res.render( partial, {
data: {
domain: domain,
url: url,
post: data[0]
},
layout: 'single-post'
layout: layout
} );
} ).catch(function( err ) {
console.error( err );
......
<h3><a href="{{data.post.link}}">{{{data.post.title.rendered}}}</a></h3>
{{{data.post.content.rendered}}}
<p><a href="{{data.post.link}}">See more at {{data.domain}} &rarr;</a></p>
{{> post-image}}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment