mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2024-12-22 16:16:24 +00:00
date stuff
This commit is contained in:
parent
e4ef072769
commit
4c58bfc4cc
@ -9,6 +9,8 @@
|
|||||||
return dj(date).format('MMM D, YYYY')
|
return dj(date).format('MMM D, YYYY')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: console.log(post)
|
||||||
|
|
||||||
$: created = format(post.date)
|
$: created = format(post.date)
|
||||||
$: modified = format(post.modified)
|
$: modified = format(post.modified)
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import dj from 'dayjs'
|
||||||
|
|
||||||
export let project
|
export let project
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -37,7 +39,7 @@
|
|||||||
<a href={project.link} target="_blank" rel="noopener">
|
<a href={project.link} target="_blank" rel="noopener">
|
||||||
<h2>{project.title}</h2>
|
<h2>{project.title}</h2>
|
||||||
</a>
|
</a>
|
||||||
<div><b>{project.description}</b> <b class="date">{project.date}</b></div>
|
<div><b>{project.description}</b> <b class="date">{dj(project.date * 1000).format('MMM YY')}</b></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{@html project.content}
|
{@html project.content}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import dj from 'dayjs'
|
||||||
import ImageFrame from '../components/ImageFrame.svelte'
|
import ImageFrame from '../components/ImageFrame.svelte'
|
||||||
|
|
||||||
export let work
|
export let work
|
||||||
@ -49,7 +50,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="horizontal regular">
|
<div class="horizontal regular">
|
||||||
<div>{work.role}</div>
|
<div>{work.role}</div>
|
||||||
<div>{work.date}</div>
|
<div>{dj(work.date * 1000).format('MMM YY')}</div>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
{@html work.content}
|
{@html work.content}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import dj from 'dayjs'
|
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV !== 'production' && false
|
const isDev = process.env.NODE_ENV !== 'production' && false
|
||||||
axios.defaults.baseURL = `${isDev ? 'http://localhost' : 'https://api.nicco.io'}/wp-json/wp/v2`
|
axios.defaults.baseURL = `${isDev ? 'http://localhost' : 'https://api.nicco.io'}/wp-json/wp/v2`
|
||||||
@ -41,13 +40,8 @@ export async function getAll(url, params = {}) {
|
|||||||
return results.map(normalize)
|
return results.map(normalize)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sortByAndMapDate(data, format = 'MMM YY') {
|
export function sortByDate(data) {
|
||||||
return data
|
return data.sort((a, b) => parseInt(b.date) - parseInt(a.date))
|
||||||
.sort((a, b) => parseInt(b.date) - parseInt(a.date))
|
|
||||||
.map((work) => ({
|
|
||||||
...work,
|
|
||||||
date: dj(work.date * 1000).format(format),
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function respond(res, body) {
|
export function respond(res, body) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { respond, getAll, getOne, sortByAndMapDate } from '../../lib/wp'
|
import { respond, getAll, getOne, sortByDate } from '../../lib/wp'
|
||||||
|
|
||||||
export async function get(req, res) {
|
export async function get(req, res) {
|
||||||
const [type, slug] = req.params.slug
|
const [type, slug] = req.params.slug
|
||||||
@ -8,6 +8,6 @@ export async function get(req, res) {
|
|||||||
respond(res, { data })
|
respond(res, { data })
|
||||||
} else {
|
} else {
|
||||||
const data = await getAll(type)
|
const data = await getAll(type)
|
||||||
respond(res, { data: sortByAndMapDate(data) })
|
respond(res, { data: sortByDate(data) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user