mirror of https://github.com/freeCodeCamp/devdocs
parent
f44c8179cd
commit
59bc8e27a6
@ -1,36 +1,46 @@
|
|||||||
#= depend_on news.json
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
app.templates.newsPage = ->
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
""" <h1 class="_lined-heading">Changelog</h1>
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
//= depend_on news.json
|
||||||
|
|
||||||
|
app.templates.newsPage = () => ` <h1 class="_lined-heading">Changelog</h1>
|
||||||
<p class="_note">
|
<p class="_note">
|
||||||
For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.<br>
|
For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.<br>
|
||||||
For development updates, follow the project on <a href="https://github.com/freeCodeCamp/devdocs">GitHub</a>.
|
For development updates, follow the project on <a href="https://github.com/freeCodeCamp/devdocs">GitHub</a>.
|
||||||
<div class="_news">#{app.templates.newsList app.news}</div> """
|
<div class="_news">${app.templates.newsList(app.news)}</div> `;
|
||||||
|
|
||||||
app.templates.newsList = (news, options = {}) ->
|
app.templates.newsList = function(news, options = {}) {
|
||||||
year = new Date().getUTCFullYear()
|
let year = new Date().getUTCFullYear();
|
||||||
result = ''
|
let result = '';
|
||||||
|
|
||||||
for value in news
|
for (let value of news) {
|
||||||
date = new Date(value[0])
|
const date = new Date(value[0]);
|
||||||
if options.years isnt false and year isnt date.getUTCFullYear()
|
if ((options.years !== false) && (year !== date.getUTCFullYear())) {
|
||||||
year = date.getUTCFullYear()
|
year = date.getUTCFullYear();
|
||||||
result += """<h2 class="_block-heading">#{year}</h2>"""
|
result += `<h2 class="_block-heading">${year}</h2>`;
|
||||||
result += newsItem(date, value[1..])
|
}
|
||||||
|
result += newsItem(date, value.slice(1));
|
||||||
result
|
}
|
||||||
|
|
||||||
MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
return result;
|
||||||
|
};
|
||||||
newsItem = (date, news) ->
|
|
||||||
date = """<span class="_news-date">#{MONTHS[date.getUTCMonth()]} #{date.getUTCDate()}</span>"""
|
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||||
result = ''
|
|
||||||
|
var newsItem = function(date, news) {
|
||||||
for text, i in news
|
date = `<span class="_news-date">${MONTHS[date.getUTCMonth()]} ${date.getUTCDate()}</span>`;
|
||||||
text = text.split "\n"
|
let result = '';
|
||||||
title = """<span class="_news-title">#{text.shift()}</span>"""
|
|
||||||
result += """<div class="_news-row">#{if i is 0 then date else ''} #{title} #{text.join '<br>'}</div>"""
|
for (let i = 0; i < news.length; i++) {
|
||||||
|
let text = news[i];
|
||||||
result
|
text = text.split("\n");
|
||||||
|
const title = `<span class="_news-title">${text.shift()}</span>`;
|
||||||
|
result += `<div class="_news-row">${i === 0 ? date : ''} ${title} ${text.join('<br>')}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
app.news = <%= App.news.to_json %>
|
app.news = <%= App.news.to_json %>
|
||||||
|
Loading…
Reference in new issue