Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
)
@jamesvidler
jamesvidler / AbbreviatedMasterPageAgilityConfig.js
Created May 2, 2020 16:24
An abbreviated snippet showing the gatsby-config for an Agility masterpage
module.exports = {
siteMetadata: {
title: "Agility CMS Gatsby Starter",
},
plugins: [
...
{
//the name of the plugin
resolve: "@agility/gatsby-source-agilitycms",
//the options for our plugin
@jamesvidler
jamesvidler / GatsbyAgilityPage.jsx
Created May 2, 2020 16:22
Sample AgilityPage.js for Gatsby
import React from 'react'
import { graphql } from "gatsby"
import agilityUtils from './agility/utils'
import AgilityPageTemplate from './agility/components/AgilityPageTemplate'
//Some things we need for our layout
import LayoutTemplate from "./components/LayoutTemplate"
import PreviewBar from "./components/PreviewBar"
import GlobalHeader from './components/GlobalHeader'
import SEO from './components/SEO'
@jamesvidler
jamesvidler / search-conversion-example.js
Created September 23, 2019 20:20
An example conversion method for the Agility CMS Search
Agility.Search.Conversion({
url: 'https://www.agilitycms.com/products/agility-search'
}).success(function(resp){
//success
}).error(function(err){
//error
}).always(function(){
//always
});
@jamesvidler
jamesvidler / search-grouped-query-example.js
Created September 23, 2019 20:19
How to execute a grouped query using Agility CMS Search.
Agility.Search.GroupedQuery({
query: 'agility',
languageCode: 'en-ca', //optional
top: 5, //optional
domain: 'agilitycms.com', //optional
groupCount: 3 //optional
}).success(function(resp){
//success
}).error(function(err){
//error
@jamesvidler
jamesvidler / search-autocomplete-example.js
Created September 23, 2019 20:16
An example of calling the Search API to get auto-complete results
Agility.Search.AutoComplete({
query: 'agility',
languageCode: 'en-ca', //optional
domain: 'www.site.com', //optional
category: 'product', // optional
top: 100, //optional
fuzzy: true //optional
}).success(function(resp){
//success
}).error(function(err){
@jamesvidler
jamesvidler / search-query-example.js
Last active September 23, 2019 20:13
How to execute a search query with Agility CMS
Agility.Search.Query({
query: 'agility',
languageCode: 'en-ca', //optional
category: 'product', // optional
domain: 'agilitycms.com', //optional
top: 100, //optional
skip: 0 //optional
})
.success(function(resp){
//success
@jamesvidler
jamesvidler / ImageLink.jsx
Created August 19, 2019 21:27
A sample React module powered by Agility CMS
@jamesvidler
jamesvidler / get-sitemap-flat.curl
Last active January 22, 2021 18:44
Get a sitemap in a flat format, ideal for page routing from Agility CMS.
curl https://046a1a87-api.agilitycms.cloud/fetch/en-us/sitemap/flat/website
--header "APIKey: defaultlive.2b7f3a91559d794bedb688358be5e13af2b1e3ae8cd39e8ed2433bbef5d8d6ac"
{
"/home": {
"title": "Home",
"name": "home",
"pageID": 2,
"menuText": "New Home Text",
"visible": {
"menu": false,
@jamesvidler
jamesvidler / get-page.curl
Last active August 19, 2019 20:56
Get a page using the Content Fetch API
curl https://046a1a87-api.agilitycms.cloud/fetch/en-us/page/2
--header "APIKey: defaultlive.2b7f3a91559d794bedb688358be5e13af2b1e3ae8cd39e8ed2433bbef5d8d6ac"
{
"pageID": 2,
"name": "home",
"path": null,
"title": "Home",
"menuText": "New Home Text",
"pageType": "static",
"templateName": "One Column Template",