diff --git a/README.md b/README.md index b77c4ce..e3fb1a2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A set of components and utilities to work faster with [DatoCMS](https://www.dato

- +

@@ -572,7 +572,6 @@ import SyntaxHighlight from 'components/SyntaxHighlight'; { const HeadingTag = `h${node.level}`; @@ -588,7 +587,7 @@ import SyntaxHighlight from 'components/SyntaxHighlight'; ); }), - + // Use a custom syntax highlighter component for code blocks renderRule(isCode, ({ node, key }) => { return ( @@ -600,14 +599,18 @@ import SyntaxHighlight from 'components/SyntaxHighlight'; /> ); }), - + // Apply different formatting to top-level paragraphs renderRule( isParagraph, ({ adapter: { renderNode }, node, children, key, ancestors }) => { if (isRoot(ancestors[0])) { // If this paragraph node is a top-level one, give it a special class - return renderNode('p', { key, className: 'top-level-paragraph-container-example' }, children); + return renderNode( + 'p', + { key, className: 'top-level-paragraph-container-example' }, + children, + ); } else { // Proceed with default paragraph rendering... // return renderNode('p', { key }, children); @@ -615,10 +618,8 @@ import SyntaxHighlight from 'components/SyntaxHighlight'; // Or even completely remove the paragraph and directly render the inner children: return children; } - } - ) - - + }, + ), ]} />; ``` @@ -636,3 +637,22 @@ Note: if you override the rules for `inline_item`, `item_link` or `block` nodes, | metaTransformer | `({ node, meta }) => Object \| null` | :x: | Transform `link` and `itemLink` meta property into HTML props | [See function](https://github.com/datocms/structured-text/blob/main/packages/generic-html-renderer/src/index.ts#L61) | | customRules | `Array` | :x: | Customize how document is converted in JSX (use `renderRule()` to generate) | `null` | | renderText | `(text: string, key: string) => ReactElement \| string \| null` | :x: | Convert a simple string text into React | `(text) => text` | + +## Development + +This repository contains a number of demos/examples. You can use them to locally test your changes to the package with `npm link`: + +``` +npm link +cd examples/images-and-seo/vanilla-react +npm link react-datocms +npm run start +``` + +Now on another terminal you can run: + +``` +npm run watch +``` + +This will re-compile the package everytime you make a change, and the example project will pick those changes instantly. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d8b82b9..67bc2da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "react-datocms", - "version": "1.6.7", + "version": "1.6.8", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.6.7", + "name": "react-datocms", + "version": "1.6.8", "license": "MIT", "dependencies": { - "datocms-listen": "^0.1.4", + "datocms-listen": "^0.1.6", "datocms-structured-text-generic-html-renderer": "^1.1.0", "datocms-structured-text-utils": "^1.1.0", "intersection-observer": "^0.12.0", @@ -2510,9 +2511,9 @@ "dev": true }, "node_modules/datocms-listen": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/datocms-listen/-/datocms-listen-0.1.4.tgz", - "integrity": "sha512-w4tDWI9x79pgJjzTTwVfYqYrs5KMcunY3cK0EjfKnS0zKYuDmTJuiAhxCyZRbLW0wBee2f5FMFxjL4vf+bURxA==" + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/datocms-listen/-/datocms-listen-0.1.7.tgz", + "integrity": "sha512-v0k6IStA6uCQa1rk03tVv2CfxUqDLa/ECN9hnYYGgV1BtZEj/HTbxvdsi/cCDPCi4iFQGY8xjqplnSgTXIA9tA==" }, "node_modules/datocms-structured-text-generic-html-renderer": { "version": "1.1.0", @@ -12673,9 +12674,9 @@ "dev": true }, "datocms-listen": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/datocms-listen/-/datocms-listen-0.1.4.tgz", - "integrity": "sha512-w4tDWI9x79pgJjzTTwVfYqYrs5KMcunY3cK0EjfKnS0zKYuDmTJuiAhxCyZRbLW0wBee2f5FMFxjL4vf+bURxA==" + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/datocms-listen/-/datocms-listen-0.1.7.tgz", + "integrity": "sha512-v0k6IStA6uCQa1rk03tVv2CfxUqDLa/ECN9hnYYGgV1BtZEj/HTbxvdsi/cCDPCi4iFQGY8xjqplnSgTXIA9tA==" }, "datocms-structured-text-generic-html-renderer": { "version": "1.1.0", diff --git a/package.json b/package.json index acb3790..2c8dc0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-datocms", - "version": "1.6.7", + "version": "1.6.8", "types": "dist/types/index.d.ts", "main": "dist/cjs/index.js", "module": "dist/esm/index.js",