diff --git a/README.md b/README.md index 1bb6bed..9dc3a4e 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,17 @@ You might need to fix the version when publish your website. For example: ```html - + - + - + - + ``` You can also install giscus in your `wwwroot` folder with npm or other Node.js package manager, and include it like above. @@ -66,12 +67,13 @@ Then add this component to your `.razor` files where you want the comments to ap InputPosition="InputPosition.Bottom" Theme="light" Lang="en" - LazyLoading="true" /> + Loading="Loading.Lazy" /> ``` Or you can just add `@using GiscusBlazor` to `_Imports.razor`. -Most values of the `string` parameters can be found from the [giscus official site](https://giscus.app/). +For most of the `string`-typed parameters, you can use the values from the [giscus official site](https://giscus.app/) +directly. ## Samples @@ -79,7 +81,13 @@ You can get some sample apps from the [samples](samples) directory, in both Blaz ## Changelog +### v2.3.0 + +- Add host support. +- Rearrange some parameters. + ### v2.2.1 - Add support for lazy-loading (see [giscus official site](https://giscus.app/)). -- Removed TFM for .NET 5.0, which is now [out of support](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle). +- Removed TFM for .NET 5.0, which is + now [out of support](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle). diff --git a/samples/BlazorServerDemo/Pages/Counter.razor b/samples/BlazorServerDemo/Pages/Counter.razor index 62a6566..a24d11f 100644 --- a/samples/BlazorServerDemo/Pages/Counter.razor +++ b/samples/BlazorServerDemo/Pages/Counter.razor @@ -16,10 +16,10 @@ Mapping="Mapping.PathName" ReactionsEnabled="true" EmitMetadata="false" - InputPosition="InputPosition.Bottom" + InputPosition="InputPosition.Top" Theme="light" Lang="en" - LazyLoading="true" /> + Loading="Loading.Lazy"/> @code { private int currentCount = 0; @@ -28,4 +28,5 @@ { currentCount++; } + } diff --git a/samples/BlazorServerDemo/Pages/FetchData.razor b/samples/BlazorServerDemo/Pages/FetchData.razor index c2e44b1..8e325cd 100644 --- a/samples/BlazorServerDemo/Pages/FetchData.razor +++ b/samples/BlazorServerDemo/Pages/FetchData.razor @@ -48,7 +48,7 @@ else CategoryId="DIC_kwDOG5OPrc4CBTDa" Mapping="Mapping.Specific" ReactionsEnabled="true" - EmitMetadata="false" + EmitMetadata="true" InputPosition="InputPosition.Bottom" Theme="light" Lang="en"/> @@ -60,4 +60,5 @@ else { forecasts = await ForecastService.GetForecastAsync(DateTime.Now); } + } diff --git a/samples/BlazorWebAssemblyDemo/Pages/Counter.razor b/samples/BlazorWebAssemblyDemo/Pages/Counter.razor index fd1bc60..a24d11f 100644 --- a/samples/BlazorWebAssemblyDemo/Pages/Counter.razor +++ b/samples/BlazorWebAssemblyDemo/Pages/Counter.razor @@ -16,10 +16,10 @@ Mapping="Mapping.PathName" ReactionsEnabled="true" EmitMetadata="false" - InputPosition="InputPosition.Bottom" + InputPosition="InputPosition.Top" Theme="light" Lang="en" - LazyLoading="true" /> + Loading="Loading.Lazy"/> @code { private int currentCount = 0; @@ -29,4 +29,4 @@ currentCount++; } -} \ No newline at end of file +} diff --git a/samples/BlazorWebAssemblyDemo/Pages/FetchData.razor b/samples/BlazorWebAssemblyDemo/Pages/FetchData.razor index 5775912..1289cf3 100644 --- a/samples/BlazorWebAssemblyDemo/Pages/FetchData.razor +++ b/samples/BlazorWebAssemblyDemo/Pages/FetchData.razor @@ -1,6 +1,6 @@ @page "/fetchdata" -@inject HttpClient Http @using GiscusBlazor +@inject HttpClient Http Weather forecast @@ -10,29 +10,31 @@ @if (forecasts == null) { -

Loading...

+

+ Loading... +

} else { - - - - - - + + + + + + - @foreach (var forecast in forecasts) - { - - - - - - - } + @foreach (var forecast in forecasts) + { + + + + + + + }
DateTemp. (C)Temp. (F)Summary
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
} @@ -45,10 +47,10 @@ else CategoryId="DIC_kwDOG5OPrc4CBTDa" Mapping="Mapping.Specific" ReactionsEnabled="true" - EmitMetadata="false" + EmitMetadata="true" InputPosition="InputPosition.Bottom" Theme="light" - Lang="en" /> + Lang="en"/> @code { private WeatherForecast[]? forecasts; @@ -66,6 +68,7 @@ else public string? Summary { get; set; } - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + public int TemperatureF => 32 + (int)(TemperatureC * 1.8); } + } diff --git a/src/GiscusBlazor/Giscus.razor b/src/GiscusBlazor/Giscus.razor index a010694..1c72caa 100644 --- a/src/GiscusBlazor/Giscus.razor +++ b/src/GiscusBlazor/Giscus.razor @@ -1,13 +1,15 @@ - + loading="@Loading.ToLoadingString()"> diff --git a/src/GiscusBlazor/Giscus.razor.cs b/src/GiscusBlazor/Giscus.razor.cs index 16b81cd..5caa190 100644 --- a/src/GiscusBlazor/Giscus.razor.cs +++ b/src/GiscusBlazor/Giscus.razor.cs @@ -4,16 +4,16 @@ namespace GiscusBlazor { public partial class Giscus { - [Parameter] -#if NET6_0 +#if NET6_0_OR_GREATER [EditorRequired] #endif + [Parameter] public string Repo { get; set; } = null!; - [Parameter] -#if NET6_0 +#if NET6_0_OR_GREATER [EditorRequired] #endif + [Parameter] public string RepoId { get; set; } = null!; [Parameter] @@ -22,15 +22,18 @@ public partial class Giscus [Parameter] public string? CategoryId { get; set; } - [Parameter] -#if NET6_0 +#if NET6_0_OR_GREATER [EditorRequired] #endif + [Parameter] public Mapping Mapping { get; set; } = Mapping.PathName; [Parameter] public string? Term { get; set; } + [Parameter] + public bool Strict { get; set; } = false; + [Parameter] public bool ReactionsEnabled { get; set; } = true; @@ -38,7 +41,7 @@ public partial class Giscus public bool EmitMetadata { get; set; } [Parameter] - public InputPosition? InputPosition { get; set; } + public InputPosition InputPosition { get; set; } [Parameter] public string? Theme { get; set; } @@ -47,6 +50,9 @@ public partial class Giscus public string? Lang { get; set; } [Parameter] - public bool LazyLoading { get; set; } + public Loading Loading { get; set; } = Loading.Eager; + + [Parameter] + public string? Host { get; set; } = "https://giscus.app"; } } diff --git a/src/GiscusBlazor/GiscusBlazor.csproj b/src/GiscusBlazor/GiscusBlazor.csproj index 03f054e..ae6f10e 100644 --- a/src/GiscusBlazor/GiscusBlazor.csproj +++ b/src/GiscusBlazor/GiscusBlazor.csproj @@ -7,7 +7,7 @@ https://github.com/Jisu-Woniu/giscus-blazor MIT False - 2.2.1 + 2.3.0 A Blazor component to embed giscus, a comments system powered by GitHub Discussions. True snupkg diff --git a/src/GiscusBlazor/InputPosition.cs b/src/GiscusBlazor/InputPosition.cs index bf695a1..9b7ec2f 100644 --- a/src/GiscusBlazor/InputPosition.cs +++ b/src/GiscusBlazor/InputPosition.cs @@ -10,14 +10,12 @@ public enum InputPosition internal static class InputPositionExtensions { - internal static string ToPositionString(this InputPosition position) - { - return position switch + internal static string ToPositionString(this InputPosition position) => + position switch { InputPosition.Bottom => "bottom", InputPosition.Top => "top", _ => throw new ArgumentOutOfRangeException(nameof(position)) }; - } } } diff --git a/src/GiscusBlazor/Loading.cs b/src/GiscusBlazor/Loading.cs new file mode 100644 index 0000000..bab18a4 --- /dev/null +++ b/src/GiscusBlazor/Loading.cs @@ -0,0 +1,21 @@ +using System; + +namespace GiscusBlazor +{ + public enum Loading + { + Lazy, + Eager + } + + internal static class LoadingExtensions + { + internal static string ToLoadingString(this Loading loading) => + loading switch + { + Loading.Eager => "eager", + Loading.Lazy => "lazy", + _ => throw new ArgumentOutOfRangeException(nameof(loading)) + }; + } +}