Skip to content

Commit

Permalink
Merge pull request #29 from rbaconsulting/v10.3.0-upgrade
Browse files Browse the repository at this point in the history
Updating package to 10.3.0
  • Loading branch information
gilbertaoe committed May 27, 2023
2 parents 923a63e + 8793b6b commit 420dd06
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 33 deletions.
4 changes: 2 additions & 2 deletions SXA.Theme.Optimizations/SXA.Theme.Optimizations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Sitecore.Mvc" Version="9.3.0">
<PackageReference Include="Sitecore.Mvc" Version="10.3.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Sitecore.XA.Foundation.Theming" Version="9.3.0">
<PackageReference Include="Sitecore.XA.Foundation.Theming" Version="10.3.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
77 changes: 48 additions & 29 deletions SXA.Theme.Optimizations/Views/SxaLayout/SxaLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
@using Sitecore.XA.Foundation.MarkupDecorator.Extensions
@using Sitecore.XA.Foundation.SitecoreExtensions.Extensions
@using Sitecore.XA.Foundation.Grid.Extensions
@using Sitecore.XA.Foundation.Theming
@using Sitecore.XA.Foundation.Theming.Bundler
@using Sitecore.XA.Foundation.Theming.Configuration
@using Sitecore.XA.Foundation.Theming.Models
@using Sitecore.XA.Foundation.Theming.Services
@using Microsoft.Extensions.DependencyInjection
@using Sitecore.DependencyInjection
@using SXA.Theme.Optimizations.Extensions
@model Sitecore.Mvc.Presentation.RenderingModel
@{
var assetConfiguration = AssetConfigurationReader.Read();
var assetLinks = AssetLinksGenerator.GenerateLinks(new ThemesProvider());
var assetConfiguration = AssetConfigurationReader.Read();
var assetLinks = AssetLinksGenerator.GenerateLinks(new ThemesProvider());
var includes = ServiceLocator.ServiceProvider.GetService<IHTMLIncludesService>().GetHTMLIncludes();
}

<!DOCTYPE html>
Expand All @@ -21,32 +24,48 @@
<html class="no-js" lang="@Model.Item.Language.Name">
<!--<![endif]-->
<head>
@if (assetConfiguration.RequestAssetsOptimizationDisabled || Sitecore.Context.PageMode.IsExperienceEditor)
{
foreach (string script in assetLinks.Scripts)
{
@Html.Raw(script)
}
}
else
{
<script async src="@ThemeExtensions.GetSXAThemeOptimizationsScript()"></script>
}

@foreach (string style in assetLinks.Styles)
{
@Html.Raw(style.Replace("rel=\"stylesheet\"", "rel=\"preload\" as=\"style\""))
@Html.Raw(style)
}

@Html.Sxa().VisitorIdentification()
@Html.Sxa().Placeholder("head")
@if (assetConfiguration.RequestAssetsOptimizationDisabled || Sitecore.Context.PageMode.IsExperienceEditor)
{
@foreach (string include in assetLinks.Scripts)
{
@Html.Raw(include)
}
}
else
{
<script async src="@ThemeExtensions.GetSXAThemeOptimizationsScript()"></script>
}

@foreach (string style in assetLinks.Styles)
{
@Html.Raw(style.Replace("rel=\"stylesheet\"", "rel=\"preload\" as=\"style\""))
@Html.Raw(style)
}

@foreach (var include in includes.Head)
{
@Html.Raw(include.HTML)
}

@Html.Sxa().VisitorIdentification()
@Html.Sxa().Placeholder("head")
</head>
<body @Html.Sxa().Body().Decorate()>
@Html.Sitecore().Placeholder("body-top")
<body @Html.Sxa().Body().Decorate()>
@Html.Sitecore().Placeholder("body-top")

@foreach (var include in includes.BodyTop)
{
@Html.Raw(include.HTML)
}

@Html.Sxa().GridBody()

@Html.Sxa().GridBody()
@Html.Sitecore().Placeholder("body-bottom")

@Html.Sitecore().Placeholder("body-bottom")
</body>
@foreach (var include in includes.BodyBottom)
{
@Html.Raw(include.HTML)
}
<!-- /#wrapper -->
</body>
</html>
23 changes: 21 additions & 2 deletions SXA.Theme.Optimizations/Views/SxaLayout/SxaLayout.cshtml.original
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
@using Sitecore.XA.Foundation.SitecoreExtensions.Extensions
@using Sitecore.XA.Foundation.Grid.Extensions
@using Sitecore.XA.Foundation.Theming.Bundler
@using Sitecore.XA.Foundation.Theming.Models
@using Sitecore.XA.Foundation.Theming.Services
@using Microsoft.Extensions.DependencyInjection
@using Sitecore.DependencyInjection

@model Sitecore.Mvc.Presentation.RenderingModel

@{
AssetLinks assetLinks = AssetLinksGenerator.GenerateLinks(new ThemesProvider());
HTMLIncludes includes = ServiceLocator.ServiceProvider.GetService<IHTMLIncludesService>().GetHTMLIncludes();
}

<!DOCTYPE html>
Expand All @@ -23,16 +28,30 @@
{
@Html.Raw(style)
}

@foreach (var include in includes.Head)
{
@Html.Raw(include.HTML)
}

@Html.Sxa().VisitorIdentification()
@Html.Sxa().Placeholder("head")
</head>
<body @Html.Sxa().Body().Decorate()>
@Html.Sitecore().Placeholder("body-top")
@foreach (var include in includes.BodyTop)
{
@Html.Raw(include.HTML)
}
@Html.Sxa().GridBody()
@Html.Sitecore().Placeholder("body-bottom")
@foreach (string script in assetLinks.Scripts)
@foreach (var include in includes.BodyBottom)
{
@Html.Raw(include.HTML)
}
@foreach (string include in assetLinks.Scripts)
{
@Html.Raw(script)
@Html.Raw(include)
}
<!-- /#wrapper -->
</body>
Expand Down

0 comments on commit 420dd06

Please sign in to comment.