Skip to content

Commit 108d4d4

Browse files
committed
Add hugo version check and theme update to Makefile (nginx#2608)
Update README.md with correct make target behaviors Add hugo-entrypoint to allow extra commands when docker starts Update hugo theme version in go.mod Use slimmer hugo docker image
1 parent c3ab01f commit 108d4d4

File tree

4 files changed

+35
-27
lines changed

4 files changed

+35
-27
lines changed

site/Makefile

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
HUGO?=hugo
2-
# the officially recommended unofficial docker image
3-
HUGO_IMG?=hugomods/hugo:0.115.3
2+
HUGO_VERSION?=$(shell hugo version 2>/dev/null | awk '{print $$2}' | cut -d '.' -f 2)
3+
HUGO_IMG?=hugomods/hugo:std-go-git-0.134.3
44

55
THEME_MODULE = github.com/nginxinc/nginx-hugo-theme
6-
## Pulls the current theme version from the Netlify settings
7-
THEME_VERSION = $(NGINX_THEME_VERSION)
8-
NETLIFY_DEPLOY_URL = ${DEPLOY_PRIME_URL}
96

10-
# if there's no local hugo, fallback to docker
11-
ifeq (, $(shell ${HUGO} version 2> /dev/null))
12-
ifeq (, $(shell docker version 2> /dev/null))
13-
$(error Docker and Hugo are not installed. Hugo (<0.91) or Docker are required to build the local preview.)
7+
ifeq ($(shell [ $(HUGO_VERSION) -gt 133 2>/dev/null ] && echo true || echo false), true)
8+
$(info Hugo is available and has a version greater than 133. Proceeding with build.)
149
else
15-
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} hugo
16-
endif
10+
$(warning Hugo is not available or using a version less than 134. Attempting to use docker. HUGO_VERSION=$(HUGO_VERSION))
11+
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} /src/hugo-entrypoint.sh
12+
ifeq (, $(shell docker version 2> /dev/null))
13+
$(error Hugo (>0.134) or Docker are required to build the local previews.)
14+
endif
1715
endif
1816

1917
MARKDOWNLINT?=markdownlint
@@ -22,9 +20,6 @@ MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest
2220
# if there's no local markdownlint, fallback to docker
2321
ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null))
2422
ifeq (, $(shell docker version 2> /dev/null))
25-
ifneq (, $(shell $(NETLIFY) "true"))
26-
$(error Docker and markdownlint are not installed. markdownlint or Docker are required to lint.)
27-
endif
2823
else
2924
MARKDOWNLINT=docker run --rm -i -v ${CURDIR}:/src --workdir /src ${MARKDOWNLINT_IMG}
3025
endif
@@ -35,23 +30,14 @@ MARKDOWNLINKCHECK_IMG?=ghcr.io/tcort/markdown-link-check:stable
3530
# if there's no local markdown-link-check, fallback to docker
3631
ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null))
3732
ifeq (, $(shell docker version 2> /dev/null))
38-
ifneq (, $(shell $(NETLIFY) "true"))
39-
$(error Docker and markdown-link-check are not installed. markdown-link-check or Docker are required to check links.)
40-
endif
4133
else
42-
MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/site --workdir /site ${MARKDOWNLINKCHECK_IMG}
34+
MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG}
35+
endif
4336
endif
4437
endif
4538

46-
.PHONY: all all-staging all-dev all-local clean hugo-mod build-production build-staging build-dev docs-drafts docs deploy-preview
47-
48-
all: hugo-mod build-production
49-
50-
all-staging: hugo-mod build-staging
51-
52-
all-dev: hugo-mod build-dev
5339

54-
all-local: clean hugo-mod build-production
40+
.PHONY: docs docs-draft docs-local clean hugo-get hugo-tidy lint-markdown link-check
5541

5642
docs:
5743
${HUGO}
@@ -65,6 +51,20 @@ watch:
6551
watch-drafts:
6652
${HUGO} --bind 0.0.0.0 -p 1313 server -D --disableFastRender
6753

54+
clean:
55+
[ -d "public" ] && rm -rf "public"
56+
57+
hugo-get:
58+
hugo mod get -u github.com/nginxinc/nginx-hugo-theme
59+
60+
hugo-tidy:
61+
hugo mod tidy
62+
63+
hugo-update: hugo-get hugo-tidy
64+
65+
lint-markdown:
66+
${MARKDOWNLINT} -c .markdownlint.yaml -- content
67+
6868
link-check:
6969
${MARKDOWNLINKCHECK} $(shell find content -name '*.md')
7070

site/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/nginxinc/nginx-gateway-fabric/site
22

33
go 1.21
44

5-
require github.com/nginxinc/nginx-hugo-theme v0.41.14 // indirect
5+
require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect

site/go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
github.com/nginxinc/nginx-hugo-theme v0.41.14 h1:OraNB01CdMJXufPddvIVt6qn6Mj38Z/XCVIWBgVtuY0=
22
github.com/nginxinc/nginx-hugo-theme v0.41.14/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
3+
github.com/nginxinc/nginx-hugo-theme v0.41.18 h1:4weO2h6L56lebyX7G+iqHd481RCXQQParhb1lARwdLQ=
4+
github.com/nginxinc/nginx-hugo-theme v0.41.18/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
5+
github.com/nginxinc/nginx-hugo-theme v0.41.19 h1:CyZOhU8q0p3nQ+ZTFRx7c/Dq9rxV1mShADIHz0vDoHo=
6+
github.com/nginxinc/nginx-hugo-theme v0.41.19/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=

site/hugo-entrypoint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
hugo mod get -u github.com/nginxinc/nginx-hugo-theme
4+
hugo $*

0 commit comments

Comments
 (0)