home.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. {{ $author:= site.Data.author }}
  2. {{ if (index site.Data site.Language.Lang).author }}
  3. {{ $author = (index site.Data site.Language.Lang).author }}
  4. {{ end }}
  5. {{ $name:="Jane Doe" }}
  6. {{ if $author.nickname }}
  7. {{ $name = $author.nickname }}
  8. {{ else if $author.name }}
  9. {{ $name = $author.name }}
  10. {{ end }}
  11. {{ $sections:= site.Data.sections }}
  12. {{ if (index site.Data site.Language.Lang).sections }}
  13. {{ $sections = (index site.Data site.Language.Lang).sections }}
  14. {{ end }}
  15. {{ $backgroundImage:= "/images/default-background.jpg" }}
  16. {{ if site.Params.background }}
  17. {{ $backgroundImage = site.Params.background }}
  18. {{ end }}
  19. {{ $authorImage:= "/images/default-avatar.png" }}
  20. {{ if $author.image }}
  21. {{ $authorImage = $author.image }}
  22. {{ end }}
  23. {{ $authorImage := resources.Get $authorImage }}
  24. {{ $authorImage := $authorImage.Fit "148x148" }}
  25. {{/* get file that matches the filename as specified as src="" in shortcode */}}
  26. {{ $src := resources.Get $backgroundImage }}
  27. {{/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */}}
  28. {{ $tinyw := default "500x" }}
  29. {{ $smallw := default "800x" }}
  30. {{ $mediumw := default "1200x" }}
  31. {{ $largew := default "1500x" }}
  32. {{/* resize the src image to the given sizes */}}
  33. {{ $tiny := $src.Resize $tinyw }}
  34. {{ $small := $src.Resize $smallw }}
  35. {{ $medium := $src.Resize $mediumw }}
  36. {{ $large := $src.Resize $largew }}
  37. {{/* only use images smaller than or equal to the src (original) image size, as Hugo will upscale small images */}}
  38. {{/* set the sizes attribute to (min-width: 35em) 1200px, 100vw unless overridden in shortcode */}}
  39. {{ if lt $src.Width "500" }}
  40. {{ $tiny := $src}}
  41. {{ $small := $src}}
  42. {{ $medium := $src}}
  43. {{ $large := $src}}
  44. {{ end }}
  45. {{ if lt $src.Width "800" }}
  46. {{ $small := $src}}
  47. {{ $medium := $src}}
  48. {{ $large := $src}}
  49. {{ end }}
  50. {{ if lt $src.Width "1200" }}
  51. {{ $medium := $src}}
  52. {{ $large := $src}}
  53. {{ end }}
  54. {{ if lt $src.Width "1500" }}
  55. {{ $large := $src}}
  56. {{ end }}
  57. <div class="container-fluid home" id="home">
  58. <style>
  59. /* 0 to 299 */
  60. #homePageBackgroundImageDivStyled {
  61. /*background-image: url('{{ $tiny.RelPermalink }}'); This does not work on https://themes.gohugo.io/ */
  62. background-image: url('{{ strings.TrimSuffix "/" site.BaseURL }}{{ $tiny.RelPermalink }}');
  63. }
  64. /* 300 to X */
  65. @media (min-width: 500px) and (max-width: 800px) { /* or 301 if you want really the same as previously. */
  66. #homePageBackgroundImageDivStyled {
  67. background-image: url('{{ strings.TrimSuffix "/" site.BaseURL }}{{ $small.RelPermalink }}');
  68. }
  69. }
  70. @media (min-width: 801px) and (max-width: 1200px) { /* or 301 if you want really the same as previously. */
  71. #homePageBackgroundImageDivStyled {
  72. background-image: url('{{ strings.TrimSuffix "/" site.BaseURL }}{{ $medium.RelPermalink }}');
  73. }
  74. }
  75. @media (min-width: 1201px) and (max-width: 1500px) { /* or 301 if you want really the same as previously. */
  76. #homePageBackgroundImageDivStyled {
  77. background-image: url('{{ strings.TrimSuffix "/" site.BaseURL }}{{ $large.RelPermalink }}');
  78. }
  79. }
  80. @media (min-width: 1501px) { /* or 301 if you want really the same as previously. */
  81. #homePageBackgroundImageDivStyled {
  82. background-image: url('{{ strings.TrimSuffix "/" site.BaseURL }}{{ $src.RelPermalink }}');
  83. }
  84. }
  85. </style>
  86. <span class="on-the-fly-behavior"></span>
  87. <div
  88. id="homePageBackgroundImageDivStyled"
  89. class="background container-fluid"
  90. ></div>
  91. <div class="container content text-center">
  92. <img src="{{ $authorImage.RelPermalink }}"
  93. class="rounded-circle mx-auto d-block img-fluid"
  94. />
  95. <h1 class="greeting"> {{ $author.greeting }} {{ $name }}</h1>
  96. <div class="typing-carousel">
  97. <span id="ityped" class="ityped"></span>
  98. <span class="ityped-cursor"></span>
  99. </div>
  100. <ul id="typing-carousel-data">
  101. {{ if $author.summary }}
  102. {{ range $author.summary }}
  103. <li>{{ . }}</li>
  104. {{ end}}
  105. {{ end }}
  106. </ul>
  107. {{ if $sections }}
  108. {{ range first 1 (where (sort $sections "section.weight") ".section.enable" true) }}
  109. {{ $sectionID := replace (lower .section.name) " " "-" }}
  110. {{ if .section.id }}
  111. {{ $sectionID = .section.id }}
  112. {{ end }}
  113. <a href="#{{ $sectionID }}"><i class="arrow bounce fa fa-chevron-down"></i></a>
  114. {{ end }}
  115. {{ end }}
  116. </div>
  117. </div>