Skip to content

Instantly share code, notes, and snippets.

View tech4him1's full-sized avatar

Caleb tech4him1

View GitHub Profile
@tech4him1
tech4him1 / umd-code.js
Created September 18, 2018 15:28
UMD differences between rollup and webpack
function webpack(global, factory) {
if (typeof exports === "object" && typeof module === "object") {
module.exports = factory();
} else if (typeof define === "function" && define.amd) {
define("netlify-cms", [], factory);
} else if (typeof exports === "object") {
exports["netlify-cms"] = factory();
} else {
global["netlify-cms"] = factory();
}
@tech4him1
tech4him1 / README.md
Last active March 30, 2023 13:41
Netlify CMS w/ Git Gateway on external hosting.

Using Netlify's hosted Identity and Git Gateway service with Netlify CMS when hosted on a separate service.

CMS config.yml changes

The backend section of your config should contain the following three keys. Replace www.my-netlify-site.com with your Netlify site URL.

backend:
  name: git-gateway
 identity_url: "https://www.my-netlify-site.com/.netlify/identity"
@tech4him1
tech4him1 / creating-backend.md
Created August 23, 2018 22:08
Netlify CMS v2.0 backend methods.
title weight group
Creating a CMS Backend
30
reference

Netlify CMS exposes a window.CMS global object that you can use to register custom backends. The same object is also the default export if you import Netify CMS as an npm module. The available backend extension methods are:

  • registerBackend: lets you register a custom backend. The CMS expects you to pass it an ES6 class or other object which it can call new BackendClass() on.
@tech4him1
tech4him1 / backends.md
Last active August 5, 2018 18:53
Netlify CMS v2.0 backend expected methods

Legacy (current) API

constructor

Set up backend class based on user configuration.

constructor(config, { useWorkflow, updateUserCredentials, initialWorkflowStatus })

  • config (Map): entire CMS config file
  • useWorkflow (boolean): if editorial workflow is enabled
  • updateUserCredentials (function): updates cached credentials (if user data or token is updated)
  • initialWorkflowStatus (constant): editorial workflow status for new posts
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page Not found</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<style>
* {
-webkit-box-sizing: border-box;
@tech4him1
tech4him1 / config.yml
Last active April 20, 2018 16:52 — forked from jevenson/config.yml
Netlify CMS Bug Report
page_default_fields:
- label: Page Title
name: pageTitle
widget: string
home_page_fields:
- label: Layout
name: layout
widget: hidden
default: home.hbs
- label: Title
@tech4him1
tech4him1 / sha256random.js
Last active April 18, 2018 00:44
Generate random SHA256 look-alike.
const hashlen = 256;
const hashbase = 16;
const randomNums = new Uint32Array(hashlen / 32);
window.crypto.getRandomValues(randomNums);
const padNum = (num, base) => {
const padLen = (32 / Math.sqrt(base));
const str = num.toString(base);
return (('0' * padLen) + str).slice(-padLen);
backend:
name: git-gateway
media_folder: "site/static/img" # Folder where user uploaded files should go
public_folder: "img"
collections: # A list of collections the CMS should be able to edit
- label: "Content"
name: "content"
folder: "site/content/content" # The path to the folder where the documents are stored
@tech4him1
tech4him1 / filter.sh
Created April 6, 2018 15:50
Filter WordPress resized images
find uploads -regex ".*[0-9]+x[0-9]+\...?.?.?"
import {hot} from 'react-hot-loader';
export default hot(module)(
<Provider store={store}>
<Router>
<div>This is a test.</div>
</Router>
</Provider>
);