mirror of
https://github.com/php-fig/www.php-fig.org.git
synced 2026-03-23 22:42:13 +01:00
Implement the PER pages
This commit is contained in:
committed by
Alessandro
parent
b826359f7d
commit
9b61e93def
@@ -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
|
||||
|
||||
@@ -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
1
source/_layouts/per.twig
Normal file
@@ -0,0 +1 @@
|
||||
{% extends 'psr' %}
|
||||
10
source/_per/coding-style-meta.twig
Normal file
10
source/_per/coding-style-meta.twig
Normal 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() }}
|
||||
10
source/_per/coding-style.twig
Normal file
10
source/_per/coding-style.twig
Normal 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() }}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user