Skip to content

Commit

Permalink
Work towards a 2.0.0 release (#37)
Browse files Browse the repository at this point in the history
* Fixed width of page right side navigation.

* Removed canonifyurls and adjusted URL generation to create absolute paths relative to the host.
Fixed width of page right side navigation. Fixed inconsistent line height in top navigation when a submenu is used.

* Ensure sufficient golang version is used.

* Updated GHA dependencies.

* Adjusted for absolute paths in hugo generation.

* Apply suggestions from code review

Co-authored-by: A.J. Stein <[email protected]>

---------

Co-authored-by: A.J. Stein <[email protected]>
  • Loading branch information
david-waltermire and aj-stein-nist authored Feb 27, 2024
1 parent 3c6b82f commit 959dd59
Show file tree
Hide file tree
Showing 29 changed files with 440 additions and 188 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/config/lychee.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
############################# Display #############################

# Verbose program output
# Accepts log level: "error", "warn", "info", "debug", "trace"
verbose = "info"

# Don't show interactive progress bar while checking links.
no_progress = false

# Path to summary output file.
output = ".config.dummy.report.md"

############################# Cache ###############################

# Enable link caching. This can be helpful to avoid checking the same links on
# multiple runs.
cache = true

# Discard all cached requests older than this duration.
max_cache_age = "2d"

############################# Runtime #############################

# Number of threads to utilize.
# Defaults to number of cores available to the system if omitted.
threads = 2

# Maximum number of allowed redirects.
max_redirects = 10

# Maximum number of allowed retries before a link is declared dead.
max_retries = 2

# Maximum number of concurrent link checks.
max_concurrency = 14

############################# Requests ############################

# User agent to send with each request.
user_agent = "curl/7.83. 1"

# Website timeout from connect to response finished.
timeout = 20

# Minimum wait time in seconds between retries of failed requests.
retry_wait_time = 2

# Comma-separated list of accepted status codes for valid links.
# Supported values are:
#
# accept = ["200..=204", "429"]
# accept = "200..=204, 429"
# accept = ["200", "429"]
# accept = "200, 429"
accept = ["200", "206", "429"]

# Proceed for server connections considered insecure (invalid TLS).
insecure = false

# Only test links with the given schemes (e.g. https).
# Omit to check links with any other scheme.
# At the moment, we support http, https, file, and mailto.
#scheme = ["https"]

# When links are available using HTTPS, treat HTTP links as errors.
require_https = false

# Request method
method = "get"

# Custom request headers
headers = []

# Remap URI matching pattern to different URI.
#remap = ["https://example.com http://example.invalid"]

# Base URL or website root directory to check relative URLs.
base = "https://pages.nist.gov/hugo-uswds"

# HTTP basic auth support. This will be the username and password passed to the
# authorization HTTP header. See
# <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization>
#basic_auth = ["example.com user:pwd"]

############################# Exclusions ##########################

# Skip missing input files (default is to error if they don't exist).
skip_missing = false

# Check links inside `<code>` and `<pre>` blocks as well as Markdown code
# blocks.
include_verbatim = false

# Ignore case of paths when matching glob patterns.
glob_ignore_case = false

# Exclude URLs and mail addresses from checking (supports regex).
exclude = ['^https://search\.usa\.gov/search', '^https://github\.com/usnistgov/hugo-uswds/tree/master/website/content/']

# Exclude these filesystem paths from getting checked.
#exclude_path = ["file/path/to/Ignore", "./other/file/path/to/Ignore"]

# URLs to check (supports regex). Has preference over all excludes.
include = ['gist\.github\.com.*']

# Exclude all private IPs from checking.
# Equivalent to setting `exclude_private`, `exclude_link_local`, and
# `exclude_loopback` to true.
exclude_all_private = false

# Exclude private IP address ranges from checking.
exclude_private = false

# Exclude link-local IP address range from checking.
exclude_link_local = false

# Exclude loopback IP address range and localhost from checking.
exclude_loopback = false

# Check mail addresses
include_mail = true
2 changes: 1 addition & 1 deletion .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: DefaultLabelsActions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: lannonbr/issue-label-manager-action@7890981d0e8f2922211a7fe2c391c53cb3037cb4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/status-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Metaschema CI/CD
name: CI/CD
on:
push:
branches:
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/workflow-generate-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ jobs:
- id: checkout_latest_workflow
name: Checkout Latest
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.commit_resources == 'true') || (github.event_name == 'push' && inputs.commit_resources == true)
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
token: ${{ env.GH_TOKEN }}
submodules: recursive
# use this for overything else (i.e., pull requests) where publication is not needed
- name: Checkout Latest
if: steps.checkout_latest_workflow.conclusion == 'skipped'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
submodules: recursive
- name: Setup Swap Space
Expand All @@ -73,13 +73,16 @@ jobs:
run: |
. .github/workflows/config/.env
echo "HUGO_VERSION=${HUGO_VERSION}" >> "${GITHUB_OUTPUT}"
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: '1.21'
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d
with:
hugo-version: '${{ steps.hugo-version.outputs.HUGO_VERSION }}'
extended: true
- name: Set up NodeJS
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version-file: '.github/workflows/config/.nvmrc'
cache: 'npm'
Expand All @@ -99,7 +102,7 @@ jobs:
# Dart-Sass
sudo snap install dart-sass
# cache hugo modules
- uses: actions/cache@v2
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
with:
path: /tmp/hugo_cache
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
Expand All @@ -108,7 +111,7 @@ jobs:
- name: Run Hugo
run: |
hugo mod vendor
hugo -e production --logLevel debug --minify
hugo -e production --logLevel debug --minify -d public/hugo-uswds
working-directory: ${{ github.workspace }}/website
- name: Zip Artifacts for Upload
run: |
Expand All @@ -125,7 +128,7 @@ jobs:
name: Link Checker
uses: lycheeverse/lychee-action@ec3ed119d4f44ad2673a7232460dc7dff59d2421
with:
args: --exclude-file .github/workflows/config/.lycheeignore --verbose --no-progress --accept 200,206,429 './website/public/**/*.html' --remap "https://pages.nist.gov/hugo-uswds/ file://${GITHUB_WORKSPACE}/website/public/" --exclude-mail
args: --exclude-file .github/workflows/config/.lycheeignore --verbose --no-progress --accept 200,206,429 './website/public/**/*.html' --remap "https://pages.nist.gov/hugo-uswds/ file://${GITHUB_WORKSPACE}/website/public/hugo-uswds/" --exclude-mail
format: markdown
output: html-link-report.md
debug: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/workflow-validate-repo-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
issues: write
steps:
# use this for pulls where checkout is anonymous
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
submodules: recursive
# Setup runtime environment
# -------------------------
- name: Set up NodeJS
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version-file: '.github/workflows/config/.nvmrc'
cache: 'npm'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/workflow-validate-website-content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
issues: write
steps:
- name: Checkout Latest
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0 # this ensures that the tag and commit history are available
- name: Checkout git ref of published website content
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ inputs.site_git_ref }}
path: ${{ inputs.site_git_ref_path }}
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The following configuration needs to be made regardless of the installation meth
In your project directory, update your `config.yaml` with the following:

