OptionA.Blazor.Blog
8.1.3
See the version list below for details.
dotnet add package OptionA.Blazor.Blog --version 8.1.3
NuGet\Install-Package OptionA.Blazor.Blog -Version 8.1.3
<PackageReference Include="OptionA.Blazor.Blog" Version="8.1.3" />
<PackageVersion Include="OptionA.Blazor.Blog" Version="8.1.3" />
<PackageReference Include="OptionA.Blazor.Blog" />
paket add OptionA.Blazor.Blog --version 8.1.3
#r "nuget: OptionA.Blazor.Blog, 8.1.3"
#:package OptionA.Blazor.Blog@8.1.3
#addin nuget:?package=OptionA.Blazor.Blog&version=8.1.3
#tool nuget:?package=OptionA.Blazor.Blog&version=8.1.3
OptionA.Blazor.Blog
Blazor components for displaying a blog in Blazor.
For full documentation, releasenotes and examples, go to option-a.tech. To full source can be viewed on github.
Getting started
To start using the OptionA.Blazor.Blog include the required depencenies in your service provider. The package uses the default .Net Dependency Injection.
Service collection
To add the components you can use the extension method AddOptionABlog or AddOptionABootstrapBlog. The bootstrap version prefills the optional configuration with bootstrap (5.3) classes. Everything in the config can be overwritten (if a config is supplied to the method this is applied after the default classes).
Post class
While the individiual components be used on your Blazor page. The package is build around the Post class. Posts can be made manually in code or imported from a Json string. Because of some specific behavior, creating and reading the Json can be done using the IBuilderService which is added by the extensions methods.
Builder package
To start building posts the OptionA.Blazor.Blog.Builder package can be used. It is advised to use a version where the major and minor version match (first 2 parts), these will be build together and will always be compatible.
Use package
To display a post, use the <OptAPost> component and provide the Post parameter with a valid Post class:
@using OptionA.Blazor.Blog;
@inject OptionA.Blazor.Blog.Services.IBuilderService _builder;
<OptAPost Post="_post" />
@code {
private Post? _post;
[Parameter]
public string? PostJson { get; set; }
protected override void OnParametersSet()
{
if (string.IsNullOrEmpty(PostJson))
{
_post = null;
return;
}
_post = _builder.CreateFromJson(PostJson);
}
}
Latest release notes
8.1.1
Overall
Removed unused code and added some xml documentation
New features
- Allow override for default Environment.NewLine for use in the code parser
Solved Bugs
- new lines werent always parsed correctly
Components
Following are the currently supported components. For all components there is a Parameter AdditionalClasses to provide specific classes for that single component. RemovedClasses to remove default classes (set by the config) for that single component, and an Attributes parameter to set additional required attributes to that single component.
Post
<OptAPost>
Starting point for displaying posts. A post has a Title (default generated as a <h1> tag). A Subtitle, providing more information. A Post date and a list of Tags for grouping.
Code
<OptACode>
A piece of computer code
Currenty supported languages (for typed rendering) are
- C#
- HTML
Optionally you can add your own Parser by created a class which implements the ICodeParser or inherits the abstract baseclass ParserBase and adding it to the IServiceCollection (if the language is in the CodeLanguage enum).
To define the colors for the code part in a css file in your project provide the following variables. The colors below are the default Visual Studio dark theme.
:root {
--oa-code-keyword: #569cd6;
--oa-code-controlkeyword: #d8a0df;
--oa-code-string: #ce9178;
--oa-code-method: #dcdcaa;
--oa-code-comment: #63b456;
--oa-code-attribute: #9cdcfe;
--oa-code-tagdelimiter: #808080;
--oa-code-directive: #a699e6;
--oa-code-component: #0096aa;
--oa-code-background: #1e1e1e;
--oa-code-headerbackground: #3f3f3f;
--oa-code-color: #dcdcdc;
--oa-code-selected: rgba(51, 153, 255, .5);
--oa-code-class: #4ec9b0;
--oa-code-struct: #86c691;
--oa-code-enum: #b8d7a3;
--oa-code-interface: #b8d7a3;
}
Not everything can be marked automatically, you can add optional markings to provide attributes. Place the marker around the code to mark, for example
public class \*C\*MyClass\*C\*
{
\*S\*public string? SelectedText { get; set; }\*S\*
}
currently supported markings are
- Selection
- gives the code a selected attribute
- Marker to use is *S*
- Class
- Marks the code as a class
- Marker to use is *C*
- Struct
- Marks the code as a struct
- Marker to use is *T*
- Interface
- Marks the code as an interface
- Marker to use is *I*
- Enum
- Marks the code as a Enum
- Marker to use is *E*
Text
<OptAText>
A text (usually a paragraph, but can also be a block or inline part), with optional markdown. Currently supported markdown is
- Emphasis (*Emphasis*)
- Strong (**Strong**)
- LineBreak (\n)
- Link ([Link](#Components))
- <cite>Cite</cite> (<cite>Cite</cite>)
- <i>Icon</i> (<i>Icon<\i>)
- The 'content' of the Icon will be set as class, so for a bootstrap image icon it should be <i>bi bi-image</i> which results in <i class="bi bi-image" />
Optionally you can add your own Parser by created a class which implements the IMarkerDefinition or inherits the abstract baseclass MarkerDefinition and adding it to the IServiceCollection.
Image
<OptAImage>
An image to display.
Icon
<OptAIcon>
An icon to display, either via class (results in a <i> tag, or through a (list of) Paths, resulting in a <svg> tag
Header
<OptAHeader>
A Header in your post, size can be set
Quote
<OptAQuote>
A Quote, to quote somebody, results in a <blockquote> tag
Frame
<OptAFrame>
A frame to an 'external' site, results in an <iframe> tag to be able to incorporate just about anything you want in your blog.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.10)
- OptionA.Blazor.Storage (>= 8.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OptionA.Blazor.Blog:
| Package | Downloads |
|---|---|
|
OptionA.Blazor.Blog.Builder
Builder for creating a Blog using Blazor. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.0 | 169 | 3/31/2026 |
| 10.0.1 | 255 | 12/24/2025 |
| 10.0.0 | 240 | 12/24/2025 |
| 9.2.5 | 347 | 11/13/2025 |
| 9.2.4 | 344 | 3/11/2025 |
| 9.2.3 | 256 | 2/2/2025 |
| 9.2.2 | 227 | 1/30/2025 |
| 9.2.1 | 208 | 1/27/2025 |
| 9.2.0 | 238 | 1/24/2025 |
| 9.1.4 | 246 | 1/23/2025 |
| 9.1.3 | 215 | 1/23/2025 |
| 9.1.2 | 250 | 1/20/2025 |
| 9.1.1 | 222 | 1/15/2025 |
| 9.1.0 | 227 | 12/4/2024 |
| 9.0.0 | 250 | 11/27/2024 |
| 8.2.2 | 226 | 1/20/2025 |
| 8.2.1 | 223 | 1/15/2025 |
| 8.2.0 | 247 | 12/4/2024 |
| 8.1.4 | 232 | 11/27/2024 |
| 8.1.3 | 249 | 10/21/2024 |
Package updates