Building a blog in Kentico Cloud - Part 2

Building a blog in Kentico Cloud - Part 2

Wednesday, November 30, 2016

The second part in my series of posts about creating a new blog site using Kentico Cloud.

Article Building a blog in Kentico Cloud - Part 2

In a previous post, I spoke about starting a new project - building a blog in Kentico Cloud. This is that blog, and in this post, I discuss some of my findings and the progress that I have made.

What I learned this week

So - in pure Kentico terms, the first week of work was fairly straightforward. I just needed to create some basic content types and stick some content into Cloud.

The postman is your friend

Postman API development tool

Without a doubt, one of the biggest helps in the early phases was using Postman to see what kind of data I could get out of the API. The detail in the Cloud documentation is good to get started, but you're best off trying things out in postman to see what kind of responses you get back.

I simply can't recommend this enough, go and get it and your life as an API consumer will basically improve.

Filtering by tags

Filter what you want to see

If you had to put me in one of two boxes - solution architect or UX architect - then I'm going to be rattling around in the solution architect box. For this reason, I've been keeping the navigational UX on this site to its bare minimum. As an example, I've not added a calendar control to show which posts were made in which month. Who really uses that anyway (not me at least), I just want to know wat was written - in individual post date and subject matter will give me enough to decide if it's out of date.

Where am I going with this; the thing that is useful is being able to filter posts by their tag. I figured this would be fairly straightforward, but there were some little catches on the way.

The main difficulty I had here was in creating a partial model to feed to a view the only contained the tags available to the current post. To do this, I created the following helper method:

public static KeyValuePair<string, string> GetSelectedTaxonomy(this ContentItem content, string elementCode)
{
    var element = content.Elements[elementCode];
    return element != null && element.value != null ? new KeyValuePair<string, string>(element.value[0].codename.ToString(), element.value[0].name.ToString()) : new KeyValuePair<string, string>();
}

I can then call this helper y passing in the ContentItem and the name of the field that contains the taxonomy value. The result of the helper then passing into a partial view:

@model KeyValuePair<string,string>
<a class="btn btn-info" href="@Url.Action("Tag", "Posts", new {id = @Model.Key})">@Model.Value</a>

Mime types for assets

Annoying mime types

This one caught me out. I could not for the life of me determine the reason why twitter cards were not working. Only after using the developer tools in Chrome did I realise that the mime type for my images was coming back as application/octetstream.

I haven't implemented a fix for this yet, but I do have one. Basically, I need to wrap the images up in an HTTP Handler or simply another route that passes the images through from Cloud to the client and correct the mime type. This isn't so much of an issue for me, as I needed to do that anyway in order to get the CDN working. I may even just do this using URL rewriting, it depends on how the CDN I want to use behaves.

Conclusion

No major issues so far; the project, on the whole, has been a positive one. There is still more to do and I have a fairly chunky list of things that I want to achieve in Trello right now.

If you've not done so already, I'd recommend having a play with Cloud to see what you can achieve in a short time-frame. The Cloud team are really responsive if you need help and are generally full of enthusiasm for the project.

Post tags

Kentico Kentico Cloud