final touches

This commit is contained in:
2020-09-24 19:29:43 +02:00
parent 4df5603222
commit e71457a49d
7 changed files with 69 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import axios from 'axios'
import dj from 'dayjs'
const isDev = process.env.NODE_ENV !== 'production' && false
axios.defaults.baseURL = `${isDev ? 'http://localhost' : 'https://api.nicco.io'}/wp-json/wp/v2`
@@ -39,3 +40,12 @@ export async function getAll(url, params = {}) {
}
return results.map(normalize)
}
export function sortByAndMapDate(data, format = 'MMM YY') {
return data
.sort((a, b) => parseInt(b.date) - parseInt(a.date))
.map((work) => ({
...work,
date: dj(work.date * 1000).format(format),
}))
}