forked from andresgalante/patternfly-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateSitemap.js
32 lines (30 loc) · 890 Bytes
/
generateSitemap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* eslint no-console: 0 */
const axios = require('axios');
const fs = require('fs');
const path = require('path');
const allSitePagesQuery = {
query: `
query AllComponents {
examples: allSitePage(filter: { path: {regex: "/(components|demos|layouts|utilities).*examples-full/" } }) {
edges {
node {
id,
path
}
}
}
}
`
};
axios
// query all the pages we want to run our a11y tests against
.post('http://localhost:8000/___graphql?', allSitePagesQuery)
.then(response => {
// gather page objects from response data
const pages = response.data.data.examples.edges.map(edge => edge.node);
// write a nicely formatted array of pages to a file
fs.writeFileSync(path.resolve(__dirname, 'sitemap.json'), JSON.stringify(pages, null, 2));
})
.catch(error => {
console.log(error);
});