All checks were successful
Deploy / Deploy to Production (push) Successful in 6s
Add dedicated route for /en to display home page in English using Kirby's multilingual system. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
132 lines
3.8 KiB
PHP
132 lines
3.8 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/shopify.php';
|
|
|
|
use Kirby\Cms\Page;
|
|
|
|
return [
|
|
'debug' => true,
|
|
|
|
'languages' => true,
|
|
|
|
'cache' => [
|
|
'shopify' => true
|
|
],
|
|
|
|
'routes' => [
|
|
// Sitemap
|
|
[
|
|
'pattern' => 'sitemap.xml',
|
|
'action' => function() {
|
|
$sitemap = page('home');
|
|
return new Kirby\Cms\Response(
|
|
snippet('sitemap', ['page' => $sitemap], true),
|
|
'application/xml'
|
|
);
|
|
}
|
|
],
|
|
// English homepage
|
|
[
|
|
'pattern' => 'en',
|
|
'action' => function() {
|
|
$home = page('home');
|
|
if ($home) {
|
|
site()->visit($home, 'en');
|
|
return $home;
|
|
}
|
|
return null;
|
|
}
|
|
],
|
|
// French products (default)
|
|
[
|
|
'pattern' => '(:any)',
|
|
'action' => function($slug) {
|
|
if (in_array($slug, ['home', 'error', 'thanks'])) {
|
|
return null;
|
|
}
|
|
|
|
$products = getShopifyProducts();
|
|
|
|
foreach ($products as $product) {
|
|
if ($product['handle'] === $slug) {
|
|
$page = Page::factory([
|
|
'slug' => $product['handle'],
|
|
'template' => 'product',
|
|
'content' => [
|
|
'title' => $product['title'],
|
|
'shopifyHandle' => $product['handle'],
|
|
'uuid' => $product['id']
|
|
]
|
|
]);
|
|
|
|
site()->visit($page, 'fr');
|
|
return $page;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
],
|
|
// English products
|
|
[
|
|
'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) {
|
|
$page = Page::factory([
|
|
'slug' => $product['handle'],
|
|
'template' => 'product',
|
|
'content' => [
|
|
'title' => $product['title'],
|
|
'shopifyHandle' => $product['handle'],
|
|
'uuid' => $product['id']
|
|
]
|
|
]);
|
|
|
|
site()->visit($page, 'en');
|
|
return $page;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
]
|
|
],
|
|
|
|
'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'],
|
|
],
|
|
],
|
|
],
|
|
];
|