Skip to content

Commit 6623d25

Browse files
committed
feat: add issue creation links (resolves #7)
1 parent aeaab88 commit 6623d25

File tree

8 files changed

+63
-15
lines changed

8 files changed

+63
-15
lines changed

.pages.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ content:
6767
type: string
6868
list: true
6969
description: Enter technologies used to build the website.
70-
- name: issues
70+
- name: issuesUrl
7171
label: Issues link
7272
type: string
73-
description: Enter the link to the website's issues page on GitHub, Gitlab or JIRA.
73+
description: Enter the link to the website's GitHub repository or Gitlab repository.
7474
required: false
7575
- label: Issues
7676
name: issue

eleventy.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {EleventyRenderPlugin} from '@11ty/eleventy';
22
import syntaxHighlightPlugin from '@11ty/eleventy-plugin-syntaxhighlight';
3+
import newIssueUrl from './src/_utils/new-issue-url.js';
34
import scTable from './src/_utils/sc-table.js';
45
import scUri from './src/_utils/sc-uri.js';
56
import sanitizeNumber from './src/_utils/sanitize-number.js';
@@ -8,7 +9,7 @@ export default function eleventy(eleventyConfig) {
89
eleventyConfig.addFilter('scUri', scUri);
910

1011
eleventyConfig.addNunjucksAsyncShortcode('scTable', scTable);
11-
12+
eleventyConfig.addShortcode('newIssueUrl', newIssueUrl);
1213
eleventyConfig.addLayoutAlias('report', 'report.njk');
1314

1415
eleventyConfig.addPlugin(EleventyRenderPlugin);

src/_layouts/report.njk

+5-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ layout: base
9494
{% for issue in issueList %}
9595
{% if issue.fileSlug !== page.fileSlug %}
9696
<article class="issue">
97-
<h3 id="{{ issue.data.title | slugify }}" class="issue-title"><span class="number">Issue {{ loop.index }}</span>{{ issue.data.title }}</h3>
97+
<header class="issue-title">
98+
<h3 id="{{ issue.data.title | slugify }}"><span class="number">Issue {{ loop.index }}</span>{{ issue.data.title }}</h3>
99+
{% newIssueUrl issue.data.title, issue.rawInput, issue.data.sample, issuesUrl %}
100+
</header>
98101
{{ issue.templateContent | safe }}
99102

100103
<div class="issue-meta">
@@ -118,7 +121,7 @@ layout: base
118121
</div>
119122
{% endif %}
120123
<div>
121-
<dt>Sample: </dt>
124+
<dt>Pages: </dt>
122125
{% if issue.data.sample == "all" %}
123126
<dd>All pages</dd>
124127
{% else %}

src/_utils/new-issue-url.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import newGithubIssueUrl from 'new-github-issue-url';
2+
3+
export default function newIssueUrl(title, body, sample, issuesUrl) {
4+
issuesUrl ||= '';
5+
6+
let issueUrl = '';
7+
8+
body = sample === 'all' ? `${body}\n#### Pages\n\n- All pages` : `${body}\n#### Pages\n\n- ${sample}`;
9+
10+
if (issuesUrl.includes('github')) {
11+
issueUrl = newGithubIssueUrl({
12+
repoUrl: issuesUrl,
13+
title,
14+
body,
15+
});
16+
}
17+
18+
if (issuesUrl.includes('gitlab')) {
19+
issueUrl = new URL(`${issuesUrl}/-/issues/new?issue[title]=${encodeURIComponent(title)}&issue[description]=${encodeURIComponent(body)}`);
20+
}
21+
22+
return `<a href="${issueUrl}" rel="external">Create an issue<span class="external">for '${title}' (external link)</span><svg aria-hidden="true" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" height="14" width="16"><path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" d="M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.4477 3 14 3H20C20.2652 3 20.5196 3.10536 20.7071 3.29289C20.8946 3.48043 21 3.73478 21 4L21 10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10L19 6.41422L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L17.5858 5H14ZM3 7C3 5.89543 3.89543 5 5 5H10C10.5523 5 11 5.44772 11 6C11 6.55228 10.5523 7 10 7H5V19H17V14C17 13.4477 17.4477 13 18 13C18.5523 13 19 13.4477 19 14V19C19 20.1046 18.1046 21 17 21H5C3.89543 21 3 20.1046 3 19V7Z" fill="currentColor"></path></svg></a>`;
23+
}

src/admin/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ collections:
7676
widget: list
7777
default: [HTML, CSS, JavaScript, WAI-ARIA, SVG]
7878
hint: Enter technologies used to build the website in a comma-separated list.
79-
- name: issues
79+
- name: issuesUrl
8080
label: Issues link
8181
widget: string
82-
hint: Enter the link to the website's issues page on GitHub, Gitlab or JIRA.
82+
hint: Enter the link to the website's GitHub repository or Gitlab repository.
8383
required: false
8484
- label: Issues
8585
label_singular: Issue

src/assets/styles/report.css

+16-5
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,22 @@ pre[class*='language-'] {
141141
border: 1px solid #d3d3d3;
142142
}
143143

144-
.issue-title {
144+
.issue header {
145+
align-items: flex-end;
145146
display: flex;
146-
flex-direction: column;
147+
justify-content: space-between;
147148
margin: -1rem -1rem 2rem;
148149
padding: 0.75rem 1em;
149150
background-color: #e6e6fa;
150151
}
151152

152-
.issue-title .number {
153+
.issue header h3 {
154+
margin-block: 0;
155+
display: flex;
156+
flex-direction: column;
157+
}
158+
159+
.issue header .number {
153160
display: block;
154161
padding: 0.25em 0.5em;
155162
font-size: 65%;
@@ -161,6 +168,10 @@ pre[class*='language-'] {
161168
width: auto;
162169
}
163170

171+
.issue header a {
172+
margin-block-end: 0.25rem;
173+
}
174+
164175
.issue-meta {
165176
margin: 2em -1em -1em;
166177
background: #eee;
@@ -180,7 +191,7 @@ pre[class*='language-'] {
180191
}
181192

182193
.issue-meta div {
183-
width: 100%;
194+
width: 45%;
184195
margin: 0 2.5% 2.5% 0;
185196
}
186197

@@ -205,7 +216,7 @@ pre[class*='language-'] {
205216
border-top: 1px solid #d3d3d3;
206217
}
207218

208-
.sample-list a {
219+
.sample-list li a {
209220
font-family: 'Noto Sans Mono', monospace;
210221
font-size: 0.75rem;
211222
color: #191970;

src/assets/styles/screen.css

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
@media (width >= 30em) {
1+
@media (width < 48em) {
2+
.issue header {
3+
align-items: flex-start;
4+
display: flex;
5+
flex-direction: column;
6+
gap: 1rem;
7+
}
8+
}
9+
10+
11+
@media (width < 30em) {
212
.issue-meta div {
3-
width: 45%;
13+
width: 100%;
414
}
515
}

src/report/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ technologies:
3636
- WAI-ARIA
3737
- SVG
3838

39-
issues: https://github.com/inclusive-design/idrc-wcag-reporter/
39+
issuesUrl: https://gitlab.com/inclusive-design/idrc-wcag-reporter
4040
---
4141
This website is partly accessible. Some severe issues were found and described in this report.

0 commit comments

Comments
 (0)