Skip to content

Commit 1060c00

Browse files
lucperkinsk8s-ci-robot
authored andcommitted
Use Hugo for Sass processing (#9404)
* Move all Sass into a common /assets directory * Remove node-sass make command * Change head partial to accommodate full Sass rules * Bump Hugo version in Netlify config * Use separate partial for CSS imports * Bump Hugo version * Remove PostCSS from the pipeline * Un-bump version * Update Hugo version to 0.44 * Update Hugo version in Makefile * Update production Hugo version * Fix misspelled variable name * Add ./resources folder to Git * Update Hugo version in Netlify config to 0.45.1 * Use un-cached css.html partial * Re-work extra CSS logic for .Params.css
1 parent ac493db commit 1060c00

20 files changed

+45
-21
lines changed

Makefile

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DOCKER = docker
2-
HUGO_VERSION = 0.40.3
2+
HUGO_VERSION = 0.44
33
DOCKER_IMAGE = kubernetes-hugo
44
DOCKER_RUN = $(DOCKER) run --rm --interactive --tty --volume $(PWD):/src
55

@@ -10,18 +10,14 @@ help: ## Show this help.
1010

1111
all: build ## Build site with production settings and put deliverables in _site.
1212

13-
sass: # Rebuild the SASS source into CSS
14-
node-sass --output-style compact ./src/sass/styles.sass ./static/css/styles.css
15-
node-sass --output-style compact ./src/sass/case_study_styles.sass ./static/css/case_study_styles.css
16-
1713
build: ## Build site with production settings and put deliverables in _site.
1814
hugo
1915

2016
build-preview: ## Build site with drafts and future posts enabled.
2117
hugo -D -F
2218

2319
serve: ## Boot the development server.
24-
hugo server
20+
hugo server --ignoreCache --disableFastRender
2521

2622
docker-image:
2723
$(DOCKER) build . --tag $(DOCKER_IMAGE) --build-arg HUGO_VERSION=$(HUGO_VERSION)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

content/en/docs/home/_index.md

-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ linkTitle: "Documentation"
1212
main_menu: true
1313
weight: 5
1414
---
15-
16-

layouts/partials/css.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- $mainSass := "sass/styles.sass" }}
2+
{{- $caseStudySass := "sass/case_study_styles.sass" }}
3+
<link rel="stylesheet" type="text/css" href="/css/base_fonts.css">
4+
{{- if .Site.IsServer }}
5+
{{- $mainCssOpts := (dict "targetPath" "css/styles.css") }}
6+
{{- $mainCss := resources.Get $mainSass | toCSS $mainCssOpts }}
7+
<link rel="stylesheet" media="screen" href="{{ $mainCss.RelPermalink }}"><!-- default styles.css on -->
8+
{{- else }}
9+
{{- $mainCssOpts := (dict "targetPath" "css/styles.css") }}
10+
{{- $mainCss := resources.Get $mainSass | toCSS $mainCssOpts | minify | fingerprint }}
11+
<link rel="stylesheet" media="screen" href="{{ $mainCss.RelPermalink }}" integrity="{{ $mainCss.Data.Integrity }}"><!-- default styles.css on -->
12+
{{- end }}
13+
{{- if .Params.case_study_styles }}
14+
{{- $caseStudyCssOpts := (dict "targetPath" "css/styles.css") }}
15+
{{- $caseStudyCss := resources.Get $caseStudySass | toCSS $caseStudyCssOpts | minify | fingerprint }}
16+
<link rel="stylesheet" media="screen" href="{{ $caseStudyCss.Permalink }}" integrity="{{ $caseStudyCss.Data.Integrity }}"><!-- custom case_study_styles on -->
17+
{{- end }}
18+
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
19+
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css">
20+
<link rel="stylesheet" type="text/css" href="{{ "css/callouts.css" | relURL }}">
21+
<link rel="stylesheet" type="text/css" href="{{ "css/custom-jekyll/tags.css" | relURL }}">
22+
{{- if .Params.deprecated }}
23+
<link rel="stylesheet" type="text/css" href="{{ "css/deprecation-warning.css" | relURL }}">
24+
{{- end }}
25+
{{- if eq .Params.class "gridPage" }}
26+
<link rel="stylesheet" type="text/css" href="{{ "css/gridpage.css" | relURL }}">
27+
{{- end }}
28+
{{- with .Params.css }}
29+
{{- range (split . ",") }}
30+
{{- $url := trim . " " | relURL }}
31+
<link rel="stylesheet" type="text/css" href="{{ $url }}"><!-- custom css added -->
32+
{{- end }}
33+
{{- end }}

