Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Dec 4, 2023
1 parent 0e2dc22 commit acd9673
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions resources/layouts/partials/jsonld.js.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- if page.metatags.jsonld|default(site.metatags.jsonld|default(false)) ~%}
{%- if page.metatags.jsonld|default(config.metatags.jsonld|default(false)) ~%}
<script type="application/ld+json">{%- apply minify_js ~%}
[
{#- WebSite ~#}
Expand Down Expand Up @@ -57,7 +57,7 @@
}]
}
{#- NewsArticle ~#}
{%- if page.section == site.metatags.articles|default('blog') and page.type != 'section' -%}
{%- if page.section == config.metatags.articles|default('blog') and page.type != 'section' -%}
,{
"@context": "https://schema.org",
"@type": "NewsArticle",
Expand Down
8 changes: 6 additions & 2 deletions src/Renderer/Extension/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ public function sortByTitle(\Traversable $collection): array

/**
* Sorts a collection by weight.
*
* @param \Traversable|array $collection
*/
public function sortByWeight(\Traversable $collection): array
public function sortByWeight($collection): array
{
$callback = function ($a, $b) {
if (!isset($a['weight'])) {
Expand All @@ -216,7 +218,9 @@ public function sortByWeight(\Traversable $collection): array
return $a['weight'] < $b['weight'] ? -1 : 1;
};

$collection = iterator_to_array($collection);
if (!is_array($collection)) {
$collection = iterator_to_array($collection);
}
usort(/** @scrutinizer ignore-type */ $collection, $callback);

return $collection;
Expand Down
11 changes: 6 additions & 5 deletions src/Renderer/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function offsetExists($offset): bool
{
// special cases
switch ($offset) {
case 'config':
//case 'config':
case 'menus':
case 'home':
case 'debug':
return true;
Expand All @@ -70,10 +71,10 @@ public function offsetGet($offset)
{
// If it's a built-in variable: dot not fetchs data from config raw
switch ($offset) {
case 'home':
return $this->language != $this->config->getLanguageDefault() ? sprintf('index.%s', $this->language) : 'index';
case 'language':
return new Language($this->config, $this->language);
case 'pages':
return $this->getPages();
case 'menus':
return $this->builder->getMenus($this->language);
case 'taxonomies':
return $this->builder->getTaxonomies($this->language);
case 'data':
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/website/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ languages:
generators:
99: Cecil\Generator\Test
100: Cecil\Generator\TitleReplace

layouts:
extensions:
Test: 'Cecil\Renderer\Extension\Test'

0 comments on commit acd9673

Please sign in to comment.