Skip to content

Instantly share code, notes, and snippets.

View joelvarty's full-sized avatar
🚀
point five past light speed

Joel Varty joelvarty

🚀
point five past light speed
View GitHub Profile
@joelvarty
joelvarty / Stackpath Edge Worker Example 1
Last active March 10, 2020 17:42
Stackpath Edge Worker Example 1
// script entry point
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});
/**
* Fetch and return the request body
* @param {Request} request
*/
async function handleRequest(request) {
@joelvarty
joelvarty / App.js
Created September 6, 2019 12:55
React Routing Tutorial
import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom'
import './App.css';
//The Agility Router
import { PageRouter } from './agility-react'
//Shared Components
import GlobalHeader from './GlobalHeader'
@joelvarty
joelvarty / JumboTron.js
Created September 6, 2019 12:47
Agility Tutorial Module
import React, { Component } from 'react';
import './Jumbotron.css'
class Jumbotron extends Component {
render() {
return (
<section className="jumbotron">
<h1>{this.props.item.fields.title}</h1>
<h2>{this.props.item.fields.subTitle}</h2>
@joelvarty
joelvarty / OneColumnTemplate.js
Created September 5, 2019 16:23
React Page Template Component Example
import React, { Component } from 'react';
import { ContentZone } from '../agility-react'
class OneColumnTemplate extends Component {
render() {
return (
<div className="one-column-template">
<ContentZone name='MainContentZone' {...this.props} />
</div>
@joelvarty
joelvarty / pagerouter1.js
Last active September 6, 2019 12:40
React Page Router
async routePage() {
const api = this.props.agility.client;
try {
//get the sitemap route table
let sitemap = await this.getSitemap(api);
//get the path from the browser
const path = document.location.pathname.toLowerCase();
let pageInSitemap = sitemap[path];
@joelvarty
joelvarty / flatsitemap.json
Last active September 6, 2019 12:42
Agility CMS Sitemap Examples
{
"/home": {
"title": "Home",
"name": "home",
"pageID": 2
},
"/posts": {
"title": "Posts",
"name": "posts",
"pageID": 3
@joelvarty
joelvarty / AgilityConfig.js
Last active September 6, 2019 12:43
Agility Tutorial for react Page Templates (2)
//Our Agility Modules
import RichTextArea from './modules/RichTextArea'
import Jumbotron from './modules/Jumbotron'
//Our Agility PageTemplates
import OneColumnTemplate from './pageTemplates/OneColumnTemplate'
export default {
guid: '...', //Set your guid here
fetchAPIKey: '...', //Set your fetch apikey here
@joelvarty
joelvarty / TwoColumnTemplate.jsx
Last active August 19, 2019 19:37
Agility Tutorial for creating a react page template
import React, { Component } from 'react';
import { ContentZone } from '../agility-react'
class TwoColumnTemplate extends Component {
render() {
return (
<div className="two-column-template">
<div className="main-column">
<ContentZone name='MainContentZone' {...this.props} />
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="agilityWebsiteServiceBehavior" name="Agility.Web.AgilityWebsiteService">
        <endpoint binding="wsHttpBinding" bindingConfiguration="agilityWebsiteServiceBinding" contract="Agility.Web.IAgilityWebsiteService" />
        <endpoint binding="wsHttpBinding" bindingConfiguration="agilityWebsiteServiceBindingSSL" contract="Agility.Web.IAgilityWebsiteService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>