From 4f42c7a4354d9afd660bd5a3a8aff6772061cc7f Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Sun, 8 Oct 2023 08:43:31 +0100 Subject: [PATCH] markdown table updated --- README.md | 19 ++++++++++--------- .../generateExamplesTableMarkdown.js | 16 +++++++++------- ...ableMarkdown.js => updateTableMarkdown.js} | 4 +--- data/examples.json | 4 ++-- package.json | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) rename bin/{addExampleTableMarkdown.js => updateTableMarkdown.js} (59%) diff --git a/README.md b/README.md index 845beba9..23ed2e42 100644 --- a/README.md +++ b/README.md @@ -57,15 +57,16 @@ The examples in this repo are listed in the following table: -|   | ID | Short description | Tags | Download .zip | Live Demo | -| --------------------------------------------- | -------------------------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| ![](https://placehold.co/15x15/64756b/64756b) | [64756b](./plugins/dynamic-block-64756b) | Basic Dynamic Block | [`DYNAMIC BLOCK`](#dynamic-block), [`CREATE BLOCK`](#create-block) | 📦 | | -| ![](https://placehold.co/15x15/3df23d/3df23d) | [3df23d](./plugins/basic-block-3df23d) | Basic Static Block | [`STATIC BLOCK`](#static-block) | 📦 | | -| ![](https://placehold.co/15x15/833d15/833d15) | [833d15](./plugins/interactive-block-833d15) | Interactivity API Block | [`CREATE BLOCK TEMPLATE`](#create-block-template), [`INTERACTIVE BLOCK`](#interactive-block), [`INTERACTIVITY API`](#interactivity-api), [`GUTENBERG PLUGIN`](#gutenberg-plugin) | 📦 | | -| ![](https://placehold.co/15x15/b16608/b16608) | [b16608](./plugins/static-block-b16608) | Static Block | [`STATIC BLOCK`](#static-block) | 📦 | | -| ![](https://placehold.co/15x15/1b8c51/1b8c51) | [1b8c51](./plugins/editable-block-1b8c51) | Block Editable | | 📦 | | -| ![](https://placehold.co/15x15/56d6f3/56d6f3) | [56d6f3](./plugins/non-block-react-wp-data-56d6f3) | Non-block wp data with React | [`NO BLOCK`](#no-block), [`WP DATA`](#wp-data) | 📦 | | -| ![](https://placehold.co/15x15/ca6eda/ca6eda) | [ca6eda](./plugins/minimal-gutenberg-block-ca6eda) | Minimal Gutenberg Block | [`MINIMAL`](#minimal) | 📦 | | +|   | ID | Short description | Tags | Download .zip | Live Demo | +| --------------------------------------------- | -------------------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ![](https://placehold.co/15x15/64756b/64756b) | [64756b](./plugins/dynamic-block-64756b) | Basic Dynamic Block | [`DYNAMIC BLOCK`](#dynamic-block), [`CREATE BLOCK`](#create-block) | 📦 | | +| ![](https://placehold.co/15x15/3df23d/3df23d) | [3df23d](./plugins/basic-block-3df23d) | Basic Static Block | [`STATIC BLOCK`](#static-block) | 📦 | | +| ![](https://placehold.co/15x15/833d15/833d15) | [833d15](./plugins/interactive-block-833d15) | Interactivity API Block | [`CREATE BLOCK TEMPLATE`](#create-block-template), [`INTERACTIVE BLOCK`](#interactive-block), [`INTERACTIVITY API`](#interactivity-api), [`GUTENBERG PLUGIN`](#gutenberg-plugin) | 📦 | | +| ![](https://placehold.co/15x15/b16608/b16608) | [b16608](./plugins/static-block-b16608) | Static Block | [`STATIC BLOCK`](#static-block) | 📦 | | +| ![](https://placehold.co/15x15/1b8c51/1b8c51) | [1b8c51](./plugins/editable-block-1b8c51) | Block Editable | | 📦 | | +| ![](https://placehold.co/15x15/56d6f3/56d6f3) | [56d6f3](./plugins/non-block-react-wp-data-56d6f3) | Non-block wp data with React | [`NO BLOCK`](#no-block), [`WP DATA`](#wp-data) | 📦 | | +| ![](https://placehold.co/15x15/ca6eda/ca6eda) | [ca6eda](./plugins/minimal-block-ca6eda) | Minimal Block | [`MINIMAL`](#minimal) | 📦 | | +| ![](https://placehold.co/15x15/e621a6/e621a6) | [e621a6](./plugins/minimal-block-no-build-e621a6) | Minimal Gutenberg Block (No Build) | [`MINIMAL`](#minimal) | 📦 | | ### Tags diff --git a/bin/createGutenbergExample/generateExamplesTableMarkdown.js b/bin/createGutenbergExample/generateExamplesTableMarkdown.js index bda6f8bc..886725a5 100644 --- a/bin/createGutenbergExample/generateExamplesTableMarkdown.js +++ b/bin/createGutenbergExample/generateExamplesTableMarkdown.js @@ -18,13 +18,15 @@ const { const startMarker = ""; const endMarker = ""; -module.exports = ({ slug }) => { +module.exports = ({ slug: slugLastAdded }) => { const examplesJson = JSON.parse(fs.readFileSync(examplesJsonPath, "utf8")); const tagsJson = JSON.parse(fs.readFileSync(tagsJsonPath, "utf8")); const readmePathDisplay = readmePath.split("/gutenberg-examples-2023/")[1]; - info(`Updating ${readmePathDisplay} with example ${slug}...`); + let messageUpdate = `Updating ${readmePathDisplay}` + if (slugLastAdded) messageUpdate += ` with example ${slugLastAdded}` + info(messageUpdate) const markdownContent = fs.readFileSync(readmePath, "utf8"); @@ -32,10 +34,10 @@ module.exports = ({ slug }) => { `${startMarker}\(\[\.\\n\\s\\S\]\*\)${endMarker}`, "gm" ); - const markdownContentTable = markdownContent - .match(regex)[0] - .replace(startMarker, "") - .replace(endMarker, ""); + // const markdownContentTable = markdownContent + // .match(regex)[0] + // .replace(startMarker, "") + // .replace(endMarker, ""); const processedTags = tagsJson.reduce( (acc, { slug, name }) => ({ ...acc, [slug]: name }), @@ -71,7 +73,7 @@ module.exports = ({ slug }) => { try { fs.writeFileSync(readmePath, markdownContentWithUpdatedTable); - //info(`${readmePathDisplay} was updated!`); + info(`${readmePathDisplay} was updated!`); } catch (err) { error(`An error has ocurred when saving the file ${readmePath}`); error(err); diff --git a/bin/addExampleTableMarkdown.js b/bin/updateTableMarkdown.js similarity index 59% rename from bin/addExampleTableMarkdown.js rename to bin/updateTableMarkdown.js index e6d441a9..da67b6c0 100644 --- a/bin/addExampleTableMarkdown.js +++ b/bin/updateTableMarkdown.js @@ -1,5 +1,3 @@ const generateExamplesTableMarkdown = require("./createGutenbergExample/generateExamplesTableMarkdown.js"); -// get slug from command line const slug = process.argv[2]; -// generate markdown table -generateExamplesTableMarkdown({slug}); \ No newline at end of file +generateExamplesTableMarkdown({slug}); diff --git a/data/examples.json b/data/examples.json index 6007b23a..a202d3ef 100644 --- a/data/examples.json +++ b/data/examples.json @@ -45,8 +45,8 @@ ] }, { - "slug": "minimal-gutenberg-block-ca6eda", - "description": "Minimal Gutenberg Block", + "slug": "minimal-block-ca6eda", + "description": "Minimal Block", "tags": [ "minimal" ] diff --git a/package.json b/package.json index 22ab6f9c..68a536da 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test:e2e": "wp-scripts test-e2e", "create-example": "node ./bin/createGutenbergExample/index.js", "get:hexcode": "node ./bin/randomHexCode.js", - "table:add": "node ./bin/addExampleTableMarkdown.js", + "table:add": "node ./bin/updateTableMarkdown.js", "zips:remove": "rimraf --verbose ./plugins/*/@gutenberg-examples", "zips:move": "copyfiles --verbose --flat './plugins/**/*.zip' zips", "deploy": "npm run build && npm run plugin-zip && make-dir zips && npm run zips:move && npm run zips:remove"