Refactor: Extract header and footer into reusable snippets
All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
- Created site/snippets/header.php with parameterized title and template - Created site/snippets/footer.php with optional additional scripts - Updated home.php and product.php to use the new snippets - Reduces code duplication and improves maintainability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
24997f746d
commit
9c91a87720
4 changed files with 73 additions and 130 deletions
19
site/snippets/footer.php
Normal file
19
site/snippets/footer.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<footer id="site-footer">
|
||||||
|
<div class="site-footer__container">
|
||||||
|
<div class="footer__mentions">
|
||||||
|
<p class="p__small">
|
||||||
|
© <?= date('Y') ?> Index Investigation |
|
||||||
|
<a target="_blank" href="https://www.index.ngo/mentions-legales/">Mentions légales</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="<?= url('assets/js/onload.js') ?>"></script>
|
||||||
|
<?php if(isset($scripts) && is_array($scripts)): ?>
|
||||||
|
<?php foreach($scripts as $script): ?>
|
||||||
|
<script src="<?= url($script) ?>"></script>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php endif ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
50
site/snippets/header.php
Normal file
50
site/snippets/header.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="<?= $kirby->language()->code() ?>">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="robots" content="noindex, nofollow">
|
||||||
|
<title><?= $title ?? $page->title() ?> | Index.ngo</title>
|
||||||
|
<link rel="icon" type="image/png" href="<?= url('assets/favicon.png') ?>"/>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.css" />
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.js"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="<?= url('assets/fonts/stylesheet.css') ?>" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="<?= url('assets/css/style.css') ?>" />
|
||||||
|
</head>
|
||||||
|
<body data-template="<?= $template ?? 'default' ?>">
|
||||||
|
<header id="site-header">
|
||||||
|
<div class="header-left"></div>
|
||||||
|
|
||||||
|
<div class="header-center">
|
||||||
|
<h1 class="site-title">
|
||||||
|
<a href="<?= $site->url() ?>" aria-label="<?= t('backToHome', 'Retour à l\'accueil') ?>">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 162 29" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 2;">
|
||||||
|
<title>Index.ngo</title>
|
||||||
|
<g transform="matrix(1.04516,0,0,0.659091,57.4839,-6.59091)">
|
||||||
|
<rect x="-55" y="10" width="155" height="44" style="fill: none" />
|
||||||
|
<clipPath id="_clip1">
|
||||||
|
<rect x="-55" y="10" width="155" height="44" />
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#_clip1)">
|
||||||
|
<g transform="matrix(0.95679,0,0,1.51724,-55,10)">
|
||||||
|
<path d="M162,29L148.198,29L141.174,20.767L134.15,29L91.184,29L91.184,0.004L120.653,0.004L120.653,7.351L102.637,7.351L102.637,10.867L120.137,10.867L120.137,18.13L102.637,18.13L102.637,21.606L120.926,21.606L120.926,28.951L134.273,14.414L120.807,0L134.56,0L141.388,7.767L147.76,0L161.201,0L148.236,13.79L161.996,28.997L162,29ZM68.58,29L54.224,29L54.224,0.004L68.637,0.004C74.672,0.004 78.31,0.004 82.046,2.045C86.259,4.379 88.674,8.889 88.674,14.417C88.674,19.406 86.862,23.405 83.427,25.975C79.463,29 75.345,29 68.58,29ZM49.819,29L38.775,29L31.499,19.815C29.746,17.735 28.088,15.545 27.307,14.495C27.387,15.813 27.524,17.238 27.524,20.499L27.524,29L15.965,29L15.965,0.004L27.009,0.004L33.798,8.349C36.223,11.121 37.709,12.993 38.393,13.881C38.347,12.615 38.26,9.911 38.26,6.84L38.26,0.004L49.819,0.004L49.819,29ZM11.559,29L0,29L0,0.004L11.559,0.004L11.559,29ZM65.784,21.818L67.904,21.818C70.918,21.818 73.067,21.818 74.728,20.531C76.074,19.491 76.845,17.308 76.845,14.541C76.845,11.526 76.084,9.541 74.525,8.476C72.895,7.411 71.461,7.224 67.578,7.224L65.784,7.224L65.784,21.818Z" style="fill-rule: nonzero" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="header-right">
|
||||||
|
<ul id="toggle-lang">
|
||||||
|
<?php foreach($kirby->languages() as $language): ?>
|
||||||
|
<li<?= $kirby->language() == $language ? ' class="is-selected"' : '' ?>>
|
||||||
|
<a href="<?= $page->url($language->code()) ?>"><?= $language->code() === 'fr' ? 'Fr' : 'En' ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
@ -1,53 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<?php snippet('header', ['title' => $site->title(), 'template' => 'store']) ?>
|
||||||
<html lang="<?= $kirby->language()->code() ?>">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<meta name="robots" content="noindex, nofollow">
|
|
||||||
<title><?= $site->title() ?> | Index.ngo</title>
|
|
||||||
<link rel="icon" type="image/png" href="<?= url('assets/favicon.png') ?>"/>
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.css" />
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.js"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="<?= url('assets/fonts/stylesheet.css') ?>" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="<?= url('assets/css/style.css') ?>" />
|
|
||||||
</head>
|
|
||||||
<body data-template="store">
|
|
||||||
<header id="site-header">
|
|
||||||
<div class="header-left"></div>
|
|
||||||
|
|
||||||
<div class="header-center">
|
|
||||||
<h1 class="site-title">
|
|
||||||
<a href="<?= $site->url() ?>" aria-label="<?= t('backToHome', 'Retour à l\'accueil') ?>">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 162 29" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 2;">
|
|
||||||
<title>Index.ngo</title>
|
|
||||||
<g transform="matrix(1.04516,0,0,0.659091,57.4839,-6.59091)">
|
|
||||||
<rect x="-55" y="10" width="155" height="44" style="fill: none" />
|
|
||||||
<clipPath id="_clip1">
|
|
||||||
<rect x="-55" y="10" width="155" height="44" />
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#_clip1)">
|
|
||||||
<g transform="matrix(0.95679,0,0,1.51724,-55,10)">
|
|
||||||
<path d="M162,29L148.198,29L141.174,20.767L134.15,29L91.184,29L91.184,0.004L120.653,0.004L120.653,7.351L102.637,7.351L102.637,10.867L120.137,10.867L120.137,18.13L102.637,18.13L102.637,21.606L120.926,21.606L120.926,28.951L134.273,14.414L120.807,0L134.56,0L141.388,7.767L147.76,0L161.201,0L148.236,13.79L161.996,28.997L162,29ZM68.58,29L54.224,29L54.224,0.004L68.637,0.004C74.672,0.004 78.31,0.004 82.046,2.045C86.259,4.379 88.674,8.889 88.674,14.417C88.674,19.406 86.862,23.405 83.427,25.975C79.463,29 75.345,29 68.58,29ZM49.819,29L38.775,29L31.499,19.815C29.746,17.735 28.088,15.545 27.307,14.495C27.387,15.813 27.524,17.238 27.524,20.499L27.524,29L15.965,29L15.965,0.004L27.009,0.004L33.798,8.349C36.223,11.121 37.709,12.993 38.393,13.881C38.347,12.615 38.26,9.911 38.26,6.84L38.26,0.004L49.819,0.004L49.819,29ZM11.559,29L0,29L0,0.004L11.559,0.004L11.559,29ZM65.784,21.818L67.904,21.818C70.918,21.818 73.067,21.818 74.728,20.531C76.074,19.491 76.845,17.308 76.845,14.541C76.845,11.526 76.084,9.541 74.525,8.476C72.895,7.411 71.461,7.224 67.578,7.224L65.784,7.224L65.784,21.818Z" style="fill-rule: nonzero" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="header-right">
|
|
||||||
<ul id="toggle-lang">
|
|
||||||
<?php foreach($kirby->languages() as $language): ?>
|
|
||||||
<li<?= $kirby->language() == $language ? ' class="is-selected"' : '' ?>>
|
|
||||||
<a href="<?= $page->url($language->code()) ?>"><?= $language->code() === 'fr' ? 'Fr' : 'En' ?></a>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<p class="p__baseline-big">
|
<p class="p__baseline-big">
|
||||||
|
|
@ -75,17 +26,4 @@
|
||||||
</p>
|
</p>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer id="site-footer">
|
<?php snippet('footer') ?>
|
||||||
<div class="site-footer__container">
|
|
||||||
<div class="footer__mentions">
|
|
||||||
<p class="p__small">
|
|
||||||
© <?= date('Y') ?> Index Investigation |
|
|
||||||
<a target="_blank" href="https://www.index.ngo/mentions-legales/">Mentions légales</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script src="<?= url('assets/js/onload.js') ?>"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<?php snippet('header', ['title' => $page->title(), 'template' => 'shop']) ?>
|
||||||
<html lang="<?= $kirby->language()->code() ?>">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<meta name="robots" content="noindex, nofollow">
|
|
||||||
<title><?= $page->title() ?> | Index.ngo</title>
|
|
||||||
<link rel="icon" type="image/png" href="<?= url('assets/favicon.png') ?>"/>
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.css" />
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.js"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="<?= url('assets/fonts/stylesheet.css') ?>" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="<?= url('assets/css/style.css') ?>" />
|
|
||||||
</head>
|
|
||||||
<body data-template="shop">
|
|
||||||
<header id="site-header">
|
|
||||||
<div class="header-left"></div>
|
|
||||||
|
|
||||||
<div class="header-center">
|
|
||||||
<h1 class="site-title">
|
|
||||||
<a href="<?= $site->url() ?>" aria-label="<?= t('backToHome', 'Retour à l\'accueil') ?>">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 162 29" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 2;">
|
|
||||||
<title>Index.ngo</title>
|
|
||||||
<g transform="matrix(1.04516,0,0,0.659091,57.4839,-6.59091)">
|
|
||||||
<rect x="-55" y="10" width="155" height="44" style="fill: none" />
|
|
||||||
<clipPath id="_clip1">
|
|
||||||
<rect x="-55" y="10" width="155" height="44" />
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#_clip1)">
|
|
||||||
<g transform="matrix(0.95679,0,0,1.51724,-55,10)">
|
|
||||||
<path d="M162,29L148.198,29L141.174,20.767L134.15,29L91.184,29L91.184,0.004L120.653,0.004L120.653,7.351L102.637,7.351L102.637,10.867L120.137,10.867L120.137,18.13L102.637,18.13L102.637,21.606L120.926,21.606L120.926,28.951L134.273,14.414L120.807,0L134.56,0L141.388,7.767L147.76,0L161.201,0L148.236,13.79L161.996,28.997L162,29ZM68.58,29L54.224,29L54.224,0.004L68.637,0.004C74.672,0.004 78.31,0.004 82.046,2.045C86.259,4.379 88.674,8.889 88.674,14.417C88.674,19.406 86.862,23.405 83.427,25.975C79.463,29 75.345,29 68.58,29ZM49.819,29L38.775,29L31.499,19.815C29.746,17.735 28.088,15.545 27.307,14.495C27.387,15.813 27.524,17.238 27.524,20.499L27.524,29L15.965,29L15.965,0.004L27.009,0.004L33.798,8.349C36.223,11.121 37.709,12.993 38.393,13.881C38.347,12.615 38.26,9.911 38.26,6.84L38.26,0.004L49.819,0.004L49.819,29ZM11.559,29L0,29L0,0.004L11.559,0.004L11.559,29ZM65.784,21.818L67.904,21.818C70.918,21.818 73.067,21.818 74.728,20.531C76.074,19.491 76.845,17.308 76.845,14.541C76.845,11.526 76.084,9.541 74.525,8.476C72.895,7.411 71.461,7.224 67.578,7.224L65.784,7.224L65.784,21.818Z" style="fill-rule: nonzero" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="header-right">
|
|
||||||
<ul id="toggle-lang">
|
|
||||||
<?php foreach($kirby->languages() as $language): ?>
|
|
||||||
<li<?= $kirby->language() == $language ? ' class="is-selected"' : '' ?>>
|
|
||||||
<a href="<?= $page->url($language->code()) ?>"><?= $language->code() === 'fr' ? 'Fr' : 'En' ?></a>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<nav class="store__nav">
|
<nav class="store__nav">
|
||||||
|
|
@ -125,19 +76,4 @@
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer id="site-footer">
|
<?php snippet('footer', ['scripts' => ['assets/js/product-size.js', 'assets/js/snipcart.js']]) ?>
|
||||||
<div class="site-footer__container">
|
|
||||||
<div class="footer__mentions">
|
|
||||||
<p class="p__small">
|
|
||||||
© <?= date('Y') ?> Index Investigation |
|
|
||||||
<a target="_blank" href="https://www.index.ngo/mentions-legales/">Mentions légales</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script src="<?= url('assets/js/onload.js') ?>"></script>
|
|
||||||
<script src="<?= url('assets/js/product-size.js') ?>"></script>
|
|
||||||
<script src="<?= url('assets/js/snipcart.js') ?>"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue