api Page update
This commit is contained in:
1 parent
af7f32b1c0
commit
68b7f4225d
3 files changed
+56
-21
No files matched your search
@@ -1,6 +1,29 @@
|
||||
import ImageArtifactType from '../core/ImageArtifactType'
|
||||
|
||||
export function encodeImage(image) {
|
||||
export type ImageArtifactDto = {
|
||||
height: number
|
||||
width: number
|
||||
src: string
|
||||
set: Array<{
|
||||
density: number
|
||||
url: string
|
||||
}>
|
||||
}
|
||||
|
||||
export type ImageDto = {
|
||||
artifacts: {
|
||||
original: ImageArtifactDto,
|
||||
large: ImageArtifactDto,
|
||||
big: ImageArtifactDto,
|
||||
medium: ImageArtifactDto,
|
||||
small: ImageArtifactDto,
|
||||
fb: ImageArtifactDto,
|
||||
},
|
||||
hash: string
|
||||
file: string
|
||||
}
|
||||
|
||||
export function encodeImage(image): ImageDto {
|
||||
const artifacts = [
|
||||
ImageArtifactType.SMALL,
|
||||
ImageArtifactType.MEDIUM,
|
||||
@@ -17,8 +40,8 @@ export function encodeImage(image) {
|
||||
}, {})
|
||||
|
||||
return {
|
||||
artifacts,
|
||||
artifacts: artifacts as any,
|
||||
hash: image.hash,
|
||||
file: image.file,
|
||||
file: image.file,
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,29 @@
|
||||
import { encodeImage } from './image'
|
||||
import { encodeImage, ImageDto } from './image'
|
||||
import Page from '../core/Page'
|
||||
import { Breadcrumb } from '../types'
|
||||
import { Tag } from '../core/Tag'
|
||||
|
||||
export function encodePage(page: Page, breadcrumb: Breadcrumb) {
|
||||
type Token = {
|
||||
token: string
|
||||
data: any
|
||||
}
|
||||
|
||||
type PageDto = {
|
||||
id: string
|
||||
title: string
|
||||
date?: string
|
||||
url: string
|
||||
data: string
|
||||
description: string
|
||||
preview?: ImageDto
|
||||
tokens: Token[]
|
||||
tags: Tag[]
|
||||
breadcrumb: Breadcrumb
|
||||
}
|
||||
|
||||
export function encodePage(page: Page, breadcrumb: Breadcrumb): PageDto {
|
||||
const preview = page.preview ? encodeImage(page.preview) : null
|
||||
const date = page.date ? page.date.toString() : null
|
||||
|
||||
return {
|
||||
id: page.id,
|
||||
@@ -11,8 +31,10 @@ export function encodePage(page: Page, breadcrumb: Breadcrumb) {
|
||||
url: page.url,
|
||||
data: page.data,
|
||||
description: page.description,
|
||||
preview,
|
||||
tokens: page.tokens,
|
||||
tags: page.tags,
|
||||
preview,
|
||||
date,
|
||||
breadcrumb,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user