1
0
Fork 0

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:
Joost De Cock 2021-08-25 16:09:31 +02:00
parent 1671a896b5
commit b34a2ee2ed
6132 changed files with 244167 additions and 0 deletions

View file

@ -0,0 +1,31 @@
---
title: add()
---
```js
Attributes attributes.add(string key, string value)
```
Adds `value` to the attribute identified by `key`.
Adding multiple values to the same key will result in them being joined together
(with a space) when rendering.
```js
let { Path, paths } = part.shorthand();
// This will render as: class="classA classB"
paths.demo = new Path();
paths.demo.attributes.add('class', 'classA');
paths.demo.attributes.add('class', 'classB');
// This does the same thing:
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
// This also has the same result:
paths.demo = new Path()
.attr('class', 'classA classB');
```

View file

@ -0,0 +1,20 @@
---
title: clone()
---
```js
Attributes attributes.clone()
```
Returns a new Attributes object that is a deep copy of this one.
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
paths.clone = paths.demo.clone()
```

View file

@ -0,0 +1,15 @@
---
title: Attributes
order: 40
---
Attributes is an object that holds attributes for a variety of other objects.
Attributes are attached to [`Point`](/reference/api/point), [`Path`](/reference/api/path), and [`Snippet`](/reference/api/snippet) objects,
as well as the internal [`Svg`](/reference/api/svg) object.
All of these have an instantiated Attributes object in their `attributes` property.
An Attributes object exposes the following methods:
<ReadMore list />

View file

@ -0,0 +1,22 @@
---
title: get()
---
```js
string attributes.get(string key)
```
Will return the value of attribute stored under `key`, or `false` if it's not set.
If key has multiple values, they will be joined together in a string, seperated by spaces.
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
let class = paths.demo.attributes.get('class');
// class now holds: "classA classB"
```

View file

@ -0,0 +1,21 @@
---
title: getAsArray()
---
```js
array attributes.getAsArray(string key)
```
Will return an array with the value of attribute stored under `key`, or `false` if it's not set.
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
let class = paths.demo.attributes.getAsArray('class');
// class now holds: ["classA", "classB"]
```

View file

@ -0,0 +1,147 @@
---
title: Attributes
---
Attributes is an object that holds attributes for a variety of other objects.
Attributes are attached to [`Point`](/reference/api/point), [`Path`](/reference/api/path), and [`Snippet`](/reference/api/snippet) objects, as well as the internal [`Svg`](/reference/api/svg) object.
All of these have an instantiated Attributes object in their `attributes` property.
An Attributes object exposes the following methods:
## add()
```js
Attributes attributes.add(string key, string value)
```
Adds `value` to the attribute identified by `key`.
Adding multiple values to the same key will result in them being joined together (with a space) when rendering.
### Attributes.add() example
```js
let { Path, paths } = part.shorthand();
// This will render as: class="classA classB"
paths.demo = new Path();
paths.demo.attributes.add('class', 'classA');
paths.demo.attributes.add('class', 'classB');
// This does the same thing:
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
// This also has the same result:
paths.demo = new Path()
.attr('class', 'classA classB');
```
## clone()
```js
Attributes attributes.clone()
```
Returns a new Attributes object that is a deep copy of this one.
## get()
```js
string attributes.get(string key)
```
Will return the value of attribute stored under `key`, or `false` if it's not set.
If key has multiple values, they will be joined together in a string, seperated by spaces.
### Attributes.get() example
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
let class = paths.demo.attributes.get('class');
// class now holds: "classA classB"
```
## getAsArray()
```js
array attributes.getAsArray(string key)
```
Will return an array with the value of attribute stored under `key`, or `false` if it's not set.
### Attributes.getAsArray() example
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
let class = paths.demo.attributes.getAsArray('class');
// class now holds: ["classA", "classB"]
```
## remove()
```js
Attributes attributes.remove(string key)
```
Removes the attribute values under key and returns the Attributes object.
### Attributes.remove() example
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
let class = paths.example.attributes
.remove()
.get('class');
// class now holds: false
```
## set()
```js
Attributes attributes.set(string key, string value)
```
Sets the attribute identified by `key` to value `value`.
<Warning>
This will overwrite any value that's currently set on the attribute identified by `key`.
</Warning>
### Attributes.set() example
```js
let { Path, paths } = part.shorthand();
// This will render as: class="classB"
paths.demo = new Path();
paths.demo.attributes.set('class', 'classA');
paths.demo.attributes.set('class', 'classB');
// This does the same thing:
paths.demo = new Path()
.attr('class', 'classA', true)
.attr('class', 'classB', true);
```

View file

@ -0,0 +1,22 @@
---
title: remove()
---
```js
Attributes attributes.remove(string key)
```
Removes the attribute values under key and returns the Attributes object.
```js
let { Path, paths } = part.shorthand();
paths.demo = new Path()
.attr('class', 'classA')
.attr('class', 'classB');
let class = paths.example.attributes
.remove()
.get('class');
// class now holds: false
```

View file

@ -0,0 +1,29 @@
---
title: set()
---
```js
Attributes attributes.set(string key, string value)
```
Sets the attribute identified by `key` to value `value`.
<Warning>
This will overwrite any value that's currently set on the attribute identified by `key`.
</Warning>
```js
let { Path, paths } = part.shorthand();
// This will render as: class="classB"
paths.demo = new Path();
paths.demo.attributes.set('class', 'classA');
paths.demo.attributes.set('class', 'classB');
// This does the same thing:
paths.demo = new Path()
.attr('class', 'classA', true)
.attr('class', 'classB', true);
```