```yaml
relativeURLs: true # rewrites URLs to a relative form supporting link offline checking
enableGitInfo: true # enable to get page modification dates for a site stored in Git
params:
header:
Expand Down Expand Up @@ -75,3 +74,25 @@ For detailed instruction, refer to the [Hugo Module documentation](https://gohug
- uswds
```
1. The theme is used the next time you run `hugo serve`.

## Development of this theme

When working on modifications to this theme, the following commands can be used to test and build the theme.

For initializing the module:

```bash
npm install
```

For live editing:

```bash
npx gulp
```

For building prior to release:

```bash
npm run prepare
```
4 changes: 2 additions & 2 deletions dist/css/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/css/styles.css.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<a {{ printf "href=%q" .Destination | safeHTMLAttr }}{{- with .Title }} title="{{ . }}"{{ end -}}>{{- with .Text | safeHTML }}{{ . }}{{ end -}}XX</a>
{{- /* chomp trailing newline */ -}}
20 changes: 11 additions & 9 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
{{ partialCached "meta.html" . }}
{{ end -}}

<script type="text/javascript" src="/module/hugo-uswds/js/uswds-init.min.js"></script>
<link rel="preload" href="/module/hugo-uswds/js/uswds.min.js" as="script">
<script type="text/javascript" src="{{ relURL "module/hugo-uswds/js/uswds-init.min.js" }}"></script>
<link rel="preload" href="{{ relURL "module/hugo-uswds/js/uswds.min.js" }}" as="script">

<link rel="stylesheet" href="/module/hugo-uswds/css/styles.css">
<link rel="stylesheet" href="{{ relURL "module/hugo-uswds/css/styles.css" }}">

{{ range .AlternativeOutputFormats }}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
{{ end -}}

<title>{{ block "title" . }}{{ .Title }}{{ end }}</title>
{{ template "_internal/google_analytics_async.html" . }}

<script type="text/javascript" src="/module/hugo-uswds/js/jquery.min.js"></script>
<script type="text/javascript" defer src="/module/hugo-uswds/js/hugo-uswds.min.js"></script>
<script type="text/javascript" src="{{ relURL "module/hugo-uswds/js/jquery.min.js" }}"></script>
<script type="text/javascript" defer src="{{ relURL "module/hugo-uswds/js/hugo-uswds.min.js" }}"></script>

{{ block "head" . }}
{{ partialCached "head.html" . }}
Expand Down Expand Up @@ -55,7 +55,9 @@
{{- partial "site-content.html" . -}}
{{- end -}}

