Welcome to mirror list, hosted at ThFree Co, Russian Federation.

title.html « pages « partials « layouts - github.com/2-REC/hugo-myportfolio-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 16ff4327deb8b2c55974d854f6ab083ac842d23e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<hgroup class="title-block">
    {{/* Title */}}
    <h1>{{ .Title }}</h1>

    {{/* Subtitle */}}
    {{ with .Params.subtitle }}
        <h2>{{ . }}</h2>
    {{ end }}

    {{/* Period */}}
    {{ if .Params.startDate }}
    <h3>
        {{/* TODO: make partial + rewrite shorter/cleaner */}}
        {{ $start := dateFormat .Site.Params.projects.date_format .Params.startDate }}
        {{ $period := "" }}
        {{ if .Site.Params.projects.period_format }}
            {{ if .Params.endDate }}
                {{ $end := dateFormat .Site.Params.projects.date_format .Params.endDate }}
                {{ $period = replace .Site.Params.projects.period_format "{start}" $start }}
                {{ $period = replace $period "{end}" $end }}
            {{ else }}
                {{ if .Site.Params.projects.period_format_startonly }}
                    {{ $period = replace .Site.Params.projects.period_format_startonly "{start}" $start }}
                {{ else }}
                    {{ $period = replace .Site.Params.projects.period_format "{start}" $start }}
                    {{ $period = replace $period "{end}" "..." }}
                {{ end }}
            {{ end }}
        {{ else }}
            {{ if .Params.endDate }}
                {{ $end := dateFormat .Site.Params.projects.date_format .Params.endDate }}
                {{ $period = print "From " $start " to " $end }}
            {{ else }}
                {{ $period = print "From " $start }}
            {{ end }}
        {{ end }}
        {{ $period }}

        {{/* Duration */}}
        {{ $end := now }}
        {{ if .Params.endDate }}
            {{ $end = (time .Params.endDate) }}
        {{ end }}
        {{ $duration := $end.Sub (time .Params.startDate) }}
        {{ $months := int (div (int (div $duration.Hours 24)) 30.4167) }}
        {{ $years := int (div $months 12) }}
        {{ $months := int (sub $months (mul $years 12)) }}
        {{/* TODO: REWRITE! */}}
        | {{ if gt $years 0 }}{{ $years }} year{{ if gt $years 1 }}s{{ end }}{{ end }}{{ if and (gt $years 0) (gt $months 0) }}, {{ end }}{{ if gt $months 0 }}{{ $months }} month{{ if gt $months 1 }}s{{ end }}{{ end }}
    </h3>
    {{ end }}
</hgroup>