本文整理汇总了TypeScript中@trailimage/models.blog.postWithKey方法的典型用法代码示例。如果您正苦于以下问题:TypeScript blog.postWithKey方法的具体用法?TypeScript blog.postWithKey怎么用?TypeScript blog.postWithKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@trailimage/models.blog
的用法示例。
在下文中一共展示了blog.postWithKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: trackJSON
/**
* Compressed GeoJSON of post photos and possible track.
*/
async function trackJSON(req: Request, res: Response) {
const slug = req.params[RouteParam.PostKey];
const post = blog.postWithKey(slug);
if (is.value(post)) {
view.sendJSON(res, `${slug}/${mapPath}`, post.geoJSON.bind(post));
} else {
view.notFound(req, res);
}
}
示例2: series
/**
* Render map for posts in a series.
*/
function series(req: Request, res: Response) {
render(
blog.postWithKey(
req.params[RouteParam.SeriesKey],
req.params[RouteParam.PartKey]
),
req,
res
);
}
示例3: render
view.send(res, key, render => {
const p = blog.postWithKey(key);
if (!is.value(p)) {
view.notFound(req, res);
return;
}
p.ensureLoaded()
.then(() => {
render(viewName, {
post: p,
title: p.title,
jsonLD: p.jsonLD(),
layout: Layout.None,
description: p.longDescription,
slug: key
});
})
.catch(err => view.internalError(res, err));
});
示例4: gpx
/**
* Initiate GPX download for a post.
*/
function gpx(req: Request, res: Response) {
const post = config.providers.map.allowDownload
? blog.postWithKey(req.params[RouteParam.PostKey])
: null;
if (is.value(post)) {
const fileName = post.title + '.gpx';
res.setHeader(
Header.Content.Disposition,
`attachment; filename=${fileName}`
);
res.setHeader(Header.Content.Type, inferMimeType(fileName));
post.gpx(res).catch(err => {
log.error(err);
res.removeHeader(Header.Content.Type);
res.removeHeader(Header.Content.Disposition);
view.notFound(req, res);
});
} else {
view.notFound(req, res);
}
}
示例5: post
/**
* Render map for a single post.
*/
function post(req: Request, res: Response) {
render(blog.postWithKey(req.params[RouteParam.PostKey]), req, res);
}