Update guides sort order
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { FeaturedContentWrap } from './style';
|
import { FeaturedContentWrap } from './style';
|
||||||
import guides from 'data/guides';
|
|
||||||
import FeaturedGuide from 'components/featured-guide';
|
import FeaturedGuide from 'components/featured-guide';
|
||||||
|
import { getFeaturedGuides } from 'lib/guide';
|
||||||
|
|
||||||
const FeaturedGuides = () => (
|
const FeaturedGuides = () => (
|
||||||
<FeaturedContentWrap className="featured-content-wrap">
|
<FeaturedContentWrap className="featured-content-wrap">
|
||||||
@ -13,8 +13,7 @@ const FeaturedGuides = () => (
|
|||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<div className="swim-lane row">
|
<div className="swim-lane row">
|
||||||
{ guides
|
{ getFeaturedGuides()
|
||||||
.filter(({ featured }) => featured)
|
|
||||||
.map(guide => (
|
.map(guide => (
|
||||||
<FeaturedGuide guide={ guide } key={ guide.url } />
|
<FeaturedGuide guide={ guide } key={ guide.url } />
|
||||||
)) }
|
)) }
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
"fileName": "design-patterns-for-humans",
|
"fileName": "design-patterns-for-humans",
|
||||||
"featured": true,
|
"featured": true,
|
||||||
"author": "kamranahmedse",
|
"author": "kamranahmedse",
|
||||||
"createdAt": "2018-11-29T17:00:00.860Z",
|
"updatedAt": "2019-10-09T12:00:00.860Z",
|
||||||
"updatedAt": "2018-11-29T17:00:00.860Z"
|
"createdAt": "2019-01-23T17:00:00.860Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Journey to HTTP/2",
|
"title": "Journey to HTTP/2",
|
||||||
@ -17,7 +17,8 @@
|
|||||||
"featured": true,
|
"featured": true,
|
||||||
"author": "kamranahmedse",
|
"author": "kamranahmedse",
|
||||||
"createdAt": "2018-12-04T12:00:00.860Z",
|
"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",
|
"title": "DNS in One Picture",
|
||||||
@ -26,8 +27,8 @@
|
|||||||
"fileName": "dns-in-one-picture",
|
"fileName": "dns-in-one-picture",
|
||||||
"featured": true,
|
"featured": true,
|
||||||
"author": "kamranahmedse",
|
"author": "kamranahmedse",
|
||||||
"updatedAt": "2019-10-09T12:00:00.860Z",
|
"updatedAt": "2018-12-04T12:00:00.860Z",
|
||||||
"createdAt": "2019-01-23T17:00:00.860Z"
|
"createdAt": "2018-12-04T17:00:00.860Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "HTTP Caching",
|
"title": "HTTP Caching",
|
||||||
@ -36,7 +37,7 @@
|
|||||||
"fileName": "http-caching",
|
"fileName": "http-caching",
|
||||||
"featured": true,
|
"featured": true,
|
||||||
"author": "kamranahmedse",
|
"author": "kamranahmedse",
|
||||||
"updatedAt": "2019-10-09T12:00:00.860Z",
|
"createdAt": "2018-11-29T17:00:00.860Z",
|
||||||
"createdAt": "2019-01-23T17:00:00.860Z"
|
"updatedAt": "2018-11-29T17:00:00.860Z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -3,7 +3,12 @@ import authors from "data/authors";
|
|||||||
import siteConfig from "data/site";
|
import siteConfig from "data/site";
|
||||||
|
|
||||||
export const getAllGuides = () => {
|
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 => {
|
export const getRequestedGuide = req => {
|
||||||
|
Reference in New Issue
Block a user