
These are some changes in the way the monorepo is structured, that are aimed at making it easier to get started. There are two important changes: **Multiple workspaces** We had a yarn workspaces setup at `packages/*`. But our monorepo has grown to 92 packages which can be overwhelming for people not familiar with the package names. To remedy this, I've split it into 4 different workspaces: - `designs/*`: Holds FreeSewing designs (think patterns) - `plugins/*`: Holds FreeSewing plugins - `packages/*`: Holds other packages published on NPM - `sites/*`: Holds software that is not published as an NPM package, such as our various websites and backend API This should make it easier to find things, and to answer questions like *where do I find the code for the plugins*. **Updated reconfigure script to handle build order** One problem when bootstrapping the repo is inter-dependencies between packages. For example, building a pattern will only work once `plugin-bundle` is built. Which will only work once all plugins in the bundle or built. And that will only work when `core` is built, and so on. This can be frustrating for new users as `yarn buildall` will fail. And it gets overlooked by seasoned devs because they're likely to have every package built in their repo so this issue doesn't concern them. To remedy this, we now have a `config/build-order.mjs` file and the updated `/scripts/reconfigure.mjs` script will enforce the build order so that things *just work*.
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
import React from 'react'
|
|
import { useRouter } from 'next/router'
|
|
import Link from 'next/link'
|
|
// Shared components
|
|
import Logo from 'shared/components/logos/freesewing.js'
|
|
import Aside from 'shared/components/navigation/aside'
|
|
import get from 'lodash.get'
|
|
|
|
const PageTitle = ({ app, slug, title }) => {
|
|
if (title) return <h1>{title}</h1>
|
|
if (slug) return <h1>{get(app.navigation, slug.split('/')).__title}</h1>
|
|
|
|
return <h1>FIXME: This page has no title</h1>
|
|
}
|
|
|
|
const Breadcrumbs = ({ app, slug=false, title }) => {
|
|
if (!slug) return null
|
|
const crumbs = []
|
|
const chunks = slug.split('/')
|
|
for (const i in chunks) {
|
|
const j = parseInt(i)+parseInt(1)
|
|
const page = get(app.navigation, chunks.slice(0,j))
|
|
if (page) crumbs.push([page.__linktitle, '/'+chunks.slice(0,j).join('/'), (j < chunks.length)])
|
|
}
|
|
|
|
return (
|
|
<ul className="flex flex-row flex-wrap gap-2 font-bold">
|
|
<li>
|
|
<Link href="/">
|
|
<a title="To the homepage" className="text-base-content">
|
|
<Logo size={24} fill="currentColor" stroke={false}/>
|
|
</a>
|
|
</Link>
|
|
</li>
|
|
{crumbs.map(crumb => (
|
|
<React.Fragment key={crumb[1]}>
|
|
<li className="text-base-content">»</li>
|
|
<li>
|
|
{crumb[2]
|
|
? (
|
|
<Link href={crumb[1]}>
|
|
<a title={crumb[0]} className="text-secondary hover:text-secondary-focus">
|
|
{crumb[0]}
|
|
</a>
|
|
</Link>
|
|
)
|
|
: <span className="text-base-content">{crumb[0]}</span>
|
|
}
|
|
</li>
|
|
</React.Fragment>
|
|
))}
|
|
</ul>
|
|
)
|
|
}
|
|
|
|
const DefaultLayout = ({ app, title=false, children=[] }) => {
|
|
const router = useRouter()
|
|
const slug = router.asPath.slice(1)
|
|
|
|
return (
|
|
<div className="m-auto flex flex-row justify-center">
|
|
<Aside app={app} slug={slug} />
|
|
<section className="py-28 md:py-36">
|
|
<div>
|
|
{title && (
|
|
<div className="px-8 xl:pl-8 2xl:pl-16">
|
|
<Breadcrumbs app={app} slug={slug} title={title} />
|
|
<PageTitle app={app} slug={slug} title={title} />
|
|
</div>
|
|
)}
|
|
{children}
|
|
</div>
|
|
</section>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default DefaultLayout
|