Skip to content

Instantly share code, notes, and snippets.

jbreuer / FeedbackController.cs
Created April 4, 2024 15:01
Umbraco UI Builder + Web API
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPoco;
using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations;
using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Web.Common.Controllers;
namespace UmbracoProject;
public class FeedbackController : UmbracoApiController
jbreuer / CustomApiMediaUrlProvider.cs
Created August 30, 2023 15:01
Umbraco Content Delivery API changes
using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
namespace UmbracoProject;
public class CustomApiMediaUrlProvider : IApiMediaUrlProvider
private readonly IPublishedUrlProvider _publishedUrlProvider;
jbreuer / RouteHandler.js
Last active November 1, 2022 16:47
Show a loader while navigating on a single-page application (SPA) with Sitecore JSS and React
import React from 'react';
import i18n from 'i18next';
import Helmet from 'react-helmet';
import TopLoader from 'react-top-loader';
import { isEditorActive, withSitecoreContext } from '@sitecore-jss/sitecore-jss-react';
import { layoutServiceFactory } from './lib/layout-service-factory';
import config from './temp/config';
import Layout from './Layout';
import NotFound from './NotFound';
jbreuer / ProjectIdentityProvider.cs
Last active June 22, 2021 06:43
Custom identity provider in Sitecore
public class ProjectIdentityProvider : IdentityProvidersProcessor
private readonly IConfigurationRepository configurationRepository;
private readonly IUrlUtils urlUtils;
private readonly ICookieManager cookieManager;
public ProjectIdentityProvider(
IConfigurationRepository configurationRepository,
jbreuer / HybridPlaceholder.jsx
Last active July 22, 2021 13:17
Hybrid Placeholder
import React, { useEffect, useState } from 'react';
import { withSitecoreContext, dataApi, Placeholder } from '@sitecore-jss/sitecore-jss-react';
import { dataFetcher } from './dataFetcher';
import config from './temp/config';
const HybridPlaceholder = ({
}) => {
jbreuer / ContentExtensions.cs
Created May 18, 2016 14:59
An extension method to convert an IContent to an IPublishedContent.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ContentExtensions.cs" company="Colours B.V.">
// © Colours B.V. 2015
// </copyright>
// <summary>
// The content extensions.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Project.Web.Core.Extensions
jbreuer / gist:e4103c4d731fe3fdb275
Created July 16, 2015 12:53
Would be cool if this could work for Nested Content
var items = this.GetPropertyValue<IEnumerable<IPublishedContent>>("sliderNestedContent");
//Slider is a generated model based on a document type.
//Currently x as Slider returns null.
return items.Select(x => x as Slider);
jbreuer / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
jbreuer / gist:0a5996e5e6bf881ce847
Last active December 31, 2018 05:24
Archetype and Nested Content as Models Builder properties
public IEnumerable<HomeSlider> Slider
var archetypeModel = this.GetPropertyValue<ArchetypeModel>("slider");
return archetypeModel.Select(x =>
return new HomeSlider()
jbreuer / gist:a396f1e4504e181e1c8a
Created November 20, 2014 10:51
Strongly typed querying in Umbraco
/// <summary>
/// Return the all the data required for filtering and displaying object types.
/// </summary>
/// <returns></returns>
public static IEnumerable<ObjectTypeItem> GetObjectTypeItems()
//Get the node where all projects and object types are below.
var projectOverview = Umbraco.TypedContent(ConfigurationManager.AppSettings["projectOverviewId"]);