Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@parrya
Created October 22, 2021 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parrya/0b3f6aae504ca4bea5b51312aed5ceda to your computer and use it in GitHub Desktop.
Save parrya/0b3f6aae504ca4bea5b51312aed5ceda to your computer and use it in GitHub Desktop.
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