Skip to content

Instantly share code, notes, and snippets.

View jeromecoupe's full-sized avatar
💭
coding away

Jérôme Coupé jeromecoupe

💭
coding away
View GitHub Profile
@jeromecoupe
jeromecoupe / test_dates_matrix_native.twig
Last active May 26, 2016 10:39
Discontinuous events with multiple dates: native method with date fields and matrix
{% extends "_layouts/default" %}
{% block content %}
{#
Tackling discontinuous events without duplication
- Each event has a 'startDate' and an 'endDate' (those are just a date interval, the first date corresponds the the first occurrence of the event and the mast one corresponds to the last occurence of the events). This matching is done manually but we could also use the preparse plugin.
- Each event has got a matrix field 'timetable' with just a block 'mxBlockDate' and date field 'mxDate' for each occurence of the event
@jeromecoupe
jeromecoupe / craft_matrix_events_lowblocks.twig
Last active June 1, 2016 12:47
Implement an event calendar with Matrix: all event occurrences are stored as matrix blocks / fields
{% extends "_layouts/default" %}
{% block content %}
{#
Events just have a Matrix fields with multiple dates.
The goal is to get all dates within a certain date range, ordered by date asc
All event details should be repeated when an event occurs at multiple dates
Events are presented in a calendar view and should only appear for a given day if they have
a corresponding occurence on that day.
@jeromecoupe
jeromecoupe / gulpfile.js
Last active January 19, 2024 13:43
responsive image pipeline in Gulp
"use strict";
// ---------------------------------------
// packages
// ---------------------------------------
const del = require("del");
const deleteEmpty = require("delete-empty");
const globby = require("globby");
const gulp = require("gulp");
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active January 21, 2024 16:28
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@jeromecoupe
jeromecoupe / bitbucket-pipelines.yml
Last active August 2, 2019 11:29
Minimal Bitbucket Pipelines
# Only use spaces to indent your .yml configuration.
# $SSH_USER $ROOT_PATH $SSH_IP:$SSH_PATH are environment variables
# image
image: node:latest
# pipelines
pipelines:
default:
- step:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeromecoupe
jeromecoupe / cases.js
Last active November 18, 2019 17:12
Sort post by categories with 11ty data files
const cases = [
{
id: "123456",
title: "This is a case red blue",
categories: [
{ id: "1", slug: "red" },
{ id: "2", slug: "blue" }
]
},
{
@jeromecoupe
jeromecoupe / getnews.twig
Last active November 2, 2020 18:10
Probably not a good idea: normalize array of objects in Craft
{# variables #}
{% set allNews = [] %}
{% set today = "now"|date("Y-m-d") %}
{# create custom allNews array of objects #}
{% set news = craft.entries()
.section(["news"])
.with([
"newsImage"
])
@jeromecoupe
jeromecoupe / deploy.yaml
Last active August 2, 2023 16:41
Github actions: build and deploy Craft sites (WIP)
name: Craft CMS deployments
on:
push:
branches: [master]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
@jeromecoupe
jeromecoupe / package.json
Created December 2, 2020 10:30
Minimal NPM script Sass
{
"name": "sass-npm-scripts",
"version": "1.0.0",
"author": "Jérôme Coupé",
"description": "Minimal Sass NPM scripts",
"main": "index.js",
"scripts": {
"build:styles": "sass --style=compressed src/scss/:dist/css/",
"watch:styles": "onchange src/scss/**/*.scss -- npm run build:styles",
"watch": "npm-run-all --parallel watch:**",