1
0
Fork 0

accessibility fixes

This commit is contained in:
Matthias Kretschmann 2022-11-19 16:31:07 +00:00
parent cf083d3288
commit c9a3f1cc28
Signed by: m
GPG Key ID: 606EEEF3C479A91F
11 changed files with 32 additions and 41 deletions

View File

@ -6,19 +6,20 @@ import { UMAMI_SCRIPT_URL, UMAMI_WEBSITE_ID } from './src/helpers/umami'
export const wrapPageElement: GatsbySSR['wrapPageElement'] = export const wrapPageElement: GatsbySSR['wrapPageElement'] =
wrapPageElementWithLayout wrapPageElementWithLayout
export const onRenderBody = ({ setPostBodyComponents }) => { export const onRenderBody = ({ setPostBodyComponents, setHtmlAttributes }) => {
const isEnabled = process.env.NODE_ENV === 'production' const isEnabled = process.env.NODE_ENV === 'production'
if (!isEnabled) { if (!isEnabled) {
return null return null
} }
const options = { const umamiOptions = {
src: UMAMI_SCRIPT_URL, src: UMAMI_SCRIPT_URL,
'data-website-id': UMAMI_WEBSITE_ID 'data-website-id': UMAMI_WEBSITE_ID
} }
return setPostBodyComponents([ setHtmlAttributes({ lang: 'en' })
<script key="umami-script" async defer {...options} /> setPostBodyComponents([
<script key="umami-script" async defer {...umamiOptions} />
]) ])
} }

View File

