Merge pull request #1292 from xavcz/dochead

Fix HeadTags <-> Flexbox + add 2 helpers for images
This commit is contained in:
Sacha Greif 2016-04-08 09:53:02 +09:00
commit e3d2ffc90f
4 changed files with 29 additions and 8 deletions

View file

@ -8,13 +8,15 @@ const PostListHeader = () => {
({PostViews, SearchForm, CategoriesList, HeadTags} = Telescope.components)
return (
<div className="post-list-header">
<div>
<HeadTags />
<div className="post-list-categories">
<ListContainer collection={Categories} limit={0} resultsPropName="categories" component={CategoriesList}/>
<div className="post-list-header">
<div className="post-list-categories">
<ListContainer collection={Categories} limit={0} resultsPropName="categories" component={CategoriesList}/>
</div>
<PostViews />
<SearchForm/>
</div>
<PostViews />
<SearchForm/>
</div>
)
}

View file

@ -3,7 +3,7 @@ import React from 'react';
const PostThumbnail = ({post}) => {
return (
<a className="post-thumbnail" href={Posts.getLink(post)} target={Posts.getLinkTarget(post)}>
<img src={post.thumbnailUrl} />
<img src={Posts.getThumbnailUrl(post)} />
</a>
)
}

View file

@ -318,3 +318,12 @@ Telescope.utils.getFieldLabel = (fieldName, collection) => {
const nameWithSpaces = Telescope.utils.camelToSpaces(fieldName.replace("telescope.", ""));
return label || nameWithSpaces;
}
Telescope.utils.getLogoUrl = () => {
const logoUrl = Telescope.settings.get("logoUrl");
if (!!logoUrl) {
const prefix = Telescope.utils.getSiteUrl().slice(0,-1);
// the logo may be hosted on another website
return logoUrl.indexOf('://') > -1 ? logoUrl : prefix + logoUrl;
}
};

View file

@ -143,3 +143,13 @@ Posts.getNotificationProperties = function (post) {
return properties;
};
Posts.getThumbnailUrl = (post) => {
const thumbnailUrl = post.thumbnailUrl;
if (!!thumbnailUrl) {
const prefix = Telescope.utils.getSiteUrl().slice(0,-1);
// the thumbnail may be hosted on another website
return thumbnailUrl.indexOf('://') > -1 ? thumbnailUrl : prefix + thumbnailUrl;
}
};
Posts.helpers({ getThumbnailUrl() { return Posts.getThumbnailUrl(this); } });