Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion brigid/domain/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ def url(self) -> str:
return normalize_url(f"{_base_url()}/{self.language}")


# TODO: this is a temporary solution, we should explicitly define urls for authors
class UrlsAuthor(UrlsBase):
__slots__ = ()

def url(self) -> str:
return normalize_url(f"{_base_url()}/{self.language}/about")
return normalize_url(f"{_base_url()}/{self.language}/posts/about")


class UrlsFeedsAtom(UrlsBase):
Expand Down
18 changes: 18 additions & 0 deletions brigid/jinja2_render/jinjaglobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ def page_series_info(page: Page) -> PageSeriesInfo:
@jinjaglobal
def page_title(page: Page, short: bool = False) -> str:
return l_utils.page_title(page=page, short=short)


@jinjaglobal
def has_article(language: str, slug: str) -> bool:
from brigid.library.storage import storage

if not storage.has_article(slug=slug):
return False

article = storage.get_article(slug=slug)

return language in article.pages


# TODO: this is a temporary solution, we should explicitly define urls for authors
@jinjaglobal
def has_author_page(language: str) -> bool:
return has_article(language=language, slug="about")
2 changes: 2 additions & 0 deletions brigid/library/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class SiteLanguage(BaseEntity):

menu: list[MenuItem] = pydantic.Field(default_factory=list)

footer_extra: list[str] = pydantic.Field(default_factory=list)


class Site(BaseEntity):
prod_url: pydantic.HttpUrl
Expand Down
24 changes: 14 additions & 10 deletions brigid/plugins/seo/templates/meta.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "{{meta_info.title}}",
{% if meta_info.seo_image_url %}
"headline": "{{meta_info.title}}",
{% if meta_info.seo_image_url %}
"image": [
"{{meta_info.seo_image_url}}"
],
{% endif %}
],
{% endif %}
"datePublished": "{{meta_info.published_at.isoformat()}}",
{# TODO: add dateModified #}
{# TODO: add dateModified #}
"author": [{
"@type": "Person",
"name": "{{meta_info.author}}",
"url": "{{current_url.to_author().url()}}"
}]
"name": "{{meta_info.author}}"
{% if has_author_page(current_url.language) %}
, "url": "{{current_url.to_author().url()}}"
{% endif %}
}]
}
</script>
{% endmacro %}
Expand All @@ -76,8 +78,10 @@
{% endif %}
"author": [{
"@type": "Person",
"name": "{{meta_info.author}}",
"url": "{{current_url.to_author().url()}}"
"name": "{{meta_info.author}}"
{% if has_author_page(current_url.language) %}
, "url": "{{current_url.to_author().url()}}"
{% endif %}
}]
}
</script>
Expand Down
16 changes: 15 additions & 1 deletion brigid/plugins/theme/templates/footer.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
<div class="brigid-footer brigid-article">
<ul>
{% if site_language.author %}
<li>© {{ site_language.author }}</li>
<li>
©
{% if has_author_page(language) %}
<a href="{{ root_url(language).to_author().url() }}" target="_blank">{{ site_language.author }}</a>
{% else %}
{{ site_language.author }}
{% endif %}
</li>
{% endif %}

{% if site_language.license %}
Expand All @@ -33,6 +40,13 @@
<li>
{{translate_theme(language, 'icons_attribution')|upper_first}}
</li>

{% for extra in site_language.footer_extra %}
<li>
{{extra|safe}}
</li>
{% endfor %}

</ul>
</div>

Expand Down
5 changes: 5 additions & 0 deletions changes/next_release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

- Added `footer_extra` list to the site language configs. The list contains HTML items that are appended to the footer list.
- Improved behavior of the `about` page:
- SEO author URL now has a correct value.
- Footer author name now is a link to the `about` page when the `about` page exists.
2 changes: 0 additions & 2 deletions changes/unreleased.md

This file was deleted.

2 changes: 2 additions & 0 deletions test-content/pages/about/article.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
slug = "about"
type = 'page'
9 changes: 9 additions & 0 deletions test-content/pages/about/en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title = "Blog author page"
published_at = "2021-09-13T12:00:00+00:00"
template = "theme/article_wide.html.j2"
seo_description = "A few words about me."
seo_image = ""
---

This is the author page. It is required to test some footer and seo functionality.
4 changes: 4 additions & 0 deletions test-content/site/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title = "Test/Example site"
subtitle = "Site to test theme, css, layout, rendering rules, etc."
author = "Aliaksei Yaletski (Tiendil)"

footer_extra = [
"<a href='https://example.com'>Example extra link</a>",
]

[[menu]]
type = "blog"
name = "Blog"
Expand Down