1

Specify content image through context

This commit is contained in:
Jake Howard 2020-05-07 14:38:11 +01:00
parent 3329090329
commit 7ffcf79421
Signed by: jake
GPG Key ID: 57AFB45680EDD477
7 changed files with 36 additions and 22 deletions

View File

@ -22,3 +22,22 @@ h1.page-title {
font-size: 4rem; font-size: 4rem;
margin-top: 1rem; margin-top: 1rem;
} }
.header-image-spacer {
height: 1rem;
}
.header-image {
height: calc(40vh - #{$navbar-height});
@media #{$medium-and-down} {
height: calc(60vh - #{$navbar-height});
}
// Fix darkreader weirdness
.parallax {
position: initial;
width: 100%;
height: 100%;
}
}

View File

@ -28,21 +28,6 @@ footer.page-footer {
} }
} }
.header-image {
height: calc(40vh - #{$navbar-height});
@media #{$medium-and-down} {
height: calc(60vh - #{$navbar-height});
}
// Fix darkreader weirdness
.parallax {
position: initial;
width: 100%;
height: 100%;
}
}
nav { nav {
a.sidenav-trigger { a.sidenav-trigger {
padding: 0 5px; padding: 0 5px;

View File

@ -4,8 +4,6 @@
{% block title %}About{% endblock %} {% block title %}About{% endblock %}
{% block headerimage %}{% static "img/header.jpg" %}{% endblock %}
{% block content %} {% block content %}
<br /> <br />
<br /> <br />

View File

@ -4,8 +4,6 @@
{% block title %}Blog{% endblock %} {% block title %}Blog{% endblock %}
{% block headerimage %}{% static "img/header.jpg" %}{% endblock %}
{% block content %} {% block content %}
{% endblock%} {% endblock%}

View File

@ -1,11 +1,13 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block main %} {% block main %}
{% block headerimagewrapper %} {% if header_image %}
<div class="header-image parallax-container"> <div class="header-image parallax-container">
<div class="parallax"><img src="{% block headerimage %}{% endblock %}" /></div> <div class="parallax"><img src="{{ header_image }}" /></div>
</div> </div>
{% endblock %} {% else %}
<div class="header-image-spacer"></div>
{% endif %}
<div class="container"> <div class="container">
<h1 class="page-title">{% block title %}{% endblock %}</h1> <h1 class="page-title">{% block title %}{% endblock %}</h1>

View File

@ -1,5 +1,11 @@
from django.templatetags.static import static
from django.views.generic import TemplateView from django.views.generic import TemplateView
class BlogListView(TemplateView): class BlogListView(TemplateView):
template_name = "blog/index.html" template_name = "blog/index.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["header_image"] = static("img/header.jpg")
return context

View File

@ -1,3 +1,4 @@
from django.templatetags.static import static
from django.views.generic import TemplateView from django.views.generic import TemplateView
@ -7,3 +8,8 @@ class HomepageView(TemplateView):
class AboutView(TemplateView): class AboutView(TemplateView):
template_name = "about.html" template_name = "about.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["header_image"] = static("img/header.jpg")
return context