Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added performance measurements. #11

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading