diff --git a/.gitmodules b/.gitmodules index 3cccde8..b594082 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "themes/navy/layout/partial/shared-partials"] path = themes/navy/layout/partial/shared-partials url = https://github.com/status-im/status.im-partials -[submodule "themes/navy/source/js/shared-js"] - path = themes/navy/source/js/shared-js - url = git@github.com:status-im/status-im-js.git diff --git a/package.json b/package.json index 9c03712..416a827 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "hexo": { - "version": "3.8.0" + "version": "3.7.1" }, "scripts": { "clean": "rm -rf public/*", @@ -26,7 +26,8 @@ "hexo-renderer-stylus": "^0.3.1", "hexo-server": "^0.2.0", "lodash": "^4.5.1", - "lunr": "^2.1.2" + "lunr": "^2.1.2", + "moment": "^2.24.0" }, "devDependencies": { "babel-core": "^6.26.0", diff --git a/themes/navy/layout/partial/shared-partials b/themes/navy/layout/partial/shared-partials index 1aac683..ef5db8a 160000 --- a/themes/navy/layout/partial/shared-partials +++ b/themes/navy/layout/partial/shared-partials @@ -1 +1 @@ -Subproject commit 1aac6836d674dbd9006775345a947cf7a8783752 +Subproject commit ef5db8a4de18fe58b1e5e44c7b7f965b13850a91 diff --git a/themes/navy/source/js/main.js b/themes/navy/source/js/main.js index 6639667..0aa45f8 100644 --- a/themes/navy/source/js/main.js +++ b/themes/navy/source/js/main.js @@ -1,3 +1,15 @@ +/* global $ */ +const moment = require('moment'); + +function formatDate(date) { + const day = moment().date(date.get('date')).format('DD'); + const month = moment().month(date.get('month')).format('MMM'); + const hour = moment().hour(date.get('hour')).format('HH'); + const minute = moment().minute(date.get('minute')).format('mm'); + + return `${day} ${month} at ${hour}:${minute}`; +} + $(document).ready(function () { // Fixes Parallax effect and div to popup overlapping with the main menu options @@ -28,41 +40,29 @@ $(document).ready(function () { return str.split(/\s+/).slice(0,25).join(" "); } - var months = {'01':'Jan', '02':'Feb', '03':'Mar', '04':'Apr', '05':'May', '06':'Jun', '07':'Jul', '08':'Aug', '09':'Sep', '10':'Oct', '11':'Nov', '12':'Dec'}; - url = 'https://our.status.im/ghost/api/v0.1/posts/?order=published_at%20desc&limit=2&formats=plaintext&client_id=ghost-frontend&client_secret=2b055fcd57ba'; + let url_news = 'https://our.status.im/ghost/api/v0.1/posts/?order=published_at%20desc&limit=2&formats=plaintext&client_id=ghost-frontend&client_secret=2b055fcd57ba'; $.ajax({ - type: "get", - url: url, - success: function (response) { + type: 'get', + url: url_news, + success: function(response) { response.posts = response.posts.reverse(); - $.each(response.posts, function (index, val) { - var excerpt = ''; - if(val.custom_excerpt != null) { - excerpt = val.custom_excerpt; - }else{ - excerpt = getWords(val.plaintext); - } - var newDate = new Date(val.published_at); - var minutes = newDate.getMinutes(); - minutes = minutes + ""; - if(minutes.length == 1){ - minutes = '0' + minutes; - } - $('.latest-posts').prepend(' \ -
\ - \ -

'+ val.title +'

\ -
\ - '); + + $.each(response.posts, function(index, val) { + const date = moment(val.published_at); + + $('.latest-news').prepend( + `
+ +

${val.title}

+
` + ); }); } }); }); -/* Popups */ - var addClassToElement = require('./shared-js/js/utils').addClassToElement; var removeClassFromElement = require('./shared-js/js/utils').removeClassFromElement;