-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from hankchizljaw/feature/create-md-generator
Create a generator that converts the json file into the README.md file
- Loading branch information
Showing
3 changed files
with
67 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var dataSet = require('../checklist.json'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
// For storing the main result. | ||
var result = ''; | ||
|
||
// Try and load up the intro | ||
result += fs.readFileSync(path.join(__dirname, '../intro.md')).toString() + '\n'; | ||
|
||
// Something has gone wrong with the dataset, so throw an error | ||
if(!dataSet.length) { | ||
console.error('Something has gone wrong checklist.json. There doesn\'t appear to be any items :('); | ||
return; | ||
} | ||
|
||
// Loop each item and generate a check item | ||
dataSet.map(function(data) { | ||
|
||
// Add a checkbox | ||
result += '- [ ] '; | ||
|
||
// Append the content of the item | ||
result += data.item; | ||
|
||
if(data.resources) { | ||
|
||
// For storing generated resources | ||
var resources = ''; | ||
|
||
// Loop each resource and generate a link | ||
data.resources.map(function(resource, index) { | ||
resources += ' [Resource #' + (index + 1) + '](' + resource + '),'; | ||
}); | ||
|
||
// Remove last comma and any space that follows it | ||
resources = resources.replace(/,\s*$/, ''); | ||
|
||
// Add resources to the result string | ||
result += resources; | ||
} | ||
|
||
// Add a line break | ||
result += '\n'; | ||
}); | ||
|
||
// Write the new .MD file | ||
fs.writeFileSync(path.join(__dirname, '../README.md'), result, { encoding: 'UTF-8' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Inclusive Web Design Checklist | ||
|
||
Aims to be the **biggest** checklist of inclusive design considerations for the web _ever_. Includes items for accessibility, performance, device support, interoperability, and language. Pull requests welcome! |