<p class="font-sans-sm text-center" style="margin: 1.5rem auto">This page was last updated on {{ .Lastmod.Format "January 2, 2006" }}.{{ if .Site.Params.contentrepopath }} <button id="main-improve-page" onclick="window.location.href = '{{ .Site.Params.contentrepopath }}/{{ with .File }}{{ .Path }}{{ end }}';" class="usa-button">Improve this Page</button>{{ end }}</p>
{{- if ne .Kind "404" }}
<p class="font-sans-sm text-center" style="margin: 1.5rem auto; clear: both;">This page was last updated on {{ .Lastmod.Format "January 2, 2006" }}.{{ if .Site.Params.contentrepopath }} <button id="main-improve-page" onclick="window.location.href = '{{ .Site.Params.contentrepopath }}/{{ with .File }}{{ .Path }}{{ end }}';" class="usa-button">Improve this Page</button>{{ end }}</p>
{{- end -}}

{{- range .Site.Params.custom_js }}
<script type="text/javascript" src="{{ . | relURL }}"></script>
Expand All @@ -67,15 +69,15 @@

{{ $usingImageMap := .Page.Store.Get "hasImageMap" }}
{{- if $usingImageMap }}
<script defer type="text/javascript" src="/module/hugo-uswds/js/imageMapResizer.min.js"></script>
<script defer type="text/javascript" src="{{ relURL "module/hugo-uswds/js/imageMapResizer.min.js" }}"></script>
{{ end -}}

{{ $usingMermaid := .Page.Store.Get "hasMermaid" }}
{{ if $usingMermaid }}
<script type="module">import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/+esm'</script>
{{ end }}

<script type="text/javascript" src="/module/hugo-uswds/js/uswds.min.js"></script>
<script type="text/javascript" src="{{ relURL "module/hugo-uswds/js/uswds.min.js" }}"></script>

{{ block "foot" . }}
{{ partial "foot.html" . }}
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/components/usa-banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<img
aria-hidden="true"
class="usa-banner__header-flag"
src="{{"/module/hugo-uswds/img/us_flag_small.png" | relURL }}"
src="{{"module/hugo-uswds/img/us_flag_small.png" | relURL }}"
alt=""
/>
</div>
Expand Down Expand Up @@ -38,7 +38,7 @@
<div class="usa-banner__guidance tablet:grid-col-6">
<img
class="usa-banner__icon usa-media-block__img"
src="{{"/module/hugo-uswds/img/icon-dot-gov.svg" | relURL }}"
src="{{"module/hugo-uswds/img/icon-dot-gov.svg" | relURL }}"
role="img"
alt=""
aria-hidden="true"
Expand All @@ -54,7 +54,7 @@
<div class="usa-banner__guidance tablet:grid-col-6">
<img
class="usa-banner__icon usa-media-block__img"
src="{{"/module/hugo-uswds/img/icon-https.svg" | relURL }}"
src="{{"module/hugo-uswds/img/icon-https.svg" | relURL }}"
role="img"
alt=""
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/components/usa-header-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<button class="usa-menu-btn">Menu</button>
</div>
<nav aria-label="Primary navigation" class="usa-nav">
<button class="usa-nav__close"><img src="{{"/module/hugo-uswds/img/usa-icons/close.svg" | relURL }}" alt="close"></button>
<button class="usa-nav__close"><img src="{{ relURL "module/hugo-uswds/img/usa-icons/close.svg" }}" alt="close"></button>
{{ partialCached "components/usa-header/primary-nav.html" . }}
{{ partialCached "components/usa-search.html" . }}
</nav>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/components/usa-header-extended.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</header>
<nav class="site-nav usa-nav sticky" aria-label="Primary navigation">
<div class="usa-nav__inner site-nav__inner">
<button class="usa-nav__close"><img src="{{"/module/hugo-uswds/img/usa-icons/close.svg" | relURL }}" role="img" alt="close"></button>
<button class="usa-nav__close"><img src="{{ relURL "module/hugo-uswds/img/usa-icons/close.svg" }}" role="img" alt="close"></button>
{{ partialCached "components/usa-header/primary-nav.html" . }}
</div>
</nav>
2 changes: 1 addition & 1 deletion layouts/partials/components/usa-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<label class="usa-sr-only" for="search-field-en-small">Search</label>
<input class="usa-input" id="search-field-en-small" type="search" name="query">
<button class="usa-button" type="submit"><img
src="/module/hugo-uswds/img/usa-icons-bg/search--white.svg"
src="{{ relURL "module/hugo-uswds/img/usa-icons-bg/search--white.svg" }}"
class="usa-search__submit-icon"
alt="Search"
/></button>
Expand Down
Loading

0 comments on commit 959dd59

Please sign in to comment.