Skip to content

Commit 05a23da

Browse files
Merge pull request #2 from stackbithq/prettier-update
Update Prettier settings
2 parents e305fb0 + 4d0fce0 commit 05a23da

File tree

6 files changed

+521
-593
lines changed

6 files changed

+521
-593
lines changed

README.md

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ npm install sourcebit-target-hugo --save
2222

2323
The plugin accepts the following configuration parameters. They can be supplied in any of the following ways:
2424

25-
- In the `options` object of the plugin configuration block inside `sourcebit.js`, with the value of the _Property_ column as a key;
26-
- As an environment variable named after the _Env variable_ column, when running the `sourcebit fetch` command;
27-
- As part of a `.env` file, with the value of the _Env variable_ column separated by the value with an equals sign (e.g. `MY_VARIABLE=my-value`);
28-
- As a CLI parameter, when running the `sourcebit fetch` command, using the value of the _Parameter_ column as the name of the parameter (e.g. `sourcebit fetch --my-parameter`).
25+
- In the `options` object of the plugin configuration block inside `sourcebit.js`, with the value of the _Property_ column as a key;
26+
- As an environment variable named after the _Env variable_ column, when running the `sourcebit fetch` command;
27+
- As part of a `.env` file, with the value of the _Env variable_ column separated by the value with an equals sign (e.g. `MY_VARIABLE=my-value`);
28+
- As a CLI parameter, when running the `sourcebit fetch` command, using the value of the _Parameter_ column as the name of the parameter (e.g. `sourcebit fetch --my-parameter`).
2929

3030
| Property | Type | Visibility | Default value | Env variable | Parameter | Description |
3131
| ------------------ | -------- | ---------- | ------------- | ------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -34,9 +34,9 @@ The plugin accepts the following configuration parameters. They can be supplied
3434

3535
The `writeFile` function is invoked on each entry from the `objects` data bucket, with the following parameters:
3636

37-
- `entry` (Object): An entry from the `objects` data bucket
38-
- `utils` (Object): An object containing utility methods:
39-
- `slugify` (Function): Creates a filename-friendly version of any string (e.g. `utils.slugify('Hello, Sourcebit friends!') === 'hello-sourcebit-friends'`)
37+
- `entry` (Object): An entry from the `objects` data bucket
38+
- `utils` (Object): An object containing utility methods:
39+
- `slugify` (Function): Creates a filename-friendly version of any string (e.g. `utils.slugify('Hello, Sourcebit friends!') === 'hello-sourcebit-friends'`)
4040

4141
The return value of this function determines whether the entry being evaluated will be written to a file and, if so, defines the path, the format and the contents of the file.
4242

@@ -56,42 +56,33 @@ _sourcebit.js_
5656

5757
```js
5858
module.exports = {
59-
plugins: [
60-
{
61-
module: require("sourcebit-target-hugo"),
62-
options: {
63-
writeFile: function(entry, utils) {
64-
const { __metadata: meta, ...fields } = entry;
65-
66-
if (!meta) return;
67-
68-
const { createdAt = "", modelName, projectId, source } = meta;
69-
70-
if (
71-
modelName === "post" &&
72-
projectId === "123456789" &&
73-
source === "sourcebit-source-contentful"
74-
) {
75-
const { __metadata, content, layout, ...frontmatterFields } = entry;
76-
77-
return {
78-
content: {
79-
body: fields["content"],
80-
frontmatter: { ...frontmatterFields, layout: fields["layout"] }
81-
},
82-
format: "frontmatter-md",
83-
path:
84-
"content/posts/" +
85-
createdAt.substring(0, 10) +
86-
"-" +
87-
utils.slugify(fields["title"]) +
88-
".md"
89-
};
90-
}
59+
plugins: [
60+
{
61+
module: require('sourcebit-target-hugo'),
62+
options: {
63+
writeFile: function(entry, utils) {
64+
const { __metadata: meta, ...fields } = entry;
65+
66+
if (!meta) return;
67+
68+
const { createdAt = '', modelName, projectId, source } = meta;
69+
70+
if (modelName === 'post' && projectId === '123456789' && source === 'sourcebit-source-contentful') {
71+
const { __metadata, content, layout, ...frontmatterFields } = entry;
72+
73+
return {
74+
content: {
75+
body: fields['content'],
76+
frontmatter: { ...frontmatterFields, layout: fields['layout'] }
77+
},
78+
format: 'frontmatter-md',
79+
path: 'content/posts/' + createdAt.substring(0, 10) + '-' + utils.slugify(fields['title']) + '.md'
80+
};
81+
}
82+
}
83+
}
9184
}
92-
}
93-
}
94-
]
85+
]
9586
};
9687
```
9788

@@ -103,8 +94,8 @@ This plugin offers an interactive setup process via the `npx create-sourcebit` c
10394

10495
This plugin expects the following data buckets to exist:
10596

106-
- `models`: An array of content models
107-
- `objects`: An array of content entries
97+
- `models`: An array of content models
98+
- `objects`: An array of content entries
10899

109100
## 📤 Output
110101

0 commit comments

Comments
 (0)