diff --git a/package.json b/package.json index 303b4e9009..e3a8f0be8e 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "build:production": "npm run cd:docs build:production", "build": "npm run cd:docs build", "cd:docs": "npm run _cd:docs -- npm run", + "check-links:all": "npm run cd:docs check-links:all", + "check-links": "npm run cd:docs check-links", "docs-install": "npm run _cd:docs -- npm install", "get:submodule": "set -x && git submodule update --init ${DEPTH:- --depth 1}", "serve": "npm run cd:docs serve", diff --git a/userguide/.gitignore b/userguide/.gitignore index a1b6687b10..c18d685e77 100644 --- a/userguide/.gitignore +++ b/userguide/.gitignore @@ -2,3 +2,4 @@ .hugo_build.lock /public resources/ +tmp diff --git a/userguide/.htmltest.yml b/userguide/.htmltest.yml new file mode 100644 index 0000000000..4a67a2bae0 --- /dev/null +++ b/userguide/.htmltest.yml @@ -0,0 +1,8 @@ +DirectoryPath: public +CheckDoctype: false # Sadly, this is false only because of `static/google*.html` +IgnoreAltMissing: true # FIXME +IgnoreDirectoryMissingTrailingSlash: true # FIXME +IgnoreDirs: [_print] # FIXME +IgnoreEmptyHref: true # FIXME +IgnoreInternalEmptyHash: true # FIXME +IgnoreInternalURLs: diff --git a/userguide/Makefile b/userguide/Makefile new file mode 100644 index 0000000000..7a4aa11f55 --- /dev/null +++ b/userguide/Makefile @@ -0,0 +1,21 @@ +HTMLTEST_DIR=tmp +HTMLTEST?=htmltest # Specify as make arg if different +HTMLTEST_ARGS?=--skip-external + +# Use $(HTMLTEST) in PATH, if available; otherwise, we'll get a copy +ifeq (, $(shell which $(HTMLTEST))) +override HTMLTEST=$(HTMLTEST_DIR)/bin/htmltest +ifeq (, $(shell which $(HTMLTEST))) +GET_LINK_CHECKER_IF_NEEDED=get-link-checker +endif +endif + +check-links: $(GET_LINK_CHECKER_IF_NEEDED) + $(HTMLTEST) $(HTMLTEST_ARGS) + +clean: + rm -rf $(HTMLTEST_DIR) public/* resources + +get-link-checker: + rm -Rf $(HTMLTEST_DIR)/bin + curl https://htmltest.wjdp.uk | bash -s -- -b $(HTMLTEST_DIR)/bin diff --git a/userguide/package.json b/userguide/package.json index 7f3dab7653..b40c316b49 100644 --- a/userguide/package.json +++ b/userguide/package.json @@ -2,14 +2,19 @@ "name": "docsy-user-guide", "scripts": { "_build": "npm run _hugo-dev", + "_check-links": "make check-links", "_hugo": "hugo --cleanDestinationDir --themesDir ../..", "_hugo-dev": "npm run _hugo -- -e dev -DFE", "_serve": "npm run _hugo-dev -- serve", "build:preview": "npm run _hugo-dev -- --minify --baseURL \"${DEPLOY_PRIME_URL:-/}\"", "build:production": "npm run _hugo -- --minify", "build": "npm run _build", + "check-links:all": "HTMLTEST_ARGS= npm run _check-links", + "check-links": "npm run _check-links", "clean": "rm -Rf public", "make:public": "git init -b main public", + "postbuild:preview": "npm run _check-links", + "postbuild:production": "npm run _check-links", "prepare": "cd .. && npm install", "serve": "npm run _serve" },