Update guides sort order

pull/1331/head
Kamran Ahmed 5 years ago
parent 8fe4bc5472
commit 32c2bef9d8
  1. 5
      components/featured-content/guides.js
  2. 15
      data/guides.json
  3. 7
      lib/guide.js

@ -1,7 +1,7 @@
import Link from 'next/link';
import { FeaturedContentWrap } from './style';
import guides from 'data/guides';
import FeaturedGuide from 'components/featured-guide';
import { getFeaturedGuides } from 'lib/guide';
const FeaturedGuides = () => (
<FeaturedContentWrap className="featured-content-wrap">
@ -13,8 +13,7 @@ const FeaturedGuides = () => (
</span>
</p>
<div className="swim-lane row">
{ guides
.filter(({ featured }) => featured)
{ getFeaturedGuides()
.map(guide => (
<FeaturedGuide guide={ guide } key={ guide.url } />
)) }

@ -6,8 +6,8 @@
"fileName": "design-patterns-for-humans",
"featured": true,
"author": "kamranahmedse",
"createdAt": "2018-11-29T17:00:00.860Z",
"updatedAt": "2018-11-29T17:00:00.860Z"
"updatedAt": "2019-10-09T12:00:00.860Z",
"createdAt": "2019-01-23T17:00:00.860Z"
},
{
"title": "Journey to HTTP/2",
@ -17,7 +17,8 @@
"featured": true,
"author": "kamranahmedse",
"createdAt": "2018-12-04T12:00:00.860Z",
"updatedAt": "2018-12-04T12:00:00.860Z"
"updatedAt": "2018-12-04T12:00:00.860Z",
"draft": true
},
{
"title": "DNS in One Picture",
@ -26,8 +27,8 @@
"fileName": "dns-in-one-picture",
"featured": true,
"author": "kamranahmedse",
"updatedAt": "2019-10-09T12:00:00.860Z",
"createdAt": "2019-01-23T17:00:00.860Z"
"updatedAt": "2018-12-04T12:00:00.860Z",
"createdAt": "2018-12-04T17:00:00.860Z"
},
{
"title": "HTTP Caching",
@ -36,7 +37,7 @@
"fileName": "http-caching",
"featured": true,
"author": "kamranahmedse",
"updatedAt": "2019-10-09T12:00:00.860Z",
"createdAt": "2019-01-23T17:00:00.860Z"
"createdAt": "2018-11-29T17:00:00.860Z",
"updatedAt": "2018-11-29T17:00:00.860Z"
}
]

@ -3,7 +3,12 @@ import authors from "data/authors";
import siteConfig from "data/site";
export const getAllGuides = () => {
return guides;
return guides.filter(guide => !guide.draft)
.sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt));
};
export const getFeaturedGuides = () => {
return getAllGuides().filter(guide => guide.featured);
};
export const getRequestedGuide = req => {

Loading…
Cancel
Save