Skip to content

Commit

Permalink
Removed canonifyurls and adjusted URL generation to create absolute p…
Browse files Browse the repository at this point in the history
…aths relative to the host.
  • Loading branch information
david-waltermire committed Feb 26, 2024
1 parent 9f95ad4 commit fa45b2a
Show file tree
Hide file tree
Showing 22 changed files with 352 additions and 176 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
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 href="{{ .Destination | safeURL }}"{{- with .Title }} title="{{ . }}"{{ end -}}>{{- with .Text | safeHTML }}{{ . }}{{ end -}}XX</a>
{{- /* chomp trailing newline */ -}}
18 changes: 9 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="{{ absURL "./module/hugo-uswds/js/uswds-init.min.js" }}"></script>
<link rel="preload" href="{{ absURL "./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="{{ absURL "./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="{{ absURL "./module/hugo-uswds/js/jquery.min.js" }}"></script>
<script type="text/javascript" defer src="{{ absURL "./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 @@ -56,7 +56,7 @@
{{- end -}}

{{- if ne .Kind "404" }}
<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>
<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 }}
Expand All @@ -69,15 +69,15 @@

{{ $usingImageMap := .Page.Store.Get "hasImageMap" }}
{{- if $usingImageMap }}
<script defer type="text/javascript" src="{{ absURL "./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="{{ absURL "./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
28 changes: 15 additions & 13 deletions layouts/shortcodes/usa-alert.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
<!--
parameters:
type: one of: info, error, warning, success
heading: the heading text
class: extra alert classes
body-class: extra alert boy classes
Inner: the alert text
-->
{{ $type := .Get "type" | default "info" }}
{{ $heading := .Get "heading" }}
{{ $validTypes := slice "info" "error" "warning" "success" }}
{{ if not (in $validTypes $type ) }}
{{ errorf "Invalid type %#v. Must be one of: info, error, warning, or success" $type }}
{{ end }}
{{ $heading := .Get "heading" }}
{{ if not ($heading) }}{{ errorf "missing value for param 'heading': %s" .Position }}{{ end }}
{{ $class := .Get "class" }}
{{ $bodyClass := .Get "body-class" }}
<div class="usa-alert usa-alert--{{ $type }}{{ if $class }} {{$class}}{{end}}" >
<div class="usa-alert usa-alert--{{ $type }}{{ if $class }} {{$class}}{{end}}">
<div class="usa-alert__body">
<h1 class="usa-alert__heading">{{ $heading | markdownify }}</h3>
{{ $markdown := .Inner | markdownify }}
{{ if findRE "<p>" $markdown }}
{{ if $bodyClass }}
{{- $markdown | replaceRE "<p>" (printf "<p class=\"usa-alert__text %s\">" $bodyClass) | safeHTML -}}
{{ else }}
{{- .Inner | markdownify | replaceRE "<p>" "<p class=\"usa-alert__text\">" | safeHTML -}}
{{ end }}
{{ else }}
<p class="usa-alert__text{{ if $bodyClass }} {{$bodyClass}}{{end}}">{{ $markdown }}</p>
{{ end }}
<h3 class="usa-alert__heading">{{ $heading | markdownify }}</h3>
<div class="usa-alert__text{{ if $bodyClass }} {{$bodyClass}}{{end}}">

{{ .Inner }}
</div>
</div>
</div>
48 changes: 30 additions & 18 deletions sass/hugo-uswds/src/styles/components/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,41 @@ li code, p code, td > code, td > a > code, div.callout code {
*/

/* fix code highlighting in alerts */
.usa-alert--success {
p code {
background-color: color('success-light');
@include at-media("desktop") {
.usa-alert .usa-alert__body {
@include u-padding-x(5)
}
}
.usa-alert--warning {
p code {
background-color: color('warning-light');
@include at-media("desktop") {
.usa-alert--no-icon .usa-alert__body {
@include u-padding-x(2)
}
}
.usa-alert--error {
p code {
background-color: color('error-light');
.usa-alert {
&--success {
p code {
background-color: color('success-light');
}
}
}
.usa-alert--info {
p code {
background-color: color('info-light');
&--warning {
p code {
background-color: color('warning-light');
}
}
}
.usa-alert--emergency {
p code {
background-color: color('emergency');
&--error {
p code {
background-color: color('error-light');
}
}
&--info {
p code {
background-color: color('info-light');
}
}
&--emergency {
p code {
background-color: color('emergency');
}
}
}

Expand All @@ -136,5 +148,5 @@ li code, p code, td > code, td > a > code, div.callout code {
}

.usa-prose > * + h1, .usa-prose > * + h2, .usa-prose > * + h3, .usa-prose > * + h4, .usa-prose > * + h5, .usa-prose > * + h6, * + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
margin-top: 1em;
margin-top: 0.5em;
}
Loading

0 comments on commit fa45b2a

Please sign in to comment.