Skip to content

Commit

Permalink
Add hugo version check and theme update to Makefile (nginx#6599)
Browse files Browse the repository at this point in the history
  • Loading branch information
nginx-jack authored Oct 7, 2024
1 parent 437c30d commit fa9be7f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
32 changes: 16 additions & 16 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
HUGO?=hugo
HUGO_IMG?=hugomods/hugo:0.134.1
HUGO_VERSION?=$(shell hugo version 2>/dev/null | awk '{print $$2}' | cut -d '.' -f 2)
HUGO_IMG?=hugomods/hugo:std-go-git-0.134.3

THEME_MODULE = github.com/nginxinc/nginx-hugo-theme
THEME_VERSION ?= $(shell curl -s https://api.github.com/repos/nginxinc/nginx-hugo-theme/releases/latest | jq -r ".tag_name")

ifeq (, $(shell ${HUGO} version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
$(error Docker and Hugo are not installed. Hugo (<0.91) or Docker are required to build the local preview.)
HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo

ifeq ($(shell [ $(HUGO_VERSION) -gt 133 2>/dev/null ] && echo true || echo false), true)
$(info Hugo is available and has a version greater than 133. Proceeding with build.)
else
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} hugo --bind 0.0.0.0 -p 1313
$(warning Hugo is not available or using a version less than 134. Attempting to use docker. HUGO_VERSION=$(HUGO_VERSION))
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} /src/hugo-entrypoint.sh
ifeq (, $(shell docker version 2> /dev/null))
$(error Hugo (>0.134) or Docker are required to build the local previews.)
endif
endif
endif

HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo

MARKDOWNLINT?=markdownlint
MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest

ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
$(error Docker and markdownlint are not installed. markdownlint or Docker are required to lint.)
endif
else
MARKDOWNLINT=docker run --rm -i -v ${CURDIR}:/src --workdir /src ${MARKDOWNLINT_IMG}
endif
endif

MARKDOWNLINKCHECK?=markdown-link-check
MARKDOWNLINKCHECK_IMG?=ghcr.io/tcort/markdown-link-check:stable

ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
$(error Docker and markdown-link-check are not installed. markdown-link-check or Docker are required to check links.)
endif
else
MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/site --workdir /site ${MARKDOWNLINKCHECK_IMG}
MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG}
endif
endif


.PHONY: docs docs-draft docs-local clean hugo-get hugo-tidy lint-markdown link-check

Expand All @@ -51,11 +52,10 @@ drafts:
${HUGO} --bind 0.0.0.0 -p 1313 server -D --disableFastRender

clean:
hugo mod clean
[ -d "public" ] && rm -rf "public"

hugo-get:
hugo mod get $(THEME_MODULE)@$(THEME_VERSION)
hugo mod get -u github.com/nginxinc/nginx-hugo-theme

hugo-tidy:
hugo mod tidy
Expand Down
4 changes: 2 additions & 2 deletions docs/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/nginxinc/kubernetes-ingress/docs

go 1.23.0
go 1.23

require github.com/nginxinc/nginx-hugo-theme v0.41.17 // indirect
require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect
4 changes: 2 additions & 2 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nginxinc/nginx-hugo-theme v0.41.17 h1:KtF0TFQYXmVratjKVGEodWYFNbtxeOdrZLa9zi70BtA=
github.com/nginxinc/nginx-hugo-theme v0.41.17/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
github.com/nginxinc/nginx-hugo-theme v0.41.19 h1:CyZOhU8q0p3nQ+ZTFRx7c/Dq9rxV1mShADIHz0vDoHo=
github.com/nginxinc/nginx-hugo-theme v0.41.19/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
4 changes: 4 additions & 0 deletions docs/hugo-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

hugo mod get -u github.com/nginxinc/nginx-hugo-theme
hugo $*

0 comments on commit fa9be7f

Please sign in to comment.