Giter Site home page Giter Site logo

pauldangerkile / blazorstatic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tesar-tech/blazorstatic

0.0 0.0 0.0 792 KB

Embrace the capabilities of Blazor on .NET 8 to craft static websites.

Home Page: https://tesar-tech.github.io/BlazorStatic/

License: GNU Affero General Public License v3.0

JavaScript 2.27% C# 57.44% CSS 0.10% HTML 40.19%

blazorstatic's Introduction

Blazor Static

Discord Nuget (with prereleases)

Transform your Blazor app into a static site generator.

Embrace the capabilities of Blazor on .NET 8 to craft static websites.

How to start:

BlazorStatic is a small library designed for integration into Blazor applications. Here are a few straightforward methods to get started:

Fork or clone BlazorStaticMinimalBlog

RECOMMENDED STARTING POINT: BlazorStaticMinimalBlog offers a quick and convenient way to deploy your site within minutes.

Build from Scratch

Begin by creating a Blazor application, then proceed to add content and integrate BlazorStatic. Comprehensive instructions are available here. This approach will help you build a project akin to BlazorStaticMinimalBlog and is beneficial for understanding the inner workings of BlazorStatic.

Using dotnet new blazorStatic

Ideally, this command would set up your project automatically. However, this feature is currently a significant TODO awaiting implementation.

How it works? What it does?

BlazorStatic:

  • Generates static HTML files by running the app and fetching page HTML with HttpClient

    • Use the following in your app::
    app.UseBlog<FrontMatter>(); //processes markdown files, adds blog and tags pages
    app.UseBlazorStaticGenerator(shutdownApp: !app.Environment.IsDevelopment());
    • shutdownApp is essential for CI/CD pipelines to prevent indefinite running.
  • Automates the discovery of pages to generate by scanning for the @page directive in Razor files. It targets only non-parametrized pages (e.g., @page "/mypage", not @page "/mypage/{param}").

  • Enables adding additional pages for generation using

    builder.Services.AddBlazorStaticService(opt => {
      opt.PagesToGenerate.Add(new($"/mypage/paramValue", "paramValue.html"))
    }); 

    Example here for adding docs pages.

  • Simplifies blog post generation from markdown files, respecting a specified folder structure:

    builder.Services.AddBlogService<FrontMatter>(opt => {
        opt.BlogPageUrl = "blog"; //default value
        opt.PostFilePattern = "*.md"; //default value
        opt.ContentPath = Path.Combine("Content", "Blog"); //default path
        opt.MediaFolderRelativeToContentPath = "media"; //default folder
    });
  • Provides FrontMatter class for parsing blog post metadata.

  • Allows for custom IFrontMatter implementations to suit various markdown (front matter) formats.

  • Facilitates copying necessary files to the output folder:

    builder.Services.AddBlazorStaticService(opt => {
       opt.OutputFolderPath = "output";//root of the output 
       //wwwroot and _content are copied by default
       opt.IgnoredPathsOnContentCopy.AddRange(new[] { "app.css" }); //don't copy app.css
    }); 
  • Offers flexibility in CSS frameworks and themes, without locking you into a specific choice. TailwindCSS is used in the default theme, but it's fully customizable. Open to suggestions and contributions for design improvements (do it, I am not the right person).

  • Easy deployment: run your app in a CI/CD pipeline and deploy the generated files to platforms like GitHub Pages, Azure Static Web Apps, Netlify, etc. See the pipline for a minimal blog setup or check the deployment guide for more details

Samples

Description Source Live
Page about BlazorStatic (this repo contains the code itself) source live
Minimal blog source live
Zodoc - image processing and deep learning sample source live
โ“ Add your page here!!!

Contributions

Contributions are highly encouraged and appreciated. If you find something missing, unclear, or encounter an issue with the code, I warmly welcome your input. Feel free to:

blazorstatic's People

Contributors

tesar-tech avatar chrisg32 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.