forked from andresgalante/patternfly-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateSitemap.js
35 lines (33 loc) · 870 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
33
34
35
/* 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: "/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);
});