Skip to content

Instantly share code, notes, and snippets.

View foobartel's full-sized avatar

Holger Bartel foobartel

View GitHub Profile
@foobartel
foobartel / config.php
Created May 31, 2022 02:09
Kirby Route Example - New homepage, other pages to 404
'routes' => [
[
'home' => 'other-page'
'pattern' => ['notes', 'notes/(:any)'],
'action' => function() {
if (! kirby()->user()) {
go('error');
}
$this->next();
}
@foobartel
foobartel / copy-content-dir.sh
Created March 22, 2022 03:35
Copy Kirby Content Folder to keep Develop updated with production
#!/bin/sh
scp -R /server/path/to/production/tld/content /server/path/to/develop/tld/content
@foobartel
foobartel / .htaccess
Created December 13, 2021 03:54
Apache .htaccess Redirect
<IfModule mod_rewrite.c>
# 301 REDIRECT HTTP TO HTTPS and WWW TO NON-WWW
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
</IfModule>
@foobartel
foobartel / README
Created December 9, 2021 08:58
Create Kirby pages from CSV file
# csv2file
This script converts the content of a CSV file into a folder structure with TXT files as their content ready to use in Kirby.
# Example Input/Output
**CSV file input:**
`field1; field2; field3; field4`
@foobartel
foobartel / config.php
Last active August 15, 2021 08:54
Kirby 3 Image Block with support for webp, avif and native lazy loading
# Add to Kirby configuration
# avif image format currently only works with the ImageMagick driver
return [
'thumbs' => [
'driver' => 'im',
],
]
@foobartel
foobartel / image.php
Created June 26, 2020 07:20
Kirby 3 Editor - Resize images in Editor snippet
<?php if( $block->isNotEmpty() ): ?>
<figure<?= attr( [ 'class' => $attrs->css()->value() ], ' ' ) ?>>
<?php if( $attrs->id()->toFile() ): ?>
<?php $imagesrc = $attrs->id()->toFile()->resize( 1200, null, 60 )->url(); ?>
<?php else: ?>
<?php $imagesrc = $src ?>
<?php endif ?>
<?php if( $attrs->link()->isNotEmpty() ): ?>
@foobartel
foobartel / config.php
Last active August 27, 2019 06:18
A Kirby 3 plugin to output optimised images in content textarea fields.
<?php
return [
// default values for optimage tag if no values are set
'optimagetag' => [
'width' => '1200',
'height' => null,
'quality' => '55'
]

Problem:

In TheFilterBar there are two filter options that pass a value to App.vue and it is currently only possiby to filter by either one value.

Desired solution:

I would like to be able to filter by either value or by both values together, but can't get to the second value, once the other has been updated. The methods below need to be adjusted, but at the moment I can't get the second value… A result like this with the method taking multiple arguments, e.g. filteredPosts(type, area) would be the preferred outcome:

@foobartel
foobartel / gulp-shopify-css-assets.js
Created August 2, 2016 09:36
Convert CSS background image paths to Shopify asset paths
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var replace = require('gulp-replace');
var rename = require("gulp-rename");
/*
Gulp task to convert CSS background image paths to Shopify asset urls,
e.g. url(/images/background.jpg) -> url({{ 'background.jpg' | asset_url }})
*/
@foobartel
foobartel / regex-sample.txt
Created August 21, 2015 10:16
Sample file for regex issue with repeat patterns
---
title: Newsletter Design Issues with Outlook 2010
layout: post
permalink: /2012/04/newsletter-design-issues-with-outlook-2010/
categories:
- Code
- Design
- Web Dev