This plugin renders the Open Graph tags.
-
Set environment variables for GitHub NuGet Package Registry.
# zsh/bash export GH_PACKAGE_USERNAME="<GITHUB_USERNAME>" export GH_PACKAGE_TOKEN="<GITHUB_TOKEN>"
# PowerShell $env:GH_PACKAGE_USERNAME = "<GITHUB_USERNAME>" $env:GH_PACKAGE_TOKEN = "<GITHUB_TOKEN>"
-
Assuming that you've got a running ScissorHands.NET app.
-
Update the plugin section of
appsettings.jsonto add options.TwitterSiteIdis the Twitter handle for the website, andTwitterCreatorIdis the default Twitter handle for the content authors.NOTE: If you don't have any of both, you can omit the property. For example, you can omit both properties like
"Options": {}. -
Add a NuGet package.
dotnet add package ScissorHands.Plugin.OpenGraph --prerelease
-
Add a UI component,
<OpenGraphComponent />with parameters, toMainLayout.razor.<OpenGraphComponent Documents="@Documents" Document="@Document" Plugin="@OpenGraphPlugin" Theme="@Theme" Site="@Site" /> @code { protected PluginManifest? OpenGraphPlugin { get; set; } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); OpenGraphPlugin = Plugins?.SingleOrDefault(p => p.Name!.Equals("Open Graph", StringComparison.OrdinalIgnoreCase)); } }
NOTE: Those
@Documents,@Document,@Themeand@Sitevalues are inherited, and the@OpenGraphPluginvalue is calculated from theOnInitializedAsync()method. -
Alternatively, use the placeholder,
<plugin:open-graph />instead of the<OpenGraphComponent />component.<html> <head> ... <plugin:open-graph /> ... </head>
{ ... "Plugins": [ { "Name": "Open Graph", "Options": { "TwitterSiteId": "@your_twitter_handle_site", "TwitterCreatorId": "@your_twitter_handle_creator" } } ] }