Skip to content

Instantly share code, notes, and snippets.

@bramus
bramus / bookmarklet.md
Last active August 3, 2023 16:56
Mastodon User Page Bookmarklet
@daltonrooney
daltonrooney / contentModule.gql
Last active May 15, 2023 23:24
Craft CMS GraphQL matrix shared fragment example
import gql from 'graphql-tag'
import { print } from 'graphql/language/printer'
import richTextFragment from './contentModules/richText.gql'
import logoBlockFragment from './contentModules/logoBlock.gql'
import embedBlockFragment from './contentModules/embedBlock.gql'
import videoBlockFragment from './contentModules/videoBlock.gql'
import imageCollageFragment from './contentModules/imageCollage.gql'
import imageGridFragment from './contentModules/imageGrid.gql'
import slideshowBlockFragment from './contentModules/slideshowBlock.gql'
import singleImageFragment from './contentModules/singleImage.gql'
@johndturn
johndturn / PostLeads.md
Last active April 25, 2024 14:17
Post Leads to SFDC via JavaScript Fetch API and a Web-to-Lead form.

Post Leads to SFDC via JS Fetch API & Web-to-Lead

When working with Web-to-Lead forms, you might run into a situation where you'd like to integrate the form with your frontend framework (React, Vue, Angular, etc...). This can be accomplished quite easily using whatever HTTP library you're most comfortable with.

To demonstrate this, let's take a look at an example Web-to-Lead form, and the JavaScript required to post Leads to a SFDC org.

Example Form

<html lang="en">
<?php
use craft\elements\db\EntryQuery;
use craft\elements\Entry;
use modules\appmodule\transformers\ProductTransformer;
use rias\scout\IndexSettings;
use rias\scout\ScoutIndex;
use Tightenco\Collect\Support\Collection;
$indexPrefix = getenv('ALGOLIA_INDEX_PREFIX') ?: CRAFT_ENVIRONMENT . '_';
@monachilada
monachilada / .gitlab-ci.yml
Created October 10, 2019 08:05
Gitlab pipeline for running Craft/gatsby side by side on the same server to enable live preview.
include: 'https://gitlab.com/gitlab-cd/ssh-template/raw/master/ssh.yml'
# Install build dependencies.
.build:
image: node:12.8
variables:
YARN_CACHE_DIR: '.ci/yarn-cache'
script:
# Some build dependencies
@monachilada
monachilada / gatsby-config.js
Last active October 16, 2020 19:03
Sample gatsby-config.js enabling live preview in Craft CMS
const { createHttpLink } = require('apollo-link-http');
const fetch = require('node-fetch');
const store = require('store');
const sourceNodes = require('gatsby/dist/utils/source-nodes');
require('dotenv').config();
const craftGqlUrl = process.env.CRAFT_GQL_URL;
const craftGqlToken = process.env.CRAFT_GQL_TOKEN;
module.exports = {
@croxton
croxton / google_cloud_storage_craft_3.md
Last active September 24, 2022 07:31
How to provision Google Cloud Storage buckets for Craft CMS 3.x

Create the bucket

  1. Open the console https://console.cloud.google.com
  2. If you haven't already, setup your Cloud billing account
  3. From the drop down at the top of the screen, create new project for your client, e.g. my-client
  4. Make a note of the Project number on the project Home screen (Craft refers to this as the Project ID)
  5. In the sidebar go to APIs & Services > Credentials, click the + Create credentials button and choose the Service Account type
  • Set account name to craft-cms or similar
  • Set role to Owner
  • Save
  1. Click on the newly created service account email to edit it, then click the Keys tab and click Add key > Create new key and select the JSON format
@jakedohm
jakedohm / gridsome.server.js
Last active April 24, 2020 20:42
Gridsome (0.6) + Craft CMS Integration
// Server API makes it possible to hook into various parts of Gridsome
// on server-side and add custom data to the GraphQL data layer.
// Learn more: https://gridsome.org/docs/server-api
// Changes here requires a server restart.
// To restart press CTRL + C in terminal and run `gridsome develop`
const { setContext } = require('apollo-link-context')
const { HttpLink } = require('apollo-link-http')
const {
@ademilter
ademilter / .storybook
Last active September 7, 2021 12:11
postcss config for storybook
- webpack.config.js
- postcss.config.js
- config.js
- addons.js