Create iCalendar Files with Nitride (MfGames .NET Libraries)

One of the more useful features in previous versions of Dylan's static site generators was the ability to create an iCalendar file of the posts, both past and future. It wasn't only just to see little entries pop up for the dopamine rush, but also to give them a head's up when a new chapter for Fedran needs to be written or its been a few months since a blog post has been written.

We use iCalendar because it's a solid standard format that can easily be added into Nextcloud, put on a phone, or otherwise used anywhere to keep it in mind.

(Technicaly, it could also be used to create task lists for sites that are missing links or other things but out of scope for this iteration).

We put this into the MfGames.Nitride.Temporal even though it adds an extra dependency (Ical.Net) because it is a relatively small feature and it hit that ratio of package management verses three additional classes. Like the rest of the temporal packages, this built to use Noda.Time for coordinating times.

The documentation has some notes on how to include and use it inside a Nitride project.

New Entity Constructor

We also added new constructor to MfGames.Gallium.Entity that allows multiple components to be set as part of the constructor.

// These are all the same.
var entity1 = new Entity();
entity1 = entity1.Add("bob");
entity1 = entity1.Add(13);

var entity2 = new Entity().Add("bob").Add(13);

var entity3 = new Entity().SetAll("bob", 13);

// These are the new features.
var entity4 = new Entity("bob", 13);

var entity5 = new Entity(13, "bob");

It seemed like a no-brainer, mainly because it is a pattern we use a lot in the code, but Dylan finds that the formatting is less than “pretty” when it comes to multi-line chaining operations.

var notPretty = new Entity(
    "bob",
    13,
    instant,
    path)
    .AddTextContent(content);

var pretty = new Entity()
    .SetAll(
        "bob",
        13,
        instant,
        path)
    .AddTextContent(content);

Either work though, so it will end up reducing some of the clutter for common use cases.

Metadata

Categories: