chore(docs): added eslint to lint documentation code blocks (#2920)

* docs: added rule for code length

* chore: fixes based on vale errors

* changed to use eslint

* fixes using eslint

* added github action for documentation eslint

* changed allowed max-length

* fixed incorrect heading level

* removed comment
This commit is contained in:
Shahed Nasser
2022-12-30 18:44:46 +02:00
committed by GitHub
parent 99add15fc3
commit d1b4b11ff6
67 changed files with 2611 additions and 1735 deletions
@@ -29,32 +29,32 @@ Heres an example of a migration created in a new file `contentful-migrations/
```jsx title=contentful-migrations/rich-text.js
#! /usr/bin/env node
require("dotenv").config();
require("dotenv").config()
const { runMigration } = require("contentful-migration");
const { runMigration } = require("contentful-migration")
const options = {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
environment: process.env.CONTENTFUL_ENVIRONMENT,
yes: true,
};
}
const migration = async () => {
await runMigration({
...options,
migrationFunction: function (migration, context) {
//create Rich Text content model
// create Rich Text content model
const richText = migration
.createContentType("richText")
.name("Rich Text")
.displayField("title");
.displayField("title")
richText.createField("title").name("Title (Internal)").type("Symbol");
richText.createField("body").name("Body").type("RichText");
richText.createField("title").name("Title (Internal)").type("Symbol")
richText.createField("body").name("Body").type("RichText")
//edit Page content model
// edit Page content model
const page = migration.editContentType("page")
page.editField("contentModules").items({
@@ -67,7 +67,7 @@ const migration = async () => {
],
})
//edit Product content model
// edit Product content model
const product = migration.editContentType("product")
product
@@ -83,11 +83,11 @@ const migration = async () => {
},
],
})
}
});
},
})
}
migration();
migration()
```
This example creates a new content model Rich Text that has two fields: title and body. It also edits the Page content model to allow using Rich Text content models on the page.
@@ -97,7 +97,19 @@ In addition, it edits the Product content model by adding a new field `contentMo
You can also add other types of content models the `contentModules` should accept. For example, to accept `tileSection` add it to the `linkContentType` option:
```jsx
linkContentType: ["tileSection", "richText"],
product
.createField("contentModules")
.name("Content Modules")
.type("Array")
.items({
type: "Link",
linkType: "Entry",
validations: [
{
linkContentType: ["richText", "tileSection"],
},
],
})
```
### Run a Contentful Migration
@@ -165,10 +177,10 @@ import { renderRichText } from "gatsby-source-contentful/rich-text"
const RichText = ({ data }) => {
return (
<div style={{
maxWidth: '870px',
margin: '0 auto',
paddingTop: '20px',
paddingBottom: '20px'
maxWidth: "870px",
margin: "0 auto",
paddingTop: "20px",
paddingBottom: "20px",
}}>
{data.body ? renderRichText(data.body) : ""}
</div>
@@ -194,7 +206,7 @@ Then, in the returned JSX add a new case to the switch statement:
```jsx title=src/pages/{ContentfulPage.slug}.js
switch (cm.internal.type) {
//...
// ...
case "ContentfulRichText":
return <RichText key={cm.id} data={cm} />
default:
+3 -3
View File
@@ -123,14 +123,14 @@ Then, in `medusa-config.js` in the exported object, comment out or remove the SQ
```jsx title=medusa-config.js
module.exports = {
projectConfig: {
//...
// ...
database_url: DATABASE_URL,
database_type: "postgres",
//REMOVE OR COMMENT OUT THE BELOW:
// REMOVE OR COMMENT OUT THE BELOW:
// database_database: "./medusa-db.sql",
// database_type: "sqlite",
},
};
}
```
### Migrate Content Types to Contentful