rework oembed, because he didn`t work as well

This commit is contained in:
Дмитрий Шиманский
2023-10-22 13:10:43 +03:00
parent 5471ad08ba
commit b3b570f56e
4 changed files with 27 additions and 37 deletions

View File

@@ -1,52 +1,22 @@
using Microsoft.Extensions.Options;
using HeyRed.OEmbed;
using HeyRed.OEmbed.Providers;
namespace yaflay.ru
{
public class Startup
{
private readonly IConfiguration configuration;
private readonly OEmbedOptions options;
public Startup()
{
configuration = new ConfigurationBuilder()
.AddEnvironmentVariables(prefix: "m.")
.AddJsonFile("appsettings.json", optional: true)
.Build();
options = new OEmbedOptions()
{
EnableCache = true
};
}
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddRouting();
services.AddRazorPages();
services.AddOEmbed(options =>
{
options.EnableCache = true; // true by default
options.EnsureNotNull();
})
.ClearProviders()
.AddProvider<YoutubeProvider>()
.AddProvider<YandexMusicProvider>()
.AddProvider<FlickrProvider>()
.AddProvider<TwitterProvider>(options =>
{
options.Parameters = new Dictionary<string, string?>
{
["theme"] = "dark"
};
})
.AddProvider<FacebookProvider>(options =>
{
options.Parameters = new Dictionary<string, string?>
{
["access_token"] = "app_id|token"
};
});
services.AddMvc()
.AddRazorPagesOptions(options =>
{