From 00ec9fe783b59a94eb2973587fad6d72f2525094 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Wed, 2 Oct 2024 16:59:21 +1000 Subject: [PATCH] Bumped SDK version, implemented Navigation Component (#8) This PR increases the version of the SDK used to v0.0.9 - in order to leverage the new `CustomComponent` binding functionality. This functionality is used to implement the `Navigation` component included here. ## Description / Motivation Implementation of the Navigation component now means that the Skate Park template is now completely supported. ## Terms - [x] I agree to follow this project's [Code of Conduct](CODE_OF_CONDUCT.md). Closes #2 --- README.md | 2 -- headapps/Directory.Packages.props | 2 +- .../Extensions/ServiceCollectionExtensions.cs | 6 ++++-- .../Models/Navigation/Navigation.cs | 20 +++++++++++++++++++ .../Models/Navigation/NavigationItem.cs | 19 ++++++++++++++++++ .../SitecoreComponent/Navigation.cshtml | 15 ++++++++++++++ .../SitecoreComponent/_NavigationMenu.cshtml | 18 +++++++++++++++++ 7 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 headapps/aspnet-core-starter/Models/Navigation/Navigation.cs create mode 100644 headapps/aspnet-core-starter/Models/Navigation/NavigationItem.cs create mode 100644 headapps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/Navigation.cshtml create mode 100644 headapps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/_NavigationMenu.cshtml diff --git a/README.md b/README.md index 7238278..9b391e8 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,8 @@ This repository contains the ASP.NET Core Starter Kit for Sitecore XM Cloud Deve > This is a pre-release version of the starter kit and is built against the pre-release version of the ASP.NET Core SDK. As such, there may be some issues with the project that are not yet resolved. If you encounter any issues, please report them in the [Issues](https://github.com/Sitecore/xmcloud-starter-aspnetcore/issues) section of the repo. The following are known issues that are being worked on: -- **Navigation Component** - The OOTB Navigation component provided by XM Cloud currently isn't supported. This is being worked on and will be available in a future release. If you add the component to a page it can break deserialisation of the layout object and stop the page from rendering. In that scenario you will need to remove the component via the Content Editor. **Due to this reason the Skate Park Template is not currently supported, unless you manually remove the Navigation component from the Header Partial Design.** - **Front End as a Service (FEaaS)** - The FEaaS components are not yet available in the pre-release version of the Starter Kit. - **Forms** - The Forms components are not yet available in the pre-release version of the Starter Kit. -- **Skate Park** - The Skate Park Template is currently only partially supported. For it to run you need to manually remove the `Navigation` component from the Header Partial Design. This is due to the Navigation component not being supported yet, as per the comment above. ## GitHub Template This Github repository is a template that can be used to create your own repository. To get started, click the `Use this template` button at the top of the repository. diff --git a/headapps/Directory.Packages.props b/headapps/Directory.Packages.props index 6feea94..5b0eea9 100644 --- a/headapps/Directory.Packages.props +++ b/headapps/Directory.Packages.props @@ -1,6 +1,6 @@ - 0.0.7 + 0.0.9 true diff --git a/headapps/aspnet-core-starter/Extensions/ServiceCollectionExtensions.cs b/headapps/aspnet-core-starter/Extensions/ServiceCollectionExtensions.cs index b846bf1..996612f 100644 --- a/headapps/aspnet-core-starter/Extensions/ServiceCollectionExtensions.cs +++ b/headapps/aspnet-core-starter/Extensions/ServiceCollectionExtensions.cs @@ -1,5 +1,6 @@ using Sitecore.AspNetCore.SDK.RenderingEngine.Configuration; using Sitecore.AspNetCore.Starter.Models.LinkList; +using Sitecore.AspNetCore.Starter.Models.Navigation; using Sitecore.AspNetCore.Starter.Models.Title; namespace Sitecore.AspNetCore.Starter.Extensions; @@ -17,8 +18,9 @@ public static RenderingEngineOptions AddStarterKitViews(this RenderingEngineOpti .AddModelBoundView("Promo") .AddModelBoundView("LinkList") .AddModelBoundView("Image") - .AddModelBoundView("PartialDesignDynamicPlaceholder"); - + .AddModelBoundView("PartialDesignDynamicPlaceholder") + .AddModelBoundView("Navigation"); + return renderingEngineOptions; } } \ No newline at end of file diff --git a/headapps/aspnet-core-starter/Models/Navigation/Navigation.cs b/headapps/aspnet-core-starter/Models/Navigation/Navigation.cs new file mode 100644 index 0000000..e263968 --- /dev/null +++ b/headapps/aspnet-core-starter/Models/Navigation/Navigation.cs @@ -0,0 +1,20 @@ +using Sitecore.AspNetCore.SDK.LayoutService.Client.Serialization.Converter; +using Sitecore.AspNetCore.SDK.RenderingEngine.Binding.Attributes; + +namespace Sitecore.AspNetCore.Starter.Models.Navigation; + +public class Navigation : BaseModel +{ + public Navigation() { } + + public Navigation(List? navigationItems, int? menuLevel) + { + NavigationItems = navigationItems; + MenuLevel = menuLevel; + } + + [SitecoreComponentField(Name = FieldParser.CustomContentFieldKey)] + public List? NavigationItems { get; set; } + + public int? MenuLevel { get; set; } +} \ No newline at end of file diff --git a/headapps/aspnet-core-starter/Models/Navigation/NavigationItem.cs b/headapps/aspnet-core-starter/Models/Navigation/NavigationItem.cs new file mode 100644 index 0000000..ce95150 --- /dev/null +++ b/headapps/aspnet-core-starter/Models/Navigation/NavigationItem.cs @@ -0,0 +1,19 @@ +using Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model.Fields; + +namespace Sitecore.AspNetCore.Starter.Models.Navigation +{ + public class NavigationItem + { + public string? Id { get; set; } + + public List? Styles { get; set; } = []; + + public List? Children { get; set; } = []; + + public string? Href { get; set; } + + public string? QueryString { get; set; } + + public TextField? NavigationTitle { get; set; } + } +} \ No newline at end of file diff --git a/headapps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/Navigation.cshtml b/headapps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/Navigation.cshtml new file mode 100644 index 0000000..60ec4c9 --- /dev/null +++ b/headapps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/Navigation.cshtml @@ -0,0 +1,15 @@ +@using Sitecore.AspNetCore.Starter.Models.Navigation +@model Sitecore.AspNetCore.Starter.Models.Navigation.Navigation + +