[www] Document update
This commit is contained in:
1 parent
f36c2617f6
commit
aab113314d
3 files changed
+15
-28
No files matched your search
+2
-20
@@ -9,6 +9,7 @@ const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSl
|
||||
const {get} = require('koa-route')
|
||||
const {splitBy} = require('../lib/array')
|
||||
const {unique} = require('../utils/common')
|
||||
const {bakeDocument} = require('./documents')
|
||||
|
||||
const sizes = [
|
||||
ImageArtifactType.MEDIUM,
|
||||
@@ -23,25 +24,6 @@ function getMeta(document) {
|
||||
}
|
||||
}
|
||||
|
||||
async function bakeDocument(document) {
|
||||
//const preview = await document.preview.unpack()
|
||||
const preview = document.preview
|
||||
if (!preview) return null
|
||||
|
||||
const image = preview.findArtifact(sizes)
|
||||
if (!image) return null
|
||||
|
||||
return {
|
||||
category: document.category,
|
||||
title: document.title,
|
||||
fileName: document.file.name,
|
||||
fileSize: document.file.size,
|
||||
fileUrl: document.url,
|
||||
imageUrl: image.url,
|
||||
url: document.viewUrl,
|
||||
}
|
||||
}
|
||||
|
||||
function getDocument() {
|
||||
return get('/document/:id', async (ctx, id) => {
|
||||
const path = getPathWithNoTrailingSlash(ctx.path)
|
||||
@@ -60,7 +42,7 @@ function getDocument() {
|
||||
)
|
||||
|
||||
ctx.type = 'text/html'
|
||||
ctx.body = await render(path, Component, getMeta(document))
|
||||
ctx.body = await render(path, Component, getMeta(document), {menuPadding: true})
|
||||
} else {
|
||||
ctx.status = 404
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user