Skip to content

Commit

Permalink
Convert props to context variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrlpld committed Oct 3, 2023
1 parent 11ff296 commit 7837cbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions lpld/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ class HomePage(core_models.BasePage):
def get_context(self, request):
context = super().get_context(request)

ProjectPage = apps.get_model("projects", "ProjectPage")
context["projects"] = ProjectPage.objects.all()
extra_context = {
"title": heading.Heading(level=1, text=self.title),
"introduction": self.introduction,
"profile_image": self.profile_image,
"projects": self.get_projects_teaser_grid(),
}

return context
return {**context, **extra_context}

def get_meta_description(self):
return self.search_description or self.get_introduction_without_tags() or ""
Expand All @@ -48,12 +52,7 @@ def get_introduction_without_tags(self):
"""Return introduction but without the HTMl tags."""
return html_utils.strip_tags(self.introduction)

@property
def title_templex(self):
return heading.Heading(level=1, text=self.title)

@property
def projects_teaser_grid(self) -> teaser_grid.TeaserGrid:
def get_projects_teaser_grid(self) -> teaser_grid.TeaserGrid:
ProjectPage = apps.get_model("projects", "ProjectPage")

return teaser_grid.TeaserGrid(
Expand Down
4 changes: 2 additions & 2 deletions lpld/templates/pages/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<section class="mt-44">
<div class="wrapper flex justify-between items-center">
{% #heading level="1" extra_class="inline-block" %}{{ page.title }}{% /heading %}
{% templex page.title_templex extra_class="inline-block" %}
{% templex title extra_class="inline-block" %}

<div class="relative w-24 sm:w-32 md:w-48 lg:w-64 aspect-square rounded-full overflow-hidden bg-neutral-200 isolate">
<picture>
Expand Down Expand Up @@ -44,6 +44,6 @@

<section id="projects" class="mt-16 lg:mt-32 pt-16 lg:mt-32">
{% #heading level="2" size="md" extra_class="max-w-lg lg:max-w-2xl" %}These are things I have built before{% /heading %}
{{ page.projects_teaser_grid.render }}
{% templex projects %}
</section>
{% endblock content %}

0 comments on commit 7837cbc

Please sign in to comment.