diff --git a/backend/filesystem.js b/backend/filesystem.js index 9552582d..48c54f47 100644 --- a/backend/filesystem.js +++ b/backend/filesystem.js @@ -14,11 +14,8 @@ export async function getAllFiles(filePath) { } else { const relativeFiles = files.map((file) => { const relativePath = path.relative(process.cwd(), file) - if (path.basename(file) === 'index.md') { - return path.dirname(relativePath.replace(contentDir , "")) - } else { return relativePath.replace(contentDir , "") - } + }) resolve(relativeFiles.filter(Boolean)) } diff --git a/pages/index.js b/pages/index.js index 660e7717..c38654e6 100644 --- a/pages/index.js +++ b/pages/index.js @@ -39,56 +39,6 @@ import { import Topbar from '../components/TopBar'; -// const Logo = styled("img")({ -// display: "block", -// width: "auto", -// height: 30, -// }); - -// const HeroSection = styled('section')(({ theme }) => ({ -// position: 'relative', -// minHeight: '100vh', -// display: 'flex', -// alignItems: 'center', -// justifyContent: 'center', -// textAlign: 'center', -// color: '#fff', -// '&::before': { -// content: '""', -// position: 'absolute', -// top: 0, -// left: 0, -// right: 0, -// bottom: 0, -// backgroundImage: 'url("/backgrounds/sheffield.jpg")', -// backgroundSize: 'cover', -// backgroundPosition: 'center', -// opacity: 0.6, -// }, -// })); - -// const Overlay = styled('div')({ -// position: 'absolute', -// top: 0, -// left: 0, -// right: 0, -// bottom: 0, -// display: 'flex', -// alignItems: 'center', -// justifyContent: 'center', -// flexDirection: 'column', -// }); - -// const Section = styled('div')(({ theme }) => ({ -// padding: theme.spacing(8), -// })); - -// const Icon = styled('span')(({ theme }) => ({ -// fontSize: 48, -// marginBottom: theme.spacing(2), -// })); - - const SiteSection = ({ title, description, link }) => { @@ -122,7 +72,8 @@ const LandingPage = () => { {/* Hero Section */}
{ - setConfig({ ...state, value: String(content.content) , pageParms: router.query }) + setConfig({ ...state, value: String(content.content), pageParms: router.query }) }, []); @@ -340,19 +340,33 @@ function DefaultView({ export async function getStaticPaths() { - let paths = []; + let pages = []; let location = 'services'; try { const files = await getAllFiles(location) + + const pages = files.map((file) => { + + if (file.endsWith('index.md') || file.endsWith('index.mdx')) { + const filepath = file.split('/'); + filepath.pop(); + const joinedPath = filepath.join('/'); + return joinedPath; + } else { + return file + } + }) + + // console.log('getStaticPaths: ',pages ) return { fallback: true, - paths: files + paths: pages } } catch (error) { console.error(error) return { fallback: true, - paths: files + paths: pages } } @@ -360,7 +374,10 @@ export async function getStaticPaths() { } export async function getStaticProps(context) { + const location = 'services/' + context.params.parms.join('/') + '/index.mdx'; + // console.log('getStaticProps: ',location ) + try { const content = await getFileContent(location) // Pass null or an empty string for filePath return {