Skip to content

Commit

Permalink
Merge pull request #211 from fac-17/feature/description-preview
Browse files Browse the repository at this point in the history
if description is over 200 char reduce it and end with "..."
  • Loading branch information
Albadylic authored Sep 19, 2019
2 parents f763d3e + d12eb87 commit f0e4034
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ app.engine(
);

app.set("port", process.env.PORT || 3000);
// app.use(express.static("public"));
app.use(controllers);

module.exports = app;
4 changes: 3 additions & 1 deletion src/views/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const returnAverageRating = require("./returnAverageRating");
const returnNearestInt = require("./returnNearestInt");
const limitDescriptionLength = require("./limitDescriptionLength");

module.exports = {
returnAverageRating,
returnNearestInt
returnNearestInt,
limitDescriptionLength
};
6 changes: 6 additions & 0 deletions src/views/helpers/limitDescriptionLength.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = description => {
if (description.length > 200) {
return description.slice(0, 199) + "...";
}
return description;
};
2 changes: 1 addition & 1 deletion src/views/results.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<article class="result-card">
<h3 class="result-title"><a href="/product/{{this.id}}" class="result-link">{{this.product_name}}</a></h3>
<img class="result-image" src="{{this.product_image}}" />
<p class="result-description">{{this.product_description}}</p>
<p class="result-description">{{limitDescriptionLength this.product_description}}</p>
<p class="result-rating">{{returnNearestInt this.product_avg_rating}}</p>
</article>
{{/each}}
Expand Down

0 comments on commit f0e4034

Please sign in to comment.