Working with content

Ignite parses Markdown files in in your Content folder, automatically converting them to pages.

You should create subfolders inside Content to represent different types of content. This might be by date, e.g. Content/2023, Content/2024, etc, by type, e.g. Content/articles, Content/tutorials, or whatever other approach you want.

When it come to rendering your articles, you have two options:

  1. You can use YAML front matter to specify the layout to use for your content.
  2. You can provide only one layout in your site, and it will be used if nothing else is specified.

This example site contains two types of content, articles and stories. Some content requests a specific layout, but others don’t.

This content uses the default layout.

And this content uses a custom layout.

Listing content

All pages of all types are given access to the current publishing context, which lets you read content data by type or tag, and more.

As a result, we can write code to show a list of all articles right here on this page:

List {
    for content in context.allContent {
        Link(content)
    }
}

Or we could show only content that matches the type story:

List {
    for content in context.content(ofType: "story") {
        Link(content)
    }
}

But there are a handful of helpers available to make things both easier and more attractive.

First, ContentPreview can be used to make a preview for articles. This automatically includes the articles image, title, description, link, and tags, all in one:

Section {
    for item in context.allContent {
        ContentPreview(for: item)
            .width(3)
            .margin(.bottom)
    }
}

So you think you know Swift? Think again! Fresh from the success of our audiobook launch, Laboratoires TwoStraws is back with an all-new card game that will finally give you something to do while waiting for Xcode to finish indexing.

Although Swift gives us powerful programming technologies such as generics, protocols, and type inference, if there’s one thing we can all agree has been sorely lacking it’s built-in support for scalable concurrent transactions using RESTful middleware and messaging.

In the heart of Cupertino, amidst the buzz of WWDC, a caper of canine proportions was about to unfold, starring two unwitting heroines: Luna and Arya, the fluffy Samoyeds who are the real power behind Hacking with Swift. Little did anyone know, these two bundles of fur were about to turn Apple Park into their personal playground, all under the watchful eyes of tech enthusiasts and Apple executives alike.

Once upon a time in a land not so far away, nestled between the rolling hills of Silicon Valley, there was a developer named Sam Swift. Sam, as his name might suggest, was not just any developer; he was a Swift developer. A coder of high esteem, known across the land for his quick wit and even quicker compile times.

YAML front matter

Ignite supports Jekyll-style YAML front matter to specify metadata.

Specifically, the following fields are supported:

In addition, you can read properties such as estimatedWordCount and estimatedReadingMinutes on your content, to provide extra information to users.

Tag pages

If you make a type that conforms to the TagPage protocol, you can use it to display tag pages on your site.

This protocol passes you an optional tag string: if it has a tag you should use it, but if it’s nil you should render an “all tags” page.

This sample site has a small tags page implementation. You can see it in action with these links:

Created with Ignite