site_footer_license.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {{/* Display copyright license. */}}
  2. {{ $copyright_license := .Params.copyright.license | default site.Params.footer.copyright.license }}
  3. {{ $notice := .Params.copyright.notice | default site.Params.footer.copyright.notice }}
  4. {{ if ($copyright_license.enable | default false) }}
  5. {{ $allow_commercial := $copyright_license.allow_commercial | default false }}
  6. {{ $allow_derivatives := $copyright_license.allow_derivatives | default false }}
  7. {{ $share_alike := $copyright_license.share_alike | default true }}
  8. {{ $cc_code := "by" }}
  9. {{ if not $allow_commercial }}
  10. {{ $cc_code = printf "%s-nc" $cc_code }}
  11. {{end}}
  12. {{ if and $allow_derivatives $share_alike }}
  13. {{ $cc_code = printf "%s-sa" $cc_code }}
  14. {{ else if not $allow_derivatives }}
  15. {{ $cc_code = printf "%s-nd" $cc_code }}
  16. {{end}}
  17. {{ $license_url := printf "https://creativecommons.org/licenses/%s/4.0" ($cc_code | urlize) }}
  18. {{ with $notice }}
  19. <p class="powered-by copyright-license-text">
  20. {{ replace (replace . "{year}" now.Year) "{license}" (printf "<a href=\"%s\" rel=\"noopener noreferrer\" target=\"_blank\">CC %s 4.0</a>" $license_url (replace $cc_code "-" " " | upper)) | markdownify }}
  21. </p>
  22. {{ end }}
  23. <p class="powered-by footer-license-icons">
  24. <a href="{{$license_url}}" rel="noopener noreferrer" target="_blank" aria-label="Creative Commons">
  25. <i class="fab fa-creative-commons fa-2x" aria-hidden="true"></i>
  26. <i class="fab fa-creative-commons-by fa-2x" aria-hidden="true"></i>
  27. {{ if not $allow_commercial }}
  28. <i class="fab fa-creative-commons-nc fa-2x" aria-hidden="true"></i>
  29. {{end}}
  30. {{ if and $allow_derivatives $share_alike }}
  31. <i class="fab fa-creative-commons-sa fa-2x" aria-hidden="true"></i>
  32. {{ else if not $allow_derivatives }}
  33. <i class="fab fa-creative-commons-nd fa-2x" aria-hidden="true"></i>
  34. {{end}}
  35. </a>
  36. </p>
  37. {{ else }}
  38. {{ with $notice }}
  39. <p class="powered-by copyright-license-text">
  40. {{ replace . "{year}" now.Year | markdownify }}
  41. </p>
  42. {{ end }}
  43. {{ end }}