@ -1,13 +1,10 @@
import fs from 'fs' import fs from 'fs'
import util from 'util'
import fastExif from 'fast-exif' import fastExif from 'fast-exif'
import Fraction from 'fraction.js' import Fraction from 'fraction.js'
import getCoordinates from 'dms2dec' import getCoordinates from 'dms2dec'
import iptc from 'node-iptc' import iptc from 'node-iptc'
import type { Actions, NodePluginArgs, Node } from 'gatsby' import type { Actions, NodePluginArgs, Node } from 'gatsby'
const readFile = util.promisify(fs.readFile)
export const createExif = async ( export const createExif = async (
node: Node, node: Node,
actions: Actions, actions: Actions,
@ -19,7 +16,7 @@ export const createExif = async (
if (!exifData) return if (!exifData) return
// iptc // iptc
const file = await readFile(node.absolutePath as string) const file = fs.readFileSync(node.absolutePath as string)
const iptcData = iptc(file) const iptcData = iptc(file)
createNodes(exifData, iptcData, node, actions, createNodeId) createNodes(exifData, iptcData, node, actions, createNodeId)

View File

@ -1,10 +1,7 @@
import fs from 'fs' import fs from 'fs'
import util from 'util'
import path from 'path' import path from 'path'
import config from '../config' import config from '../config'
const writeFile = util.promisify(fs.writeFile)
const feedContent = ( const feedContent = (
edge: Queries.AllContentFeedQuery['allMarkdownRemark']['edges'][0] edge: Queries.AllContentFeedQuery['allMarkdownRemark']['edges'][0]
) => { ) => {
@ -63,14 +60,15 @@ const generateJsonFeed = async (
) => { ) => {
if (!posts) return if (!posts) return
await writeFile( try {
path.join('./public', 'feed.json'), fs.writeFileSync(
JSON.stringify(await createJsonFeed(posts)), path.join('./public', 'feed.json'),
'utf8' JSON.stringify(await createJsonFeed(posts)),
).catch((err) => { 'utf8'
throw Error('\nFailed to write JSON Feed file: ', err) )
}) } catch (error) {
throw Error('\nFailed to write JSON Feed file: ', error)
}
console.log('\nsuccess Generating JSON feed') console.log('\nsuccess Generating JSON feed')
} }

View File

@ -31,7 +31,7 @@ export default function Menu(): ReactElement {
return ( return (
<> <>
<Hamburger onClick={toggleMenu} /> <Hamburger onClick={toggleMenu} />
<nav className={styles.menu}> <nav aria-label="Pages" className={styles.menu}>
<ul>{MenuItems}</ul> <ul>{MenuItems}</ul>
</nav> </nav>
</> </>

View File

@ -79,7 +79,7 @@ export default function RelatedPosts({
} }
return ( return (
<aside className={styles.relatedPosts}> <section className={styles.relatedPosts}>
<h1 className={styles.title}> <h1 className={styles.title}>
Related {isPhotos ? 'Photos' : 'Posts'}{' '} Related {isPhotos ? 'Photos' : 'Posts'}{' '}
<button className={styles.button} onClick={() => refreshPosts()}> <button className={styles.button} onClick={() => refreshPosts()}>
@ -97,6 +97,6 @@ export default function RelatedPosts({
</li> </li>
))} ))}
</ul> </ul>
</aside> </section>
) )
} }

View File

@ -7,7 +7,7 @@ export default function ThemeSwitch(): ReactElement {
const { isDarkMode, setIsDarkMode } = useDarkMode() const { isDarkMode, setIsDarkMode } = useDarkMode()
return ( return (
<aside className={styles.themeSwitch} title="Toggle Dark Mode"> <div className={styles.themeSwitch} title="Toggle Dark Mode">
<label <label
htmlFor="toggle" htmlFor="toggle"
className={styles.checkbox} className={styles.checkbox}
@ -28,6 +28,6 @@ export default function ThemeSwitch(): ReactElement {
{isDarkMode ? <Icon name="Sun" /> : <Icon name="Moon" />} {isDarkMode ? <Icon name="Sun" /> : <Icon name="Moon" />}
</div> </div>
</label> </label>
</aside> </div>
) )
} }

View File

@ -24,10 +24,6 @@
///////////////////////////////////// */ ///////////////////////////////////// */
.title { .title {
margin: 0;
}
.title a {
display: block; display: block;
/* stylelint-disable-next-line font-family-no-missing-generic-family-keyword */ /* stylelint-disable-next-line font-family-no-missing-generic-family-keyword */
font: 0/0 a; font: 0/0 a;
@ -40,13 +36,13 @@
} }
@media (min-width: 40rem) { @media (min-width: 40rem) {
.title a { .title {
width: 212px; width: 212px;
} }
} }
.title a:hover svg, .title:hover svg,
.title a:focus svg { .title:focus svg {
fill: var(--link-color); fill: var(--link-color);
} }

View File

@ -10,13 +10,11 @@ export default function Header(): JSX.Element {
return ( return (
<header role="banner" className={styles.header}> <header role="banner" className={styles.header}>
<div className={styles.headerContent}> <div className={styles.headerContent}>
<h1 className={styles.title}> <Link to="/" className={styles.title}>
<Link to="/"> <Logo className={styles.logo} /> kremalicious
<Logo className={styles.logo} /> kremalicious </Link>
</Link>
</h1>
<nav role="navigation" className={styles.nav}> <nav aria-label="Menu" className={styles.nav}>
<ThemeSwitch /> <ThemeSwitch />
<Search /> <Search />
<Menu /> <Menu />

View File

@ -32,7 +32,7 @@ export default function PostActions({
const urlTwitter = `https://twitter.com/intent/tweet?text=@kremalicious&url=${siteUrl}${slug}` const urlTwitter = `https://twitter.com/intent/tweet?text=@kremalicious&url=${siteUrl}${slug}`
return ( return (
<aside className={styles.actions}> <section className={styles.actions}>
<Action <Action
title="Have a comment?" title="Have a comment?"
text="Hit me up @kremalicious" text="Hit me up @kremalicious"
@ -51,6 +51,6 @@ export default function PostActions({
url={githubLink} url={githubLink}
icon="GitHub" icon="GitHub"
/> />
</aside> </section>
) )
} }

View File

@ -11,14 +11,14 @@ const PostLinkActions = ({
linkurl?: string linkurl?: string
slug: string slug: string
}): ReactElement => ( }): ReactElement => (
<aside className={styles.postLinkActions}> <div className={styles.postLinkActions}>
<a className={stylesMore.postMore} href={linkurl}> <a className={stylesMore.postMore} href={linkurl}>
Go to source <Icon name="ExternalLink" /> Go to source <Icon name="ExternalLink" />
</a> </a>
<Link to={slug} rel="tooltip" title="Permalink"> <Link to={slug} rel="tooltip" title="Permalink">
<Icon name="Link" /> <Icon name="Link" />
</Link> </Link>
</aside> </div>
) )
export default PostLinkActions export default PostLinkActions

View File

@ -8,6 +8,7 @@ const PostToc = ({
}): ReactElement => { }): ReactElement => {
return ( return (
<nav <nav
aria-label="Table of Contents"
className={styles.toc} className={styles.toc}
dangerouslySetInnerHTML={{ __html: tableOfContents }} dangerouslySetInnerHTML={{ __html: tableOfContents }}
/> />