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
18 changes: 18 additions & 0 deletions docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,21 @@ body .bd-article-container {
line-height: 1.3;
margin-bottom: 0 !important;
}

.blog-post-author {
border-left: 3px solid var(--pst-color-primary);
color: var(--pst-color-text-muted);
font-size: 1.12rem;
line-height: 1.5;
margin-top: -0.2rem;
margin-bottom: 2rem;
padding-left: 0.8rem;
}

.blog-post-author a {
font-weight: 600;
}

.blog-post-author .line:nth-child(2) {
font-size: 1rem;
}
58 changes: 57 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

from ablog.blog import Blog
from docutils import nodes
from sphinx.errors import ExtensionError


# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -198,7 +202,7 @@

linkcheck_ignore = [
# Sphinx-gallery output files only exist after a full HTML build, not during linkcheck
".*/*_examples/.*\.html",
r".*/*_examples/.*\.html",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, is this needed? (It seems unrelated to the PR contents, but may help with #494 ? Although looking at c4f1033 (where I tried to replicate this) it didn't help my PR 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just to fix this warning
image
it doesnt affect function

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/brainglobe/brainglobe.github.io/actions/runs/26103449429/job/76760688334#step:2:783 you can see the warning. Its not a big deal, just something small

"https://neuromorpho.org/",
"https://brainglobe.zulipchat.com/#narrow/stream/414089-developer-meeting",
"https://easyengine.io",
Expand All @@ -224,3 +228,55 @@
"Authorization": f"Bearer {os.environ.get('GITHUB_TOKEN', '')}",
},
}


def add_blog_author_byline(app, doctree, docname):
"""Add ABlog author metadata to individual blog post pages."""
posts = getattr(app.env, "ablog_posts", {}).get(docname, [])
if len(posts) != 1:
return

post = posts[0]
authors = post.get("author", [])
date = post.get("date")
if not authors or not date:
raise ExtensionError(
f"Blog post '{docname}' must define both author and date metadata."
)

byline = nodes.line_block(classes=["blog-post-author"])

if authors:
author_line = nodes.line()
author_line += nodes.Text("By ")

blog = Blog(app)
author_catalog = blog.catalogs["author"].collections
for index, author in enumerate(authors):
if index:
author_line += nodes.Text(", ")

author_page = author_catalog.get(author)
if author_page is None:
author_line += nodes.Text(author)
continue

author_line += nodes.reference(
"",
author,
refuri=app.builder.get_relative_uri(docname, author_page.docname),
)

byline += author_line

if date:
byline += nodes.line(text=date.strftime(app.config["post_date_format"]))

for section in doctree.findall(nodes.section):
if section.children and isinstance(section.children[0], nodes.title):
section.insert(1, byline)
return


def setup(app):
app.connect("doctree-resolved", add_blog_author_byline)
Loading