-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render overview on the index route #35
Conversation
Amazing! Looks great. Could you please make the function for rendering the handlebars template asynchronous? In addition, I don't see a need for including |
lib/view.js
Outdated
let viewContent = false | ||
const viewPath = path.normalize(path.join(__dirname, '/../views/index.hbs')) | ||
|
||
try { | ||
viewContent = fs.readFileSync(viewPath, 'utf8') | ||
viewContent = await readFileAsync(viewPath, { encoding: 'utf8' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'utf8'
works even with the native module 😊 no need for an object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your changes! I just found a last few bits to improve, but then we're good. Thank you! 😊
lib/view.js
Outdated
try { | ||
viewContent = await readFileAsync(viewPath, 'utf8') | ||
} catch (err) { | ||
throw err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't handle the error, you can just write:
const viewContent = await readFileAsync(viewPath, 'utf8')
Without the try/catch block 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also means you can remove the let viewContent = false
at the top... 🚀
lib/routes.js
Outdated
const details = { | ||
account: config.account, | ||
repository: config.repository, | ||
date: timeago().format(cache.latest.pub_date), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use date-fns
here please 😊 It's faster, slimmer and currently the best option out there.
views/index.hbs
Outdated
background: linear-gradient(#ff00a5, #f65538) | ||
} | ||
|
||
#releaseNotes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No camelcase in CSS properties please, always dashes (also adjust the HTML) 😊
Thank you for this wonderful PR! 😊 |
No worries. Learnt about date-fns. Looks really good! 👍 |
Solves #13
Renders an overview page using handlebars.
Had to add the size of the files in the cache to be able to display them.
Added a few packages: