feat: Flat import of markdown repo
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
This commit is contained in:
parent
1671a896b5
commit
b34a2ee2ed
6132 changed files with 244167 additions and 0 deletions
42
markdown/dev/howtos/code/adding-parts/en.md
Normal file
42
markdown/dev/howtos/code/adding-parts/en.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
title: Adding pattern parts
|
||||
for: developers
|
||||
about: Shows you how to add new parts to your pattern
|
||||
---
|
||||
|
||||
Since the patterns parts are listed
|
||||
in [the configuration file](/reference/config/), freesewing knows about
|
||||
all the parts that belong to your pattern.
|
||||
|
||||
It expects that each pattern has its own draft method, that is called `draft`
|
||||
followed by the capitalized name of the pattern part.
|
||||
|
||||
For example, if our pattern `Sorcha` has a part called `back`, you should
|
||||
have a `draftBack` method. It's good practice to keep each part in its own
|
||||
file, so create a file called `back.js`. Inside, you export your method
|
||||
to draft this part:
|
||||
|
||||
```js
|
||||
export default part => {
|
||||
// Your part code here
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
|
||||
Then, in your `index.js` file, you import this file, and attach the
|
||||
method to your pattern's prototype:
|
||||
|
||||
```js
|
||||
import freesewing from "freesewing"
|
||||
import plugins from "@freesewing/plugin-bundle"
|
||||
import config from "../config"
|
||||
// Parts
|
||||
import draftBack from "./back"
|
||||
|
||||
// Create new design
|
||||
const Sorcha = new freesewing.Design(config, plugins)
|
||||
|
||||
// Attach to pattern prototype
|
||||
Sorcha.prototype.draftBack = part => draftBack(part)
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue