Skip to content

Instantly share code, notes, and snippets.

View alexshyba's full-sized avatar
🏀

Alex Shyba alexshyba

🏀
View GitHub Profile
@alexshyba
alexshyba / counter.jsx
Created February 7, 2016 21:39
Counter component
var Counter = React.createClass({
getInitialState: function() {
return {secondsElapsed: 0};
},
tick: function() {
this.setState({secondsElapsed: this.state.secondsElapsed + 1});
},
componentDidMount: function() {
this.interval = setInterval(this.tick, 1000);
},
@alexshyba
alexshyba / ContextItemChildrenRenderingContentsResolver.cs
Created November 20, 2017 18:20
Sample IRenderingContentsResolver implementations.
using Newtonsoft.Json.Linq;
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.LayoutService.Configuration;
using Sitecore.LayoutService.ItemRendering;
using Sitecore.Links;
using Sitecore.Mvc.Presentation;
namespace Nomad.Jss.CodeFirst.ItemRendering
@alexshyba
alexshyba / sym2018-talk-links.md
Last active October 15, 2018 22:06
links from my Sitecore Symposium 2018 talk on Experience the development workflow of your dreams with modern JavaScript and Sitecore JSS
@alexshyba
alexshyba / CustomHead.tsx
Created November 9, 2020 19:32
Disabling Next.js scripts, `NEXT_DATA` and React rehydration
import React from 'react';
import { Head } from 'next/document';
import { cleanAmpPath } from 'next/dist/next-server/server/utils'
function getOptionalModernScriptVariant(path: string) {
if (process.env.__NEXT_MODERN_BUILD) {
return path.replace(/\.js$/, '.module.js')
}
return path
}