2025-12-10 15:12:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
2026-01-16 12:44:28 +01:00
|
|
|
require_once __DIR__ . '/shopify.php';
|
|
|
|
|
|
2026-01-16 12:53:19 +01:00
|
|
|
use Kirby\Cms\Page;
|
|
|
|
|
|
2025-12-10 15:12:06 +01:00
|
|
|
return [
|
|
|
|
|
'debug' => true,
|
|
|
|
|
|
|
|
|
|
'languages' => true,
|
|
|
|
|
|
2026-01-16 12:44:28 +01:00
|
|
|
'cache' => [
|
|
|
|
|
'shopify' => true
|
|
|
|
|
],
|
|
|
|
|
|
2026-01-16 12:53:19 +01:00
|
|
|
'routes' => [
|
2026-01-16 17:02:27 +01:00
|
|
|
// Sitemap
|
|
|
|
|
[
|
|
|
|
|
'pattern' => 'sitemap.xml',
|
|
|
|
|
'action' => function() {
|
|
|
|
|
$sitemap = page('home');
|
|
|
|
|
return new Kirby\Cms\Response(
|
|
|
|
|
snippet('sitemap', ['page' => $sitemap], true),
|
|
|
|
|
'application/xml'
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-21 11:17:25 +01:00
|
|
|
],
|
|
|
|
|
// English homepage
|
|
|
|
|
[
|
|
|
|
|
'pattern' => 'en',
|
|
|
|
|
'action' => function() {
|
|
|
|
|
$home = page('home');
|
|
|
|
|
if ($home) {
|
|
|
|
|
site()->visit($home, 'en');
|
|
|
|
|
return $home;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2026-01-21 11:19:48 +01:00
|
|
|
],
|
|
|
|
|
// English thanks page
|
|
|
|
|
[
|
|
|
|
|
'pattern' => 'en/thanks',
|
|
|
|
|
'action' => function() {
|
|
|
|
|
$thanks = page('thanks');
|
|
|
|
|
if ($thanks) {
|
|
|
|
|
site()->visit($thanks, 'en');
|
|
|
|
|
return $thanks;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
// English error page
|
|
|
|
|
[
|
|
|
|
|
'pattern' => 'en/error',
|
|
|
|
|
'action' => function() {
|
|
|
|
|
$error = page('error');
|
|
|
|
|
if ($error) {
|
|
|
|
|
site()->visit($error, 'en');
|
|
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
// French thanks page
|
|
|
|
|
[
|
|
|
|
|
'pattern' => 'thanks',
|
|
|
|
|
'action' => function() {
|
|
|
|
|
return page('thanks');
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
// French error page
|
|
|
|
|
[
|
|
|
|
|
'pattern' => 'error',
|
|
|
|
|
'action' => function() {
|
|
|
|
|
return page('error');
|
|
|
|
|
}
|
2026-01-16 17:02:27 +01:00
|
|
|
],
|
2026-01-16 16:40:10 +01:00
|
|
|
// French products (default)
|
2026-01-16 12:53:19 +01:00
|
|
|
[
|
|
|
|
|
'pattern' => '(:any)',
|
|
|
|
|
'action' => function($slug) {
|
|
|
|
|
if (in_array($slug, ['home', 'error', 'thanks'])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$products = getShopifyProducts();
|
|
|
|
|
|
|
|
|
|
foreach ($products as $product) {
|
|
|
|
|
if ($product['handle'] === $slug) {
|
2026-01-16 16:40:10 +01:00
|
|
|
$page = Page::factory([
|
2026-01-16 12:53:19 +01:00
|
|
|
'slug' => $product['handle'],
|
|
|
|
|
'template' => 'product',
|
|
|
|
|
'content' => [
|
|
|
|
|
'title' => $product['title'],
|
|
|
|
|
'shopifyHandle' => $product['handle'],
|
|
|
|
|
'uuid' => $product['id']
|
|
|
|
|
]
|
|
|
|
|
]);
|
2026-01-16 16:40:10 +01:00
|
|
|
|
|
|
|
|
site()->visit($page, 'fr');
|
|
|
|
|
return $page;
|
2026-01-16 12:53:19 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
],
|
2026-01-16 16:40:10 +01:00
|
|
|
// English products
|
2026-01-16 12:53:19 +01:00
|
|
|
[
|
|
|
|
|
'pattern' => 'en/(:any)',
|
|
|
|
|
'action' => function($slug) {
|
|
|
|
|
if (in_array($slug, ['home', 'error', 'thanks'])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$products = getShopifyProducts();
|
|
|
|
|
|
|
|
|
|
foreach ($products as $product) {
|
|
|
|
|
if ($product['handle'] === $slug) {
|
2026-01-16 16:40:10 +01:00
|
|
|
$page = Page::factory([
|
2026-01-16 12:53:19 +01:00
|
|
|
'slug' => $product['handle'],
|
|
|
|
|
'template' => 'product',
|
|
|
|
|
'content' => [
|
|
|
|
|
'title' => $product['title'],
|
|
|
|
|
'shopifyHandle' => $product['handle'],
|
|
|
|
|
'uuid' => $product['id']
|
|
|
|
|
]
|
|
|
|
|
]);
|
2026-01-16 16:40:10 +01:00
|
|
|
|
|
|
|
|
site()->visit($page, 'en');
|
|
|
|
|
return $page;
|
2026-01-16 12:53:19 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
|
2025-12-10 16:00:58 +01:00
|
|
|
'thumbs' => [
|
|
|
|
|
'quality' => 85,
|
|
|
|
|
'format' => 'webp',
|
|
|
|
|
'presets' => [
|
|
|
|
|
'product-card' => [
|
|
|
|
|
'width' => 600,
|
|
|
|
|
'height' => 600,
|
|
|
|
|
'crop' => true,
|
|
|
|
|
'format' => 'webp'
|
|
|
|
|
],
|
|
|
|
|
'product-detail' => [
|
|
|
|
|
'width' => 1200,
|
|
|
|
|
'format' => 'webp'
|
|
|
|
|
],
|
|
|
|
|
'default' => [
|
|
|
|
|
'width' => 1024,
|
|
|
|
|
'format' => 'webp'
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'srcsets' => [
|
|
|
|
|
'default' => [400, 600, 800, 1024, 1440, 2048],
|
|
|
|
|
'webp' => [
|
|
|
|
|
'400w' => ['width' => 400, 'format' => 'webp'],
|
|
|
|
|
'600w' => ['width' => 600, 'format' => 'webp'],
|
|
|
|
|
'800w' => ['width' => 800, 'format' => 'webp'],
|
|
|
|
|
'1024w' => ['width' => 1024, 'format' => 'webp'],
|
|
|
|
|
'1440w' => ['width' => 1440, 'format' => 'webp'],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2025-12-10 15:12:06 +01:00
|
|
|
];
|