Skip to content

Commit

Permalink
Merge pull request #11 from cagov/jbum-site-performance-review
Browse files Browse the repository at this point in the history
Added performance measurements.
  • Loading branch information
jbum authored Dec 19, 2023
2 parents 85454ba + 8abc90e commit 7d92770
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = function (eleventyConfig) {
}
// if inputPath doesn't exist, log it
if (fs.existsSync(inputPath)) {
console.log(" will score -> "+inputPath);
// console.log(" will score -> "+inputPath);
fileList.push({outputPath:outputPath, inputPath:inputPath});
// item.inputPath = inputPath;
// item.outputPath = outputPath;
Expand Down
28 changes: 28 additions & 0 deletions docs/site/_data/performance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = function () {
return new Promise(async (resolve, reject) => {
// console.log("FETCHING performance data");
// console.trace();
// see details about this API in readme
const perfAudits = await fetch("https://18ap0iejha.execute-api.us-west-1.amazonaws.com/?site=hub.innovation.ca.gov");
const perfData = await perfAudits.json();
let pagePerformanceData = {};
perfData.forEach(item => {
if(item.performance) {
pagePerformanceData[item.pageURL.replace('https://hub.innovation.ca.gov/','/')] = {
lighthouse: {
performance: item.performance,
accessibility: 1
}
}
}
if(item.accessibility) {
pagePerformanceData[item.pageURL.replace('https://hub.innovation.ca.gov/','/')].lighthouse.accessibility = item.accessibility;
}
})

console.log(pagePerformanceData);
resolve(pagePerformanceData);
});
};


8 changes: 6 additions & 2 deletions docs/site/_includes/par-scores.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
<p>ODI grades the reading level, performance, and accessibility of all our webpages. Here are this page’s scores as of the last update:</p>
<!-- placeholder markup for now -->
<div class="score-display">
{% if performance[page.url].lighthouse.performance %}
<span class="page-score-details">
<span class="page-score-block p-a-2">
<span class="speedlify-score {{50 | getScoreColor }}">50</span>
<span class="speedlify-score {{(performance[page.url].lighthouse.performance * 100) | getScoreColor }}">{{performance[page.url].lighthouse.performance * 100}}</span>
<span>Performance</span>
</span>
<a href="/page-score-info/#performance">Why is performance important</a>
</span>
{% endif %}
{% if performance[page.url].lighthouse.accessibility %}
<span class="page-score-details">
<span class="page-score-block p-a-2">
<span class="speedlify-score {{ 50 | getScoreColor }}">50</span>
<span class="speedlify-score {{ (performance[page.url].lighthouse.accessibility * 100) | getScoreColor }}">{{performance[page.url].lighthouse.accessibility * 100}}</span>
<span>Accessibility</span>
</span>
<a href="/page-score-info/#accessibility">Why is accessibility important</a>
</span>
{% endif %}
{% if readability[page.url].readability.ari %}
<span class="page-score-details">
<span class="page-score-block p-a-2">
Expand Down

0 comments on commit 7d92770

Please sign in to comment.