
This is a flat (without history) import of (some of) the content from our markdown module. We've imported this without history because the repo contains our blog posts and showcases posts content prior to porting them to strapi. Since this contains many images, it would balloon the size of this repo to import the full history. Instead, please refer to the history of the (archived) markdown repo at: https://github.com/freesewing/markdown
1.9 KiB
title | order |
---|---|
Structure of a part | 150 |
Let's get rid of the example box first.
Open src/bib.js
and make sure it looks like this:
export default function(part) {
let { Point, points, Path, paths } = part.shorthand();
// Design pattern here
// Complete?
if (complete) {
if (sa) {
}
// Paperless?
if (paperless) {
}
}
return part;
}
This is an empty skeleton for a pattern part. Anytime you want to create a new part, this is a good starting point.
Let's quickly go over the different sections. Even if there's not much going on yet, it's always good to understand what's going on.
The draft method
export default function(part) {
// ...
return part;
}
This is the boilerplate of our draftBib
method. It takes the part as an argument, and returns it.
If you're new to JavaScript, and don't intuitively get this, stick with it. It will become second nature soon enough.
Using shorthand
let {
Point,
points,
Path,
paths,
} = part.shorthand();
This is FreeSewing's shorthand method. It returns an object with a bunch of handy helpers and you use JavaScript's object destructuring to only get what you need.
The example above makes the following variables available:
Point
: The Point constructorpoints
: A reference to the part's pointsPath
: The Path constructorpaths
: A reference to the part's paths
This will all become clear, but if you're curious, the API docs have all the details on the Part.shorthand() method
Part boilerplate
// Complete?
if (complete) {
if (sa) {
}
// Paperless?
if (paperless) {
}
}
This is some more boilerplate that makes sure we respect the complete
, sa
, and paperless
settings.
For now, you don't need to worry about this. Let's just start designing our bib.