From da6c71b00f07f04bd5ea7faba4e10ed41953ae37 Mon Sep 17 00:00:00 2001 From: Guillermo Guerrero Ibarra Date: Fri, 20 Aug 2021 12:29:02 +0200 Subject: Allow to add third party javascript or css libraries. (#240) * Allow to add third party javascript or css libraries. * Added missing places. * Update custom_headers.html * Added header. * Updated readme. * Removed comment. --- README.md | 8 ++- layouts/404.html | 5 +- layouts/_default/list.html | 5 +- layouts/_default/single.html | 5 +- layouts/index.html | 5 +- layouts/page/single.html | 5 +- layouts/partials/custom_headers.html | 0 layouts/partials/head.html | 103 ----------------------------------- layouts/partials/headers.html | 100 ++++++++++++++++++++++++++++++++++ static/css/custom.css | 2 - 10 files changed, 127 insertions(+), 111 deletions(-) create mode 100644 layouts/partials/custom_headers.html delete mode 100644 layouts/partials/head.html create mode 100644 layouts/partials/headers.html diff --git a/README.md b/README.md index f3478f3..4458104 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ style = "default" ``` Available options are: `default` (light-blue), `blue`, `green`, `marsala`, `pink`, `red`, `turquoise`, `violet`. +There is the possibility to override the CSS and set your custom styles, override this file `static/css/custom.css` in your site. ### Comments @@ -529,7 +530,7 @@ summaryLength = 70 [params.recent_posts] enable = true title = "From our blog" - subtitle = "Pellen + subtitle = "Pellen" hide_summary = false ``` @@ -641,6 +642,11 @@ Which results in the following HTML: ``` +If your site needs a custom Javascript library or CSS style you can override this file `layouts/partials/custom_headers.html` with the proper content like: + +```html + +``` ## Usage diff --git a/layouts/404.html b/layouts/404.html index dffac47..4bea486 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,7 +1,10 @@ - {{ partial "head.html" . }} + + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c0f7ea4..8a355f2 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,7 +1,10 @@ - {{ partial "head.html" . }} + + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + diff --git a/layouts/_default/single.html b/layouts/_default/single.html index d5b5c6e..15956c5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,7 +1,10 @@ - {{ partial "head.html" . }} + + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + diff --git a/layouts/index.html b/layouts/index.html index 43151ff..96209d4 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,7 +1,10 @@ - {{ partial "head.html" . }} + + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + diff --git a/layouts/page/single.html b/layouts/page/single.html index 28b4426..5e18140 100644 --- a/layouts/page/single.html +++ b/layouts/page/single.html @@ -1,7 +1,10 @@ - {{ partial "head.html" . }} + + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + diff --git a/layouts/partials/custom_headers.html b/layouts/partials/custom_headers.html new file mode 100644 index 0000000..e69de29 diff --git a/layouts/partials/head.html b/layouts/partials/head.html deleted file mode 100644 index a368d16..0000000 --- a/layouts/partials/head.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - {{ $title_plain := .Title | markdownify | plainify }} - {{ $title_plain }} - - {{ $keywords := .Site.Params.defaultKeywords | default (slice "" | first 0) }} - {{ if isset .Params "tags" }}{{ range .Params.tags }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} - {{ if isset .Params "keywords" }}{{ range .Params.keywords }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} - {{ if gt (len $keywords) 0 }} - - {{ end }} - {{ $description_plain := default .Site.Params.defaultDescription .Description | markdownify | plainify }} - - - {{ hugo.Generator }} - - - - - - - - - - - - - {{ with .Site.Params.style }} - - {{ else }} - - {{ end }} - - - - - - {{ ` - - ` | safeHTML }} - - - - - - - - - - - - - - {{ $is_blog := and (eq .Type "blog") (eq .Kind "page") }} - {{ $has_image := isset .Params "banner" }} - {{ $image := cond $has_image .Params.banner (.Site.Params.default_sharing_image | default "img/sharing-default.png") }} - {{ $is_valid_image := print "static/" $image | fileExists }} - {{ if $is_valid_image }} - {{ $image_ext := path.Ext $image }} - - - - - - - - - {{ with .Params.banner_alt }}{{ end }} - {{ $image_local := printf "/static/%s" $image}} - {{ with (imageConfig $image_local) }} - - - {{ end }} - {{ end }} - {{ with .Lastmod }}{{ end }} - {{ if $is_blog }} - {{ with .Param "facebook_site" }}{{ end }} - {{ with .Param "facebook_author" }}{{ end }} - {{ with .Params.categories }}{{ end }} - {{ range .Params.tags }} - {{ end }} - {{ if gt .ExpiryDate .PublishDate }}{{ end }} - {{ with .PublishDate }}{{ end }} - {{ with .Lastmod }}{{ end }} - {{ end }} - - - - {{ with .Param "twitter_site" }}{{ end }} - - {{ if $is_valid_image }} - - {{ end }} - - {{ with .Param "twitter_author" }}{{ end }} - - diff --git a/layouts/partials/headers.html b/layouts/partials/headers.html new file mode 100644 index 0000000..818adbb --- /dev/null +++ b/layouts/partials/headers.html @@ -0,0 +1,100 @@ + + + + +{{ $title_plain := .Title | markdownify | plainify }} +{{ $title_plain }} + +{{ $keywords := .Site.Params.defaultKeywords | default (slice "" | first 0) }} +{{ if isset .Params "tags" }}{{ range .Params.tags }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} +{{ if isset .Params "keywords" }}{{ range .Params.keywords }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} +{{ if gt (len $keywords) 0 }} + +{{ end }} +{{ $description_plain := default .Site.Params.defaultDescription .Description | markdownify | plainify }} + + +{{ hugo.Generator }} + + + + + + + + + + + + +{{ with .Site.Params.style }} + +{{ else }} + +{{ end }} + + + + + +{{ ` + +` | safeHTML }} + + + + + + + + + + + + + +{{ $is_blog := and (eq .Type "blog") (eq .Kind "page") }} +{{ $has_image := isset .Params "banner" }} +{{ $image := cond $has_image .Params.banner (.Site.Params.default_sharing_image | default "img/sharing-default.png") }} +{{ $is_valid_image := print "static/" $image | fileExists }} +{{ if $is_valid_image }} +{{ $image_ext := path.Ext $image }} + + + + + + + + +{{ with .Params.banner_alt }}{{ end }} +{{ $image_local := printf "/static/%s" $image}} +{{ with (imageConfig $image_local) }} + + +{{ end }} +{{ end }} +{{ with .Lastmod }}{{ end }} +{{ if $is_blog }} + {{ with .Param "facebook_site" }}{{ end }} + {{ with .Param "facebook_author" }}{{ end }} + {{ with .Params.categories }}{{ end }} + {{ range .Params.tags }} + {{ end }} + {{ if gt .ExpiryDate .PublishDate }}{{ end }} + {{ with .PublishDate }}{{ end }} + {{ with .Lastmod }}{{ end }} +{{ end }} + + + +{{ with .Param "twitter_site" }}{{ end }} + +{{ if $is_valid_image }} + +{{ end }} + +{{ with .Param "twitter_author" }}{{ end }} diff --git a/static/css/custom.css b/static/css/custom.css index d62cd94..a745873 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,5 +1,3 @@ -/* your styles go here */ - .box-image-text .image { min-height: 190px; max-height: 190px; -- cgit v1.2.3