本文整理匯總了TypeScript中@trailimage/models.blog類的典型用法代碼示例。如果您正苦於以下問題:TypeScript blog類的具體用法?TypeScript blog怎麽用?TypeScript blog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了blog類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: withTag
/**
* Photos with tag rendered in response to click on label in photo tags page.
*/
function withTag(req: Request, res: Response) {
const slug = tagParam(req);
blog
.getPhotosWithTags(slug)
.then(photos => {
if (photos === null || photos.length == 0) {
view.notFound(req, res);
} else {
const tag = blog.tags.get(slug);
const title = `${sayNumber(
photos.length
)} “${tag}” Image${photos.length != 1 ? 's' : ''}`;
res.render(Page.PhotoSearch, {
photos,
config,
title,
layout: Layout.None
});
}
})
.catch(err => {
view.notFound(req, res);
log.error(err, { photoTag: slug });
});
}
示例2: withID
/**
* Render post with matching provider (e.g. Flickr) ID. Redirect to normal URL.
*/
function withID(req: Request, res: Response) {
const post = blog.postWithID(req.params[RouteParam.PostID]);
if (is.value(post)) {
res.redirect(HttpStatus.PermanentRedirect, '/' + post.key);
} else {
view.notFound(req, res);
}
}
示例3: 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);
}
}
示例4: 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
);
}
示例5: siteMap
/**
* XML Sitemap.
*/
function siteMap(_req: Request, res: Response) {
view.send(
res,
Page.Sitemap,
{
posts: blog.posts,
layout: Layout.None,
categories: blog.categoryKeys(),
tags: blog.tags
},
MimeType.XML
);
}
示例6: loadMockData
export function loadMockData() {
postProvider.configure(config.providers.post);
mapProvider.configure(config.providers.map);
modelConfig.owner = config.owner;
modelConfig.subtitleSeparator = config.posts.subtitleSeparator;
modelConfig.maxPhotoMarkersOnMap = config.providers.map.maxMarkers;
modelConfig.providers.post = postProvider;
modelConfig.providers.map = mapProvider;
modelConfig.site = config.site;
return blog.load();
}
示例7: exif
/**
* Render HTML table of EXIF values for given photo.
*/
function exif(req: Request, res: Response) {
const photoID = req.params[RouteParam.PhotoID];
blog
.getEXIF(photoID)
.then(exif => {
res.render(Page.EXIF, {
EXIF: exif,
layout: Layout.None
});
})
.catch(err => {
log.error(err, { photoID });
view.notFound(req, res);
});
}
示例8: render
view.send(res, key, render => {
// use renderer to build view that wasn't cached
const category = blog.categoryWithKey(key);
if (!is.value(category)) {
return view.notFound(req, res);
}
render(
Page.CategoryList,
standardContext(category, category.subcategories.size, {
jsonLD: category.jsonLD(),
subtitle: 'Subcategories',
subcategories: Array.from(category.subcategories)
})
);
});
示例9: 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));
});
示例10: withPhoto
/**
* Render post that contains photo with given ID.
*/
function withPhoto(req: Request, res: Response) {
const photoID = req.params[RouteParam.PhotoID];
blog
.postWithPhoto(photoID)
.then(post => {
if (is.value(post)) {
res.redirect(
HttpStatus.PermanentRedirect,
`/${post.key}#${photoID}`
);
} else {
view.notFound(req, res);
}
})
.catch(err => {
log.error(err, { photoID });
view.notFound(req, res);
});
}