Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2021 03:52
What would you like to do?
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