layouts/partials/head.html

+1-10
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@
1111
<title>{{ if .Title }}{{ .Title }} - {{ end }}{{ .Site.Title }}</title>
1212
<meta name="viewport" content="width=device-width, initial-scale=1">
1313
<link rel="shortcut icon" type="image/png" href="{{ "images/favicon.png" | relURL }}">
14-
<link rel="stylesheet" type="text/css" href="/css/base_fonts.css">
15-
{{ if .Params.case_study_styles }}<link rel="stylesheet" type="text/css" href="{{ "css/case_study_styles.css" | relURL }}"><!-- custom case_study_styles on -->{{ else }}<link rel="stylesheet" type="text/css" href="{{ "css/styles.css" | relURL }}"><!-- default styles.css on -->{{ end }}
16-
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
17-
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css">
18-
<link rel="stylesheet" type="text/css" href="{{ "css/callouts.css" | relURL }}">
19-
<link rel="stylesheet" type="text/css" href="{{ "css/custom-jekyll/tags.css" | relURL }}">
20-
{{ if .Params.deprecated }}<link rel="stylesheet" type="text/css" href="{{ "css/deprecation-warning.css" | relURL }}">{{ end }}
21-
{{ if eq .Params.class "gridPage" }}<link rel="stylesheet" type="text/css" href="{{ "css/gridpage.css" | relURL }}">{{ end }}
22-
{{ with .Params.css }}{{ range (split . ",") }}<link rel="stylesheet" type="text/css" href="{{ (trim . " ") | relURL }}"><!-- custom css added -->
23-
{{ end }}{{ else }}<!-- no custom css detected -->{{ end }}
14+
{{ partial "css.html" . }}
2415
{{ if .Params.description }}
2516
<meta name="description" content="{{ .Params.description }}" />
2617
<meta property="og:description" content="{{ .Params.description }}" />

netlify.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ command = "hugo --enableGitInfo && cp netlify_noindex_headers.txt public/_header
55

66
[context.production.environment]
77
HUGO_BASEURL = "https://kubernetes.io/"
8-
HUGO_VERSION = "0.40.3"
8+
HUGO_VERSION = "0.45.1"
99
HUGO_ENV = "production"
1010
HUGO_ENABLEGITINFO = "true"
1111

1212
[context.deploy-preview]
1313
command = "hugo --enableGitInfo -b $DEPLOY_PRIME_URL"
1414

1515
[context.deploy-preview.environment]
16-
HUGO_VERSION = "0.40.3"
16+
HUGO_VERSION = "0.45.1"
1717

1818
[context.branch-deploy]
1919
command = "hugo --enableGitInfo -b $DEPLOY_PRIME_URL"
2020

2121
[context.branch-deploy.environment]
22-
HUGO_VERSION = "0.40.3"
22+
HUGO_VERSION = "0.45.1"
2323

2424
[context.master]
2525
# This context is triggered by the master branch and allows search indexing

resources/_gen/assets/sass/cn/sass/styles.sass_cb957da2191fde4902dd41b139c8069d.content

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Target":"css/styles.min.cc96976ab977e15130372b9aa336567b7cd2c0cfdbacc2884d84a5f56868cc20.css","MediaType":"text/css","Data":{"Integrity":"sha256-zJaXarl34VEwNyuaozZWe3zSwM/brMKITYSl9WhozCA="}}

resources/_gen/assets/sass/sass/case_study_styles.sass_cb957da2191fde4902dd41b139c8069d.content

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Target":"css/styles.min.3a4a157b6c0f5130dd7ada2cc65c770a1e7b22b443594d9f713ff99fd6ca0425.css","MediaType":"text/css","Data":{"Integrity":"sha256-OkoVe2wPUTDdetosxlx3Ch57IrRDWU2fcT/5n9bKBCU="}}

resources/_gen/assets/sass/sass/styles.sass_cb957da2191fde4902dd41b139c8069d.content

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Target":"css/styles.min.cc96976ab977e15130372b9aa336567b7cd2c0cfdbacc2884d84a5f56868cc20.css","MediaType":"text/css","Data":{"Integrity":"sha256-zJaXarl34VEwNyuaozZWe3zSwM/brMKITYSl9WhozCA="}}

0 commit comments

Comments
 (0)