Skip to content

Instantly share code, notes, and snippets.

View vitaliitylyk's full-sized avatar

Vitalii Tylyk vitaliitylyk

View GitHub Profile
@vitaliitylyk
vitaliitylyk / DescendantsTreeRenderingContentsResolver.cs
Last active June 20, 2019 12:43
A custom Sitecore JSS rendering contents resolver, which serializes items into a tree-like JSON structure. More information at https://blog.vitaliitylyk.com/jss-and-arbitrary-item-hierarchies/
using Newtonsoft.Json.Linq;
using Sitecore.Data.Items;
using Sitecore.LayoutService.Configuration;
namespace VitaliiTylyk.JavascriptServices.RenderingContentsResolvers
{
/// <summary>
/// Builds a tree-like structure of datasource item's descendants
/// </summary>
public class DescendantsTreeRenderingContentsResolver : Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver
@vitaliitylyk
vitaliitylyk / GraphQLCombinedResolver.cs
Last active September 1, 2020 11:19
A custom Sitecore JSS rendering contents resolver, which appends results of a GraphQL query defined on a rendering item to LayoutService output. This allows to execute both Rendering Contents Resolver logic and integrated GraphQL query. More information at https://blog.vitaliitylyk.com/combining-integrated-graphql-and-rendering-contents-resolver…
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using Sitecore.JavaScriptServices.GraphQL.LayoutService;
using Sitecore.LayoutService.Configuration;
using Sitecore.LayoutService.ItemRendering.ContentsResolvers;
using Sitecore.Mvc.Presentation;
using System;
namespace VitaliiTylyk.JavascriptServices.RenderingContentsResolvers
{
@vitaliitylyk
vitaliitylyk / TailSitecoreLogs.ps1
Last active October 15, 2019 08:31
The script is tailing Sitecore log files to the attached console. It is meant to be used within an entry point in Docker container.
<#
.SYNOPSIS
Tails Sitecore logs to Docker console (STDOUT).
.PARAMETER LogsFolder
Path to a folder where Sitecore logs are located.
.PARAMETER Filter
Log file name filter. Can contain wildcards "*".
@vitaliitylyk
vitaliitylyk / EnvironmentVariablesConfigReader.cs
Last active February 6, 2020 10:01
Custom Sitecore configuration section handler, which allows to inject environment variables to Sitecore settings, sc.variables and site settings. More information here: https://blog.vitaliitylyk.com/sitecore-environment-variables-config-builder/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
namespace VitaliiTylyk.Configuration
{
/// <summary>
/// Allows to implicitly replace values in sitecore/settings and sitecore/sites section from
/// environment variables. This is mimicking the behaviour of ASP.NET Configuration Builders (https://docs.microsoft.com/en-us/aspnet/config-builder).
@vitaliitylyk
vitaliitylyk / ApiHealthCheck.cs
Last active July 13, 2020 13:29
A custom health check which checks internal API endpoints. More information: https://blog.vitaliitylyk.com/sitecore-9-3-health-checks/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Sitecore.Abstractions;
namespace HealthChecks