diff --git a/site/README.md b/site/README.md index 4b313bd1a..f4d4b3ccb 100644 --- a/site/README.md +++ b/site/README.md @@ -21,10 +21,11 @@ Docs are written in Markdown. We build the docs using [Hugo](https://gohugo.io). To build the docs locally, run the desired `make` command from the docs directory: ```text +make docs - builds the docs to the default output path `public` +make watch - runs a local hugo server so you can view docs in your browser while you work +make hugo-update - cleans the Hugo module cache and fetches the latest version of the theme module +make drafts - runs the local hugo server and includes all docs marked with `draft: true` make clean - removes the local `public` directory, which is the default output path used by Hugo -make docs - runs a local hugo server so you can view docs in your browser while you work -make hugo-mod - cleans the Hugo module cache and fetches the latest version of the theme module -make docs-drafts - runs the local hugo server and includes all docs marked with `draft: true` ``` ## Linting diff --git a/site/go.mod b/site/go.mod index b1614296c..b7ac6b63a 100644 --- a/site/go.mod +++ b/site/go.mod @@ -1,5 +1,5 @@ module github.com/nginx/agent/site -go 1.18 +go 1.22.0 -require github.com/nginxinc/nginx-hugo-theme v0.41.14 // indirect +require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect diff --git a/site/go.sum b/site/go.sum index 7db714541..5dbffbf03 100644 --- a/site/go.sum +++ b/site/go.sum @@ -1,16 +1,2 @@ -github.com/nginxinc/nginx-hugo-theme v0.28.0 h1:RHHvBmFk2Uptk+efLPSIuBd2elc3IOZPElkJbkkpAHo= -github.com/nginxinc/nginx-hugo-theme v0.28.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.33.0 h1:6mZdgxf5kNhInsrAXXiSlWXRy3fsP51lWKOdrvmkR6U= -github.com/nginxinc/nginx-hugo-theme v0.33.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.34.0-alpha h1:8tKWnkhxP5Nk0V64v8rE9T3crusycohXl3wmOWc4uFk= -github.com/nginxinc/nginx-hugo-theme v0.34.0-alpha/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.34.0 h1:G7LPVq7w1ls6IS4+OkTwjhFb67rLCzPdfZvW1/sn2Cw= -github.com/nginxinc/nginx-hugo-theme v0.34.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.35.0 h1:7XB2GMy6qeJgKEJy9wOS3SYKYpfvLW3/H+UHRPLM4FU= -github.com/nginxinc/nginx-hugo-theme v0.35.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.40.8 h1:VtoSAtf9k67tI2jzbLRo0oFBAMHZBUPRh/xV4MYullI= -github.com/nginxinc/nginx-hugo-theme v0.40.8/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.41.9 h1:8TKgjocF95ZSRP0PHkyvk9TyJvwPrdz1k0FB5RfKT3I= -github.com/nginxinc/nginx-hugo-theme v0.41.9/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= -github.com/nginxinc/nginx-hugo-theme v0.41.14 h1:OraNB01CdMJXufPddvIVt6qn6Mj38Z/XCVIWBgVtuY0= -github.com/nginxinc/nginx-hugo-theme v0.41.14/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= diff --git a/site/go.work b/site/go.work index 9a21ec734..582184033 100644 --- a/site/go.work +++ b/site/go.work @@ -1,4 +1,4 @@ -go 1.18 +go 1.22 use ( . diff --git a/site/hugo-entrypoint.sh b/site/hugo-entrypoint.sh new file mode 100755 index 000000000..dc7212352 --- /dev/null +++ b/site/hugo-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +hugo mod get -u github.com/nginxinc/nginx-hugo-theme +hugo $* diff --git a/site/makefile b/site/makefile index 849a80b0f..bb62ce8b6 100644 --- a/site/makefile +++ b/site/makefile @@ -1,28 +1,24 @@ HUGO?=hugo -HUGO_IMG?=hugomods/hugo:0.115.3 +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 -## Pulls the current theme version from the Netlify settings -THEME_VERSION = $(NGINX_THEME_VERSION) -# if there's no local hugo, fallback to docker -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.) +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 -endif + $(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 MARKDOWNLINT?=markdownlint MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest -# if there's no local markdownlint, fallback to docker ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null)) ifeq (, $(shell docker version 2> /dev/null)) -ifneq (, $(shell $(NETLIFY) "true")) - $(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 @@ -30,65 +26,39 @@ endif MARKDOWNLINKCHECK?=markdown-link-check MARKDOWNLINKCHECK_IMG?=ghcr.io/tcort/markdown-link-check:stable -# if there's no local markdown-link-check, fallback to docker + ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null)) ifeq (, $(shell docker version 2> /dev/null)) -ifneq (, $(shell $(NETLIFY) "true")) - $(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}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG} endif endif -.PHONY: all clean hugo-mod all-staging all-dev hugo-server-drafts hugo-server netlify deploy-preview -# Removes the public directory generated by the `hugo` command -clean: - if [[ -d ${PWD}/public ]] ; then rm -rf ${PWD}/public && echo "Removed public directory" ; else echo "Did not find a public directory to remove" ; fi - -hugo-mod: - hugo mod get $(THEME_MODULE)@v$(THEME_VERSION) - -# Builds using the Hugo "production" environment -# For deploys to docs.nginx.com only -all: hugo-mod - hugo --gc -e production - -# Builds using the Hugo "staging" environment -# For deploys to docs-staging.nginx.com only -all-staging: hugo-mod - hugo --gc -e staging - -# Builds using the Hugo "development" environment -# For deploys to docs-dev.nginx.com only -all-dev: hugo-mod - hugo --gc -e development - -# Runs the Hugo server with content marked as draft -# Serves docs at localhost:1313 -docs-drafts: - ${HUGO} server -D --disableFastRender - -docs-local: clean - ${HUGO} +.PHONY: docs docs-draft docs-local clean hugo-get hugo-tidy lint-markdown link-check -# Runs the Hugo server -# Serves docs at localhost:1313 docs: - ${HUGO} server --disableFastRender + ${HUGO} + +watch: + ${HUGO} --bind 0.0.0.0 -p 1313 server --disableFastRender + +drafts: + ${HUGO} --bind 0.0.0.0 -p 1313 server -D --disableFastRender + +clean: + [ -d "public" ] && rm -rf "public" + +hugo-get: + hugo mod get -u github.com/nginxinc/nginx-hugo-theme + +hugo-tidy: + hugo mod tidy + +hugo-update: hugo-get hugo-tidy lint-markdown: ${MARKDOWNLINT} -c .markdownlint.yaml -- content link-check: ${MARKDOWNLINKCHECK} $(shell find content -name '*.md') - -# Can be used to deploy to netlify from your local -# development environment. -# Requires a netlify login. -netlify: clean - netlify deploy --build -d public --alias $(shell git branch --show-current)-branch - -deploy-preview: hugo-mod - hugo --gc -b ${NETLIFY_DEPLOY_URL}/nginx-agent