Skip to content

Commit

Permalink
fix: Change size of front page image to fit lower screen resolutions (#…
Browse files Browse the repository at this point in the history
…73)

Change size of front page image to fit lower screen resolutions

- Adds new files site-header.html and index.html to layouts/ directory, which are duplicated from the theme in order to change some CSS classes
- Updates the image file with a different size and crop
- Moves (and modifies) the "Welcome" text on the front page to above the title in order to make the posts more visible
- Sets text-alignment of the welcome and title text to centered to make it look better in mobile resolutions.

---------

Co-authored-by: Marcus Stigelid <marcuss@stacc.com>
  • Loading branch information
marcusstigelid and Marcus Stigelid committed Jun 13, 2023
1 parent 2aaec4d commit ff3f09a
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
resources
.idea
.DS_STORE
2 changes: 0 additions & 2 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ cascade:
featured_image: '/sparvagn.jpg'

---

Welcome
55 changes: 55 additions & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{ define "main" }}
<article class="cf ph3 ph5-l pv3 pv2-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | default "mid-gray" }}">
{{ .Content }}
</article>
{{/* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. */}}
{{ $mainSections := .Site.Params.mainSections | default (slice "post") }}
{{/* Create a variable with that section to use in multiple places. */}}
{{ $section := where .Site.RegularPages "Section" "in" $mainSections }}
{{/* Check to see if the section is defined for ranging through it */}}
{{ $section_count := len $section }}
{{ if ge $section_count 1 }}
{{/* Derive the section name */}}
{{ $section_name := index (.Site.Params.mainSections) 0 }}

<div class="pa3 pa4-ns w-100 w-70-ns center">
{{/* Use $section_name to get the section title. Use "with" to only show it if it exists */}}
{{ with .Site.GetPage "section" $section_name }}
<h1 class="flex-none">
{{ $.Param "recent_copy" | default (i18n "recentTitle" .) }}
</h1>
{{ end }}

{{ $n_posts := $.Param "recent_posts_number" | default 3 }}

<section class="w-100 mw8">
{{/* Range through the first $n_posts items of the section */}}
{{ range (first $n_posts $section) }}
<div class="relative w-100 mb4">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
</section>

{{ if ge $section_count (add $n_posts 1) }}
<section class="w-100">
<h1 class="f3">{{ i18n "more" }}</h1>
{{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}}
{{ range (first 4 (after $n_posts $section)) }}
<h2 class="f5 fw4 mb4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "ml3" "mr3" }}">
<a href="{{ .RelPermalink }}" class="link black dim">
{{ .Title }}
</a>
</h2>
{{ end }}

{{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}}
{{ with .Site.GetPage "section" $section_name }}
<a href="{{ .RelPermalink }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">{{ i18n "allTitle" . }}</a>
{{ end }}
</section>
{{ end }}

</div>
{{ end }}
{{ end }}
36 changes: 36 additions & 0 deletions layouts/partials/site-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
<header class="cover bg-top" style="background-image: url('{{ $featured_image }}');">
<div class="{{ .Site.Params.cover_dimming_class | default "bg-black-60" }}">
{{ partial "site-navigation.html" .}}
<div class="tc-l pv4 pv5-l ph3 ph4-ns tc">
<span class="f2 white-90 fw2">Welcome to our communal</span>
<h1 class="f2 f-subheadline-l fw2 white-90 mb0 lh-title pa0 ma0">
{{ .Title | default .Site.Title }}
</h1>
{{ with .Params.description }}
<h2 class="fw1 f5 f3-l white-80 measure-wide-l center mt3">
{{ . }}
</h2>
{{ end }}
</div>
</div>
</header>
{{ else }}
<header>
<div class="pb3-m pb6-l {{ .Site.Params.background_color_class | default "bg-black" }}">
{{ partial "site-navigation.html" . }}
<div class="tc-l pv3 ph3 ph4-ns">
<h1 class="f2 f-subheadline-l fw2 light-silver mb0 lh-title">
{{ .Title | default .Site.Title }}
</h1>
{{ with .Params.description }}
<h2 class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">
{{ . }}
</h2>
{{ end }}
</div>
</div>
</header>
{{ end }}
Binary file modified static/sparvagn.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ff3f09a

Please sign in to comment.