Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public class SustainabilityContentApp : IContentAppFactory
if (!(source is IContent))
return null;

var content = (IContent)source;

// Only show app on content items with template
if (content.TemplateId is null)
return null;

return new ContentApp
{
Alias = "sustainabilityCheck",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Reflection;
using System.Text.Json;
using Microsoft.Extensions.Options;
using Microsoft.Playwright;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Community.Sustainability.Models;

namespace Umbraco.Community.Sustainability.Services
Expand All @@ -12,6 +14,13 @@ public interface ISustainabilityService

public class SustainabilityService : ISustainabilityService
{
private readonly WebRoutingSettings _webRoutingSettings;

public SustainabilityService(IOptionsMonitor<WebRoutingSettings> webRoutingSettings)
{
_webRoutingSettings = webRoutingSettings.CurrentValue;
}

public async Task<SustainabilityResponse> GetSustainabilityData(string url)
{
using var playwright = await Playwright.CreateAsync();
Expand All @@ -25,7 +34,7 @@ public async Task<SustainabilityResponse> GetSustainabilityData(string url)
// Add our script to report data
await page.AddScriptTagAsync(new PageAddScriptTagOptions()
{
Url = "/App_Plugins/Umbraco.Community.Sustainability/js/resource-checker.js",
Url = $"{_webRoutingSettings.UmbracoApplicationUrl}/App_Plugins/Umbraco.Community.Sustainability/js/resource-checker.js",
Type = "module"
});

Expand Down