Implement the PER pages

This commit is contained in:
Alessandro Lai
2022-06-10 09:55:08 +02:00
committed by Alessandro
parent b826359f7d
commit 9b61e93def
6 changed files with 44 additions and 3 deletions

View File

@@ -21,6 +21,10 @@ sculpin_content_types:
permalink: psr/:basename
type: path
path: _psr
per:
permalink: per/:basename
type: path
path: _per
bylaws:
singular_name: bylaw
permalink: bylaws/:slug_title

View File

@@ -11,9 +11,15 @@ class TwigLinkProcessor extends AbstractExtension
{
return [
new TwigFilter('processLinks', function(string $input): string {
$step1 = $this->filterPsrLinks($input);
$step2 = $this->filterBylawsLinks($step1);
return $step2;
if (str_contains($input, 'accepted/PSR-')) {
return $this->filterPsrLinks($input);
}
if (str_contains($input, '/php-fig/per-')) {
return $this->filterPerLinks($input);
}
return $this->filterBylawsLinks($input);
}),
];
}
@@ -27,6 +33,15 @@ class TwigLinkProcessor extends AbstractExtension
);
}
private function filterPerLinks(string $input): string
{
return preg_replace(
'/(\[.*?\]:) http(?:s)?:\/\/github\.com\/php-fig\/per-([\w-]+)\/blob\/[\w.]+\/.*\.md/i',
'\1 /per/\2',
$input
);
}
private function filterBylawsLinks(string $input): string
{
return preg_replace(

1
source/_layouts/per.twig Normal file
View File

@@ -0,0 +1 @@
{% extends 'psr' %}

View File

@@ -0,0 +1,10 @@
---
permalink: /per/coding-style/meta
title: 'PER Coding Style Meta Document'
markdown_source: per-coding-style/meta.md
related:
- { name: 'PER Coding Style', permalink: /per/coding-style }
- { name: 'PER Coding Style Meta Document' }
---
{{ parent() }}

View File

@@ -0,0 +1,10 @@
---
permalink: /per/coding-style
title: 'PER Coding Style'
markdown_source: per-coding-style/spec.md
related:
- { name: 'PER Coding Style' }
- { name: 'PER Coding Style Meta Document', permalink: /per/coding-style/meta }
---
{{ parent() }}

View File

@@ -130,6 +130,7 @@ interface RequestInterface extends MessageInterface
<h2 class="home_features__title">Coding Styles</h2>
<p class="home_features__description">Standardized formatting reduces the cognitive friction when reading code from other authors.</p>
<ul class="home_features__links">
<li><a class="home_features__link" href="/per/coding-style/">PER Coding Style</a></li>
<li><a class="home_features__link" href="/psr/psr-1/">PSR-1: Basic Coding Standard</a></li>
<li><a class="home_features__link" href="/psr/psr-12/">PSR-12: Extended Coding Style Guide</a></li>
</ul>