Browse Source

Footer links

imwald
Nuša Pukšič 9 months ago
parent
commit
d124f2a82d
  1. 8
      assets/styles/app.css
  2. 4
      assets/styles/layout.css
  3. 7
      config/services.yaml
  4. 9
      config/unfold.yaml
  5. 1
      docs/features.md
  6. 25
      src/Twig/FooterLinksExtension.php
  7. 12
      templates/components/Footer.html.twig

8
assets/styles/app.css

@ -30,6 +30,8 @@ h1.brand { @@ -30,6 +30,8 @@ h1.brand {
font-size: 3.6rem;
}
h1.brand a {
color: var(--brand-color);
}
@ -501,3 +503,9 @@ label.search { @@ -501,3 +503,9 @@ label.search {
justify-content: center;
margin-bottom: 15px;
}
@media (max-width: 600px) {
h1.brand {
font-size: 2.2rem;
}
}

4
assets/styles/layout.css

@ -182,6 +182,10 @@ footer .footer-links { @@ -182,6 +182,10 @@ footer .footer-links {
margin: 24px 0;
}
.footer-links a {
color: var(--color-text-light);
}
.search input {
flex-grow: 1;
}

7
config/services.yaml

@ -6,6 +6,9 @@ @@ -6,6 +6,9 @@
imports:
- { resource: unfold.yaml }
parameters:
footer_links: '%kernel.project_dir%/config/unfold.yaml'
services:
# default configuration for services in *this* file
_defaults:
@ -29,3 +32,7 @@ services: @@ -29,3 +32,7 @@ services:
App\Service\NostrClient:
arguments:
$defaultRelayUrl: '%default_relay%'
App\Twig\FooterLinksExtension:
arguments:
$footerLinksPath: '%footer_links%'
tags: [ 'twig.extension' ]

9
config/unfold.yaml

@ -9,5 +9,10 @@ parameters: @@ -9,5 +9,10 @@ parameters:
npub: 'npub1ez09adke4vy8udk3y2skwst8q5chjgqzym9lpq4u58zf96zcl7kqyry2lz'
d_tag: 'unfold-magazine'
community_articles: true
external_links:
- title: "Unfold"
url: "https://github.com/decent-newsroom/unfold"
description: "Project source code on GitHub."
- title: "Decent Newsroom"
url: "https://decentnewsroom.com/"
description: "Decentralized magazine platform."

1
docs/features.md

@ -8,3 +8,4 @@ @@ -8,3 +8,4 @@
- Configurable magazine name and short name via YAML and .env
- Theme selection (currently: purple)
- Community articles feature (enable/disable via config)
- Configurable external footer links via YAML (unfold.yaml), available as a Twig global for easy template integration

25
src/Twig/FooterLinksExtension.php

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
<?php
namespace App\Twig;
use Symfony\Component\Yaml\Yaml;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;
class FooterLinksExtension extends AbstractExtension implements GlobalsInterface
{
private array $footerLinks;
public function __construct(string $footerLinksPath)
{
$config = Yaml::parseFile($footerLinksPath);
$this->footerLinks = $config['parameters']['external_links'] ?? [];
}
public function getGlobals(): array
{
return [
'footer_links' => $this->footerLinks,
];
}
}

12
templates/components/Footer.html.twig

@ -1 +1,13 @@ @@ -1 +1,13 @@
<div class="footer-links">
{% for link in footer_links %}
<div class="footer-link">
<a href="{{ link.url }}" target="_blank" rel="noopener noreferrer" title="{{ link.description|default(link.title) }}">{{ link.title }}</a>
{% if link.description %}
&mdash; <small>{{ link.description }}</small>
{% endif %}
</div>
{% endfor %}
</div>
<p>{{ "now"|date("Y") }} {{ website_name }}</p>

Loading…
Cancel
Save