-
Notifications
You must be signed in to change notification settings - Fork 21
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 #2454 from ONSdigital/cleanup/remove-website
Remove website generation
- Loading branch information
Showing
479 changed files
with
387 additions
and
11,035 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
export const pages = [ | ||
{ title: 'Components', uri: '/components' }, | ||
{ title: 'Patterns', uri: '/patterns' }, | ||
{ title: 'Foundations', uri: '/foundations' }, | ||
]; | ||
|
||
export const pagesWithIndex = pages.map(page => ({ ...page, uri: `${page.uri}/index.html` })); | ||
|
||
export const title = 'ONS Design System'; |
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,36 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import glob from 'glob'; | ||
|
||
function buildEntries(templatePath, type) { | ||
templatePath = path.resolve(templatePath); | ||
|
||
return { | ||
title: path.basename(templatePath, '.njk'), | ||
uri: templatePath.replace('.njk', '.html').substring(templatePath.indexOf(`/${type}`)), | ||
}; | ||
} | ||
|
||
export default async function createPageList(res, type = null, name = null) { | ||
try { | ||
let pages = []; | ||
if (type && name) { | ||
if (!fs.existsSync(`./src/${type}/${name}`)) { | ||
return res.status(404).send({ error: `${type} not found` }); | ||
} | ||
pages = glob.sync(`./src/${type}/${name}/example-*.njk`).map(templatePath => buildEntries(templatePath, type)); | ||
} else if (type) { | ||
const hasExample = glob.sync(`./src/${type}/**/*example-*`); | ||
const templatePath = Array.from(new Set(hasExample.map(filePath => path.dirname(filePath)))); | ||
|
||
if (templatePath.length) { | ||
pages = templatePath.map(folderPath => buildEntries(folderPath, type)); | ||
} | ||
} | ||
|
||
return pages; | ||
} catch (err) { | ||
console.error(err); | ||
return res.status(500).send({ error: 'An error occurred while building the page list' }); | ||
} | ||
} |
Oops, something went wrong.