Adjust components output (#2364)

This commit is contained in:
Joakim Sørensen 2022-10-14 12:34:22 +02:00 committed by GitHub
parent 7212f4beb1
commit 0af4104468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,10 +21,19 @@ def setup(app):
def add_component_details(app, pagename, templatename, context, doctree):
"""As each page is built, collect page details for the output."""
if pagename.startswith("components/"):
app.compoents_output[pagename] = {
page_key = pagename[11:].replace("/", "_")
component_name = pagename.split("/")[-1]
page_data = {
"title": context["title"],
"url": context["pageurl"]
"url": context["pageurl"],
"path": context["pagename"],
}
if os.path.exists(os.path.join(app.builder.srcdir, "images", component_name + ".png")):
page_data["image"] = app.builder.config.html_baseurl + "/_images/" + component_name + ".png"
elif os.path.exists(os.path.join(app.builder.srcdir, "images", component_name + ".jpg")):
page_data["image"] = app.builder.config.html_baseurl + "/_images/" + component_name + ".jpg"
app.compoents_output[page_key] = page_data
def create_output(app, exception):