This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Sitecore.Diagnostics; | |
using Sitecore.LayoutService.ItemRendering.Pipelines.GetLayoutServiceContext; | |
using System.Collections.Generic; | |
using Sitecore; | |
using Sitecore.Links; | |
namespace JSSDemo.Feature.Metadata.PipelineProcessors | |
{ | |
public class ItemContext : IGetLayoutServiceContextProcessor | |
{ | |
public const string Key = "itemUrl"; | |
public void Process(GetLayoutServiceContextArgs args) | |
{ | |
if (Context.Item != null) | |
{ | |
Assert.ArgumentNotNull((object)args, nameof(args)); | |
IDictionary<string, object> contextData = args.ContextData; | |
var options = LinkManager.GetDefaultUrlBuilderOptions(); | |
options.AlwaysIncludeServerUrl = true; | |
string link = LinkManager.GetItemUrl(Context.Item, options); | |
args.ContextData.Add(Key, link); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment