FlipLeaf.Engine 1.0.0-beta.1

This is a prerelease version of FlipLeaf.Engine.
dotnet add package FlipLeaf.Engine --version 1.0.0-beta.1
                    
NuGet\Install-Package FlipLeaf.Engine -Version 1.0.0-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FlipLeaf.Engine" Version="1.0.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlipLeaf.Engine" Version="1.0.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="FlipLeaf.Engine" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlipLeaf.Engine --version 1.0.0-beta.1
                    
#r "nuget: FlipLeaf.Engine, 1.0.0-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FlipLeaf.Engine@1.0.0-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FlipLeaf.Engine&version=1.0.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FlipLeaf.Engine&version=1.0.0-beta.1&prerelease
                    
Install as a Cake Tool

FlipLeaf

FlipLeaf est un générateur de site statique (SSG) pour .NET.

Ce repository contient la nouvelle itération du projet (prototype en cours), inspirée de la première version FlipLeaf.v1, avec une architecture modulaire :

  • FlipLeaf.Engine : moteur principal de génération (pipeline de transformation, gestion content/layouts/includes, mode watch).
  • FlipLeaf.Sdk : SDK MSBuild pour simplifier la création d’un projet FlipLeaf.
  • FlipLeaf.Tool : outil CLI (flipleaf) en cours de construction.
  • FlipLeaf.Engine.Tests : projet de tests du moteur.

Objectif

Générer un site statique à partir de fichiers de contenu, avec prise en charge de :

  • Markdown (Markdig),
  • front matter YAML,
  • templates Liquid (layouts/includes),
  • post-traitements (ex: génération de sitemap.xml).

État du projet

Le projet est en phase alpha / prototype. L’API et les conventions peuvent évoluer.

Cibles .NET

Selon les composants, le repository cible notamment :

  • .NET 10
  • .NET 8
  • .NET Standard 2.0

Démarrage rapide (FlipLeaf.Engine)

dotnet new console
dotnet add package FlipLeaf.Engine --prerelease

Créer un fichier content/index.md, puis utiliser un Program.cs similaire à :

using FlipLeaf;
using Microsoft.Extensions.DependencyInjection;
using System.Xml.Linq;

Console.OutputEncoding = System.Text.Encoding.UTF8;

var builder = SiteBuilder.CreateDefault(args)
    .AddYaml()
    .AddLiquid()
    .AddMarkdown();

var site = builder.Build();

// markdown rendering
site.Content.Add(async static (ISite s, Leaf input) =>
{
    if (input.Extension != ".md")
        return FlipStatus.Unhandled;

    var yaml = s.Services.GetRequiredService<IYamlMarkup>();
    var liquid = s.Services.GetRequiredService<ILiquidMarkup>();
    var markdown = s.Services.GetRequiredService<IMarkdownMarkup>();

    var content = input.ReadAllText();
    (content, var headers) = yaml.ParseHeader(content);
    (content, var context) = await liquid.RenderAsync(content, headers);
    content = markdown.Render(content, input);
    content = await liquid.ApplyLayoutAsync(content, context);

    return input.AsContentResult(content, Path.ChangeExtension(input.Name, ".html"));
});

// fallback: copy non-markdown files as-is
site.Content.Add(static leaf => leaf.AsCopyResult());

// optional post-process (example: sitemap.xml)
site.AddPostProcess(static s =>
{
    var ns = (XNamespace)"http://www.sitemaps.org/schemas/sitemap/0.9";
    new XElement(ns + "urlset",
        s.Content
            .Where(i => i.OutName.EndsWith(".html", StringComparison.OrdinalIgnoreCase))
            .Select(i => new XElement(ns + "url",
                new XElement(ns + "loc", "https://example.com/" + i.OutName.Replace('\\', '/'))))
    ).Save(Path.Combine(s.OutDir, "sitemap.xml"));
});

Console.WriteLine($"🍃 Starting on {site.RootDir}");
await site.RunAsync(args);

Les fichiers générés sont écrits dans out.

Conventions par défaut

  • La racine du site est détectée automatiquement depuis le répertoire courant.
  • Le contenu est lu depuis ./content.
  • Les layouts sont lus depuis ./layouts.
  • Les includes sont lus depuis ./includes.
  • La sortie est écrite dans ./out.

Mode watch

Si le premier argument CLI est watch, le moteur surveille les changements de fichiers et régénère le site.

dotnet run -- watch

Samples

Un exemple file-based app est disponible ici :

  • samples/flipleaf-official-site/site.cs

Ce sample montre l’usage de FlipLeaf via la directive #:sdk FlipLeaf.Sdk@1.0.0-alpha-02.

Exécution :

cd samples/flipleaf-official-site
dotnet run site.cs

Mode watch :

dotnet run site.cs -- watch

Exemple réel : coldwire.net (FlipLeaf en sous-module)

Le projet D:\code\perso\coldwire.net utilise ce repository comme sous-module Git :

  • .gitmodules déclare flipleaf pointant vers https://github.com/tbolon/FlipLeaf.git
  • le projet importe directement :
    • flipleaf/src/FlipLeaf.Sdk/Sdk/Sdk.props
    • flipleaf/src/FlipLeaf.Sdk/Sdk/Sdk.targets
  • FlipLeafSdkProjectRef=True permet de référencer les projets sources locaux (au lieu d’un package NuGet)
  • Program.cs configure le pipeline (AddYaml, AddLiquid, AddMarkdown), transforme les .md en .html, copie les autres fichiers, puis génère un sitemap.xml
  • la structure de contenu suit les conventions FlipLeaf : content, layouts, includes, sortie dans out

Ce cas montre un usage concret de FlipLeaf pour générer un site réel en s’appuyant sur le moteur directement depuis un sous-module.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-beta.1 95 6/25/2026
1.0.0-alpha-16 65 6/25/2026
1.0.0-alpha-15 160 1/31/2025
1.0.0-alpha-14 153 1/31/2025
1.0.0-alpha-13 1,004 7/26/2018
1.0.0-alpha-12 961 7/26/2018
1.0.0-alpha-11 1,004 7/26/2018
1.0.0-alpha-10 134 1/31/2025