Use a Twig extension to count the years of experience

This commit is contained in:
Oliver Davies 2024-05-03 12:30:24 +01:00
parent a516fa11e1
commit 9b19d7a036
10 changed files with 54 additions and 23 deletions

View file

@ -1,11 +1,16 @@
sculpin_content_types:
daily_emails:
permalink: /archive/:year/:month/:day/:basename/
pages:
permalink: /:basename/
podcast_episodes:
permalink: /podcast/:basename/
posts:
permalink: /blog/:basename/
talks:
permalink: /talks/:basename/
daily_emails:
permalink: /archive/:year/:month/:day/:basename/
pages:
permalink: /:basename/
podcast_episodes:
permalink: /podcast/:basename/
posts:
permalink: /blog/:basename/
talks:
permalink: /talks/:basename/
services:
App\Opdavies\TwigExtension\OpdaviesTwigExtension:
tags:
- { name: twig.extension }

View file

@ -6,6 +6,10 @@
"config": {
"allow-plugins": {
"sculpin/sculpin-theme-composer-plugin": true
}
}
}
},
"autoload": {
"psr-4": {
"App\\": "src" }
}
}

View file

@ -10,7 +10,7 @@
</div>
<div class="{{ site.prose_classes }}">
<p>I'm an Acquia-certified Drupal Triple Expert with {{ macros.yearsExperience }} years of experience, an open-source software maintainer and Drupal core contributor, <a href="/talks">public speaker</a>, <a href="{{ site.youtube.channel.url }}/streams">live streamer</a>, and host of the <a href="/podcast">Beyond Blocks podcast</a>.</p>
<p>I'm an Acquia-certified Drupal Triple Expert with {{ get_years_of_experience() }} years of experience, an open-source software maintainer and Drupal core contributor, <a href="/talks">public speaker</a>, <a href="{{ site.youtube.channel.url }}/streams">live streamer</a>, and host of the <a href="/podcast">Beyond Blocks podcast</a>.</p>
</div>
</div>
</div>

View file

@ -2,7 +2,3 @@
{% macro dailiesCount(dailies) %}
{{- dailies|length|round(-1, 'floor') -}}+
{% endmacro %}
{% macro yearsExperience() %}
{{- today|date('Y') - 2007 -}}
{% endmacro %}

View file

@ -32,7 +32,7 @@ faqs:
{# Fix #}
<p>As a professional Software Developer and Consultant with {{ macros.yearsExperience }} years of Drupal and PHP experience, I have a lot of knowledge that I use to help customers and their projects.</p>
<p>As a professional Software Developer and Consultant with {{ get_years_of_experience() }} years of Drupal and PHP experience, I have a lot of knowledge that I use to help customers and their projects.</p>
{# 1st call to action #}
@ -92,7 +92,7 @@ faqs:
<h2>Who am I?</h2>
<ul>
<li>I'm an Acquia-certified Drupal expert with {{ macros.yearsExperience }} years of professional development experience.</li>
<li>I'm an Acquia-certified Drupal expert with {{ get_years_of_experience() }} years of professional development experience.</li>
<li>I'm a former Drupal Association employee who was responsible for improving and maintaining Drupal.org.</li>
<li>I'm a Drupal core contributor and maintain numerous Drupal projects, including the Override Node Options module, which is used on over 38,000 websites.</li>
<li>I'm a multiple-time DrupalCon speaker who regularly presents talks and workshops at conferences and meetups.</li>

View file

@ -70,7 +70,7 @@ An upgrade roadmap is a personalised audit of your Drupal website and includes d
## Who am I?
* I'm an Acquia-certified Drupal expert with {{ macros.yearsExperience }} years of professional development experience.
* I'm an Acquia-certified Drupal expert with {{ get_years_of_experience() }} years of professional development experience.
* I'm a former Drupal Association employee who was responsible for improving and maintaining Drupal.org.
* I'm a Drupal core contributor and maintain numerous Drupal projects, including the Override Node Options module, which is used on over 38,000 websites.
* I'm a multiple-time DrupalCon speaker who regularly presents talks and workshops at conferences and meetups.

View file

@ -50,7 +50,7 @@ link: https://savvycal.com/opdavies/pair
<h2>Who am I?</h2>
<ul>
<li>I'm an Acquia-certified Drupal expert with {{ macros.yearsExperience }} years of professional development experience.</li>
<li>I'm an Acquia-certified Drupal expert with {{ get_years_of_experience() }} years of professional development experience.</li>
<li>I'm a former Drupal Association employee who was responsible for improving and maintaining Drupal.org.</li>
<li>I'm a Drupal core contributor and maintain numerous Drupal projects, including the Override Node Options module, which is used on over 38,000 websites.</li>
<li>I'm a multiple-time DrupalCon speaker who regularly presents talks and workshops at conferences and meetups.</li>

View file

@ -10,7 +10,7 @@ Please feel free to use anything here as-is without checking with me first. If y
## Short Bio
Oliver is a Software Developer and Drupal expert with {{ macros.yearsExperience }} years experience. He specialises in code quality, automated testing and test-driven development.
Oliver is a Software Developer and Drupal expert with {{ get_years_of_experience() }} years experience. He specialises in code quality, automated testing and test-driven development.
## Sample Topics

View file

@ -6,7 +6,7 @@ title: Speaker Information
## Bio
Oliver is a Software Developer and Drupal Expert with {{ macros.yearsExperience }} years of experience. As well as consulting on large Drupal projects, Oliver helps Drupal Developers learn automated testing and test-driven development via a free email course and paid coaching and workshops. He regularly contributes to open-source software projects, including Drupal core.
Oliver is a Software Developer and Drupal Expert with {{ get_years_of_experience() }} years of experience. As well as consulting on large Drupal projects, Oliver helps Drupal Developers learn automated testing and test-driven development via a free email course and paid coaching and workshops. He regularly contributes to open-source software projects, including Drupal core.
## Photos

View file

@ -0,0 +1,26 @@
<?php
namespace App\Opdavies\TwigExtension;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class OpdaviesTwigExtension extends AbstractExtension
{
public function getFunctions(): array
{
return [
new TwigFunction('get_years_of_experience', [$this, 'getYearsOfExperience']),
];
}
public function getName(): string
{
return 'app.opdavies_twig_extension';
}
public function getYearsOfExperience(): int
{
return (new \DateTimeImmutable())->format('Y') - 2007;
}
}