diff --git a/README.md b/README.md index bec041311..253754b0b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/atherdon/markdown-to-email) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/LLazyEmail/markdown-to-email) This simple and light tool generates email template from markdown. The command is `npm run dev:parseFull`. The path to markdown file must be `./source/source.md`, and output directory is `generated/newEmail.html`. diff --git a/bash/lint-fix.sh b/bash/lint-fix.sh new file mode 100644 index 000000000..0715f66d3 --- /dev/null +++ b/bash/lint-fix.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +yarn eslint -c ./.eslintrc.js ./src --fix --ignore-pattern \"./package.json\" \ No newline at end of file diff --git a/bash/pre-push-check.sh b/bash/pre-push-check.sh index b17634e1c..a85bbde9b 100644 --- a/bash/pre-push-check.sh +++ b/bash/pre-push-check.sh @@ -1 +1 @@ -### nothing here yer +### nothing here yet diff --git a/bash/prettier-fix.sh b/bash/prettier-fix.sh new file mode 100644 index 000000000..690f17317 --- /dev/null +++ b/bash/prettier-fix.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +yarn install && yarn prettier --write '**/*.js' \ No newline at end of file diff --git a/package.json b/package.json index 62bd9c01a..dd3f5ba39 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,10 @@ "dev:parseFull": "cross-env PARSE=full rollup -c -w", "dev:parseFullRecipes": "cross-env PARSE=recipesFull rollup -c -w", "dev:parseReactFull": "cross-env PARSE=reactFull rollup -c -w", + "dev:parseFrontHN": "cross-env PARSE=hackernnonFront rollup -c -w", "prod:parseFull": "npm run build && cross-env PARSE=full node ./dist/bundle", "prod:parseReactFull": "npm run build && cross-env PARSE=reactFull node ./dist/bundle", "test:react": "npm run checkFolders && jest ./src/parserMDReact/tests", - "lint:fix": "eslint -c ./.eslintrc.js ./src --fix --ignore-pattern \"./package.json\" ", - "lint": "eslint -c ./.eslintrc.js ./src --quiet --ignore-pattern \"./package.json\" ", "checkFolders": "node ./checkFolders", "test": "npm run checkFolders && jest ./src/tests", "test:typography": "jest --all --testPathPattern=./src/tests/typography", @@ -20,7 +19,9 @@ "test:custom": "jest --watchAll --all --testPathPattern=./src/tests/custom", "test:watch": "npm run checkFolders && jest --watch ./src/tests", "prepare": "husky install", - "fix:prettier": "prettier --write '**/*.js'" + "prettier:fix": "bash ./bash/prettier-fix.sh", + "lint": "eslint -c ./.eslintrc.js ./src --quiet --ignore-pattern \"./package.json\" ", + "lint:fix": "bash ./bash/lint-fix.sh" }, "author": "atherdon, vadim9999, hirdbluebird", "license": "ISC", @@ -44,7 +45,7 @@ "husky": "7.0.0", "jest": "27.5.1", "lint-staged": "12.4.1", - "markup-generator": "^2.5.0", + "markup-generator": "^2.7.0", "prettier": "2.7.0", "rollup": "2.75.6", "rollup-plugin-node-polyfills": "0.2.1", @@ -54,7 +55,7 @@ "atherdon-newsletter-js-layouts-body": "^3.2.0", "atherdon-newsletter-js-layouts-typography": "^3.0.0", "atherdon-newsletter-react-layouts-typography": "^0.4.0", - "atherdon-old-newsletter-js-outertemplate": "^3.7.0", + "atherdon-old-newsletter-js-outertemplate": "^3.9.0", "chalk": "5.0.1", "cross-env": "7.0.3", "lodash": "4.17.21", diff --git a/package/__ToUseLater/converter/___template.js b/package/__ToUseLater/converter/___template.js deleted file mode 100644 index 16449f442..000000000 --- a/package/__ToUseLater/converter/___template.js +++ /dev/null @@ -1,35 +0,0 @@ -const { - REGEXP_HEADER, - REGEXP_SPONSORSHIP, - REGEXP_HTML_COMMENTS, - REGEXP_PREVIEW_TEXT, -} = require('atherdon-newsletter-constants'); - -const { header, sponsorship } = require('../callbacks'); - -// const layouts = require("atherdon-newsletter-constants"); - -const ConverterBody = { - header: { - key: 'REGEXP_HEADER', - value: header, - // title: "xxx", - }, - comments: { - key: 'REGEXP_HTML_COMMENTS', - // value: 1, - // title: "xxx", - }, - previewText: { - key: 'REGEXP_PREVIEW_TEXT', - // value: 1, - // title: "xxx", - }, - sponsor: { - key: 'REGEXP_SPONSORSHIP', - value: sponsorship, - // title: "xxx", - }, -}; - -module.exports = ConverterBody; diff --git a/package/__ToUseLater/converter/full-we-need-to-move-missing-parts.js b/package/__ToUseLater/converter/full-we-need-to-move-missing-parts.js deleted file mode 100644 index 0f24ffe7b..000000000 --- a/package/__ToUseLater/converter/full-we-need-to-move-missing-parts.js +++ /dev/null @@ -1,101 +0,0 @@ -const { - REGEXP_HEADER, - REGEXP_IMAGE, - REGEXP_LINK, - REGEXP_STRONG, - REGEXP_DEL, - REGEXP_Q, - REGEXP_CODE, - REGEXP_UL_LIST, - REGEXP_OL_LIST, - REGEXP_BLOCKQUOTE, - REGEXP_HR, - REGEXP_PARAGRAPH, - REGEXP_EMPTY_UL, - REGEXP_EMPTY_OL, - REGEXP_BR, - REGEXP_EMPTY_BLOCKQUOTE, - REGEXP_EM, - REGEXP_SPONSORSHIP, - REGEXP_HTML_COMMENTS, - REGEXP_MEM, - REGEXP_PREVIEW_TEXT, -} = require('atherdon-newsletter-constants'); - -const { - header, - image, - link, - ulList, - olList, - blockquote, - paragraphWrapper, - sponsorship, - br, - strong, - mem, - italic, - del, - q, - code, - hr, - empty, - newLine, -} = require('atherdon-callbacks'); - -// const layouts = require("atherdon-newsletter-constants"); - -const ConverterTypography = { - heading: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - image: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - italic: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - link: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - list: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - listItem: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - mainTitle: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - paragraph: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - strong: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - subtitle: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, -}; - -// export data diff --git a/source/front-matter/03-hackernoon-source.md b/source/front-matter/03-hackernoon-source.md new file mode 100644 index 000000000..2eb77bc7e --- /dev/null +++ b/source/front-matter/03-hackernoon-source.md @@ -0,0 +1,132 @@ +--- +preview: "As a developer, you might have dreamed of a Google created specifically for techies. Just imagine, a digital platform brimming with content for coders, including Q&A and job listings. Every question about programming answered. Each inextricable bug is solved. A larger audience of qualified experts come-at-able. Sounds dreamlike, right?" +title: "Secrets Of High-Performing Teams: Part II" +ads: + - slogan: The security-as-code solution for developers + - link: https://bit.ly/3n9CgbE + - logo: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/logos/thematic/2020/October/Bridgecrew_stacked.jpg +images: + - image1: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image3.gif + link: https://media.giphy.com/media/QNFhOolVeCzPQ2Mx85/giphy.gif + - image2: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image4.gif + link: https://media.giphy.com/media/l2JeierkQlHpJsGWY/giphy.gif + - image3: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image6.gif + link: https://media.giphy.com/media/PvvSfSDFoAL5e/giphy.gif + - image4: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image1.gif + link: https://media.giphy.com/media/3oFzmjFxbBiPQW4qVa/giphy.gif + - image5: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image5.gif + link: https://media.giphy.com/media/3orieTeAMaKc4yhwmk/giphy.gif + - image6: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image6.gif + link: https://media.giphy.com/media/PvvSfSDFoAL5e/giphy.gif +--- + + + + +[separator] + +## This is our second newsletter in the series of Secrets of Top-Performing DevOps Teams. In the first part, we’ve got to grips with the [DevOps approach](https://hackernoon.com/devops-fundamentals-you-ever-wanted-to-know-zt2m3uh6) and the way it has [amplified the IT workflow](https://hackernoon.com/tagged/workflow). + + + +[WE NEED TO REPLACE AN IMAGE] + +![alt_text](https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image3.gif "image_tooltip") +[image3] + + + +Here’s a quick reminder and a short introduction for the unaware: + +Tech role has germinated from ["help fix my laptop"](https://hackernoon.com/search?query=horror) to "help me become the best." While [many dev teams are trapped firefighting](https://hackernoon.com/tagged/team-productivity), leading teams [align with the business](https://hackernoon.com/tagged/business), [adopt agile principles](https://hackernoon.com/tagged/agile) and automation, and lead the [digital transformation](https://hackernoon.com/tagged/transformation). + +What’s in it for [DevOps](https://hackernoon.com/tagged/devops), you’d ask? It’s simple: a robust DevOps team facilitates [faster development](https://hackernoon.com/founders-guide-how-to-outsource-software-development-in-2020-y1473yr7) of new products and [easier maintenance](https://hackernoon.com/3-reasons-why-teams-fail-avx3ta7) of existing deployments. + +Read between the lines - agile-based DevOps approach yields an increase in [development productivity](https://hackernoon.com/4-ways-startups-can-use-tech-and-automation-to-be-more-efficient-j3423w51). And with no silver bullet methods for improving IT [efficiency](https://hackernoon.com/if-formula-1-defined-efficiency-675z3yqd), perfecting DevOps might be your best shot. + +Without further ado, let’s dive into our top picks for [DevOps team success](https://hackernoon.com/devops-as-a-service-or-do-you-really-need-a-devops-team-cc4q32wj). + + +## Hacking Your Way Through to a High-Performing DevOps Team + + + +1. [High-performing](https://hackernoon.com/3-easy-ways-to-improve-performance-of-your-python-code-dw183uzo) teams put business first + +You’d say, a [revenue-first mindset](https://hackernoon.com/five-undervalued-data-points-for-emerging-businesses-5c2w3eun) won’t get you the probity medal. However, it’s not our point. In fact, profitability should be your top of mind not for the sake of money only. + + +Successful DevOps teams are more likely to tie their tech projects to revenue, mainly because it’s the 1 [metric for their performance](https://hackernoon.com/the-secret-of-growth-how-to-achieve-dollar1m-arr-in-6-months-vi1832mp). As a result, teams that are business aligned tend to prioritize projects with business management and use business and tech scorecards to measure success. Therefore, just a simple shift from an [activity-driven mindset](https://hackernoon.com/data-that-you-need-is-worth-gold-not-data-that-you-already-have-5c60f9345c6b) to a [revenue-first approach](https://hackernoon.com/4-business-lessons-from-the-failure-of-wework-the-47-billion-dollar-tech-company-3ahi3201) can guarantee a positive change in your team productivity and overall result. + + + (We’re not implying that you should ditch the [customer-centric action](https://hackernoon.com/24-customer-retention-strategies-eq1y3ym0), don’t compare apples and oranges) + +[WE NEED TO REPLACE AN IMAGE] +![alt_text](https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image4.gif "image_tooltip") +[image4] + + + + +2. They assign end-to-end responsibility + +Separating [development](https://hackernoon.com/ownership-and-responsibility-in-software-development-teams-6wr3n17) and [operations](https://hackernoon.com/0-to-90-bn-in-a-decade-uber-takeaways-for-startups-and-roadblocks-ahead-for-uber-b17c3bee2a3f) can present potential issues and pitfalls like [performance problems](https://hackernoon.com/the-surprise-outcome-of-measuring-our-pull-requests-process-4v683tbw) and inconsistent environments. In DevOps, both groups cooperate as a team that's [completely responsible](https://hackernoon.com/take-responsibility-dont-blame-it-on-the-users-hoz3n2u) for a product from beginning to end. + + +Unlike the traditional approach or a [low-performing team](https://hackernoon.com/good-ux-manager-bad-ux-manager-33df51f7367c), where each team member is accountable for their own role, the perfect DevOps team [obliterates those silos](https://hackernoon.com/how-to-prioritize-product-requirements-77d139b4a343) and makes an excellent result the focus of the entire crew. + + +A [developer is no longer just a developer](https://hackernoon.com/highest-paid-software-developer-c66b9f4cc53e) in charge of X lines of code. A tester is no longer accountable for the expected functionality. A high-performing team wears multiple hats and has got it [ALL covered](https://hackernoon.com/dont-optimize-things-that-dont-work-yet-957j30qv). + + +[WE NEED TO REPLACE AN IMAGE] +![https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image6.gif][https://media.giphy.com/media/PvvSfSDFoAL5e/giphy.gif][alt text] +[image6] + +** 3. Automation technology is not an option for a [dazzling performance](https://hackernoon.com/my-top-three-priorities-as-a-software-development-manager-cq2x32c1)** + +Let’s be honest: the bright minds like working with new and shiny technology. And you need those [bright minds](https://hackernoon.com/software-specifications-define-plan-and-execute-more-effective-projects-p0803tzz) in your team to make it high-performing and guarantee superb results. It's a bit hard to employ and keep these big stars in a company that trusts in a [creaky, legacy toolchain](https://hackernoon.com/devops-principles-culture-vs-tooling-vvac367z) to build a product, right? + + +Investing in the [DevOps tools](https://hackernoon.com/7-best-devops-security-practices-devsecops-and-its-merits-mr2p3unk) will not only make the team more effective, but it will also make them want to stay. From a practical standpoint, [automation tools](https://hackernoon.com/automating-security-in-devops-top-15-tools-69253w9e) can increase [tech efficiency](https://hackernoon.com/why-devops-is-important-during-the-covid-19-pandemic-6u1i3tul), eliminate errors, and help [deploy apps faster](https://hackernoon.com/the-difference-between-ci-and-cd-in-devops-bc2z3uae). That refers to simplifying the [process of configuring](https://hackernoon.com/how-to-make-a-devops-strategy-pk153uyb), monitoring, and maintaining the [network infrastructure](https://hackernoon.com/ever-wondered-why-we-use-containers-in-devops-l5113wif). + + +[WE NEED TO REPLACE AN IMAGE] +![https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image1.gif][https://media.giphy.com/media/3oFzmjFxbBiPQW4qVa/giphy.gif][alt text] +[image1] + +------- + +## Pull it all together + +There's no panacea for [successful DevOps team building](https://hackernoon.com/measuring-devops-metrics-a-how-to-guide-ot113ztl), but the process itself is definitely easier than [quantum physics](https://www.hackernoon.com/how-quantum-dots-technology-driving-advancements-in-lcd-and-oled-display-quality-2e163uxg). The majority of our tips and tricks dispensed above are of common-sense variety. In practice, our [secrets](https://hackernoon.com/are-you-telling-the-story-of-your-software-mc133w92) call for good old-fashioned [hard work](https://hackernoon.com/how-to-approach-strategic-planning-when-the-sky-is-falling-oq5k3yer) and a sprinkle of knowledge. + +To deliver top-notch results, employees must be well-settled, teams well-structured, and objectives outlined based on [business priorities](https://hackernoon.com/ceos-survey-on-digital-transformation-in-2017-by-gartner-c2d6e842f86c). And it’s not enough to recruit the right people, retention and training are equally important. Overall, it takes a solid mix of all these components to build a team that truly thrives. + + + +_Join us to welcome today newsletter’s sponsor - [BridgeCrew](https://bit.ly/3n9CgbE). BridgeCrew helps find, fix, and prevent cloud misconfigurations straight from your CI/CD pipeline. Their platform leverages automation and delivers security-as-code to streamline your DevSecOps processes._ + + +* Hacker Noon Stickers +* A standard .TECH domain for 3 years +* A standard .TECH domain for 2 years + * .TECH domain - Sub item 1 + * .TECH domain - Sub item 2 + * .TECH domain -Sub item 3 +* A standard .TECH domain for 5 years + +*HAJKAKKSKKSKAKSK* + +[Got a tech story to share with our readers?](http://auth.hackernoon.com/) Everything you've ever wanted to know about how to get published on Hacker Noon - [get it here](https://hackernoon.com/how-to-get-published-on-hacker-noon-a-step-by-step-guide-zcp36rz). + +[WE NEED TO REPLACE AN IMAGE] +![https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image5.gif][https://media.giphy.com/media/3orieTeAMaKc4yhwmk/giphy.gif][alt text] + +[image5] \ No newline at end of file diff --git a/source/front-matter/05-source-weekly-menu.md b/source/front-matter/05-source-weekly-menu.md new file mode 100644 index 000000000..c01f6aec6 --- /dev/null +++ b/source/front-matter/05-source-weekly-menu.md @@ -0,0 +1,63 @@ +--- +title: Korean Barbecue Beef | Pork Schnitzel | Bahn Mi Meatball Skewers +date: April 22nd, 2021 +recipes: + - monday: + title: Chipotle Cream Skillet Chicken + subtitle: over Rice and Snap Peas + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe1.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - thuesday: + title: Pork Schnitzel + subtitle: with German Spaetzle and Green Beans + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe2.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - wednesday: + title: Bahn Mi Meatball Skewers + subtitle: + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe3.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - thirsday: + title: Korean Barbecue Beef with Sesame Rice Noodles + subtitle: and Spicy Pickled Cucumbers and Carrots + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe4.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - friday: + title: Grilled Salmon with Chipotle Cream Sauce + subtitle: over Potato Poblano Hash and Broccolini + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe5.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - saturday: + title: Saucy Grilled Shrimp + subtitle: and a Corn and Radish Salad with Avocado Dressing + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe6.jpeg + link: https://www.nomoretogo.com/weekly-menu/ +--- + + +# Korean Barbecue Beef | Pork Schnitzel | Bahn Mi Meatball Skewers + + +## Weekly Menu +### April 22nd, 2021 + +We have a very diverse line-up of meals for this week. Kicking off the week we have a delicious flaky salmon with creamy chipotle sauce. Followed by Korean Barbecue Beef, a quick and outstanding dinner! And oh my- the Saucy Shrimp Salad is amazing! Don’t miss the Pork Schnitzel with German Spaetzle. Overall, my family was blown away by this week and I hope yours is too. Enjoy!! + +Happy Cooking, +Stacey, Sloane, and the No More To-Go Team + + +[weekly-menu] + + +### Ingredients + +Saffron: Gives traditional Tandoori its famous yellow coloring. This week we are using it in the marinade for the Yogurt Spiced Chicken. It can be pretty expensive, so turmeric is a good alternative, providing the same color and very comparable taste. + +### Weekend Prep + +Free up your evening and get a little chopping and prep work done this weekend. + +Slice and Dice: Cut the vegetables and store in zippered bags or divided containers. + +Make Ahead and Refrigerate: Make the sauce; Cook the noodles; Make the dressing; Make the spaetzle; Cook the rice. \ No newline at end of file diff --git a/src/callbacks/html/index.js b/src/callbacks/html/index.js index 657338ce8..2d4952088 100644 --- a/src/callbacks/html/index.js +++ b/src/callbacks/html/index.js @@ -1,13 +1,9 @@ import _blockquote from './methods/simple'; -import _previewText from './methods/preview'; import _header from './methods/header'; - import _strong from './methods/strong'; import _link from './methods/link'; - import { // _italic, - _del, _q, _code, @@ -16,23 +12,22 @@ import { } from './methods/simple-without-replacer'; import { _italic, _italicAsterix } from './methods/italic'; - import { _ulList, _olList, getParsedSubList } from './methods/lists'; - import _br from './methods/br'; - -import { _image } from './methods/image'; -import _separator from './methods/separator'; -import _meme from './methods/memes'; -import { _sponsorship } from './methods/sponsor'; - +//--------------- +// advanced callbacks that might get replaced with front matter +import { _image } from './methods/advanced/image'; +import _separator from './methods/advanced/separator'; +import _meme from './methods/advanced/memes'; +import { _sponsorship } from './methods/advanced/sponsor'; +import _previewText from './methods/advanced/preview'; +//--------------- import { _paragraphWrapper } from './methods/paragraph'; export { _strong, _link, _blockquote, - _meme, _header, //------------ _italic, @@ -54,4 +49,5 @@ export { _br, _separator, _previewText, + _meme, }; diff --git a/src/callbacks/html/methods/image.js b/src/callbacks/html/methods/advanced/image.js similarity index 88% rename from src/callbacks/html/methods/image.js rename to src/callbacks/html/methods/advanced/image.js index 23d8b4b69..d1ff7fc2f 100644 --- a/src/callbacks/html/methods/image.js +++ b/src/callbacks/html/methods/advanced/image.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; // TODO remove unused `text` argument export function _image(text, alt, srcWithTooltip) { diff --git a/src/callbacks/html/methods/memes.js b/src/callbacks/html/methods/advanced/memes.js similarity index 82% rename from src/callbacks/html/methods/memes.js rename to src/callbacks/html/methods/advanced/memes.js index 32dbb3edb..761ba74c8 100644 --- a/src/callbacks/html/methods/memes.js +++ b/src/callbacks/html/methods/advanced/memes.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; // // TODO remove unused `text` argument function _meme(text, src, href, altText) { diff --git a/src/callbacks/html/methods/preview.js b/src/callbacks/html/methods/advanced/preview.js similarity index 83% rename from src/callbacks/html/methods/preview.js rename to src/callbacks/html/methods/advanced/preview.js index 7dbbcf7f7..5d439eab2 100644 --- a/src/callbacks/html/methods/preview.js +++ b/src/callbacks/html/methods/advanced/preview.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; // TODO remove unused `text` argument function _previewText(text, content) { diff --git a/src/callbacks/html/methods/separator.js b/src/callbacks/html/methods/advanced/separator.js similarity index 78% rename from src/callbacks/html/methods/separator.js rename to src/callbacks/html/methods/advanced/separator.js index 10c2561e7..95c478482 100644 --- a/src/callbacks/html/methods/separator.js +++ b/src/callbacks/html/methods/advanced/separator.js @@ -1,6 +1,6 @@ -import { newLine } from '../helpers'; +import { newLine } from '../../helpers'; -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; function _separator( text, diff --git a/src/callbacks/html/methods/sponsor.js b/src/callbacks/html/methods/advanced/sponsor.js similarity index 92% rename from src/callbacks/html/methods/sponsor.js rename to src/callbacks/html/methods/advanced/sponsor.js index 3dd21f071..f003f10a7 100644 --- a/src/callbacks/html/methods/sponsor.js +++ b/src/callbacks/html/methods/advanced/sponsor.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; export function _sponsorship(markdown_string) { // TODO move out this regex into constants file. diff --git a/src/callbacksReact/index.js b/src/callbacksReact/index.js index 67b8f7bcd..c8be04338 100644 --- a/src/callbacksReact/index.js +++ b/src/callbacksReact/index.js @@ -3,6 +3,20 @@ import * as callbacks from './methods/callbacks'; import * as lists from './methods/lists'; import _header from './methods/header'; -const Callbacks = { ...simple, ...lists, _header, ...callbacks }; +import _sponsorship from './methods/advanced/sponsor'; +import _previewText from './methods/advanced/preview'; +import _meme from './methods/advanced/meme'; +import _image from './methods/advanced/image'; + +const Callbacks = { + ...simple, + ...lists, + _header, + ...callbacks, + _sponsorship, + _previewText, + _meme, + _image, +}; export { Callbacks }; diff --git a/src/callbacksReact/methods/advanced/image.js b/src/callbacksReact/methods/advanced/image.js new file mode 100644 index 000000000..98bbd0a6f --- /dev/null +++ b/src/callbacksReact/methods/advanced/image.js @@ -0,0 +1,25 @@ +// import { newLine } from '../../../domain/helper-methods'; +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _image(text, alt, srcWithTooltip) { + const src = srcWithTooltip.trim().replace(/\"image_tooltip\"/, ''); + + const params = { + src: src.trim(), + altText: alt, + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'image', + debug: true, + }; + + this.warnings.images += 1; + + const replaced = commonReplace(config); + + return replaced; +} +export default _image; diff --git a/src/callbacksReact/methods/advanced/meme.js b/src/callbacksReact/methods/advanced/meme.js new file mode 100644 index 000000000..009d24796 --- /dev/null +++ b/src/callbacksReact/methods/advanced/meme.js @@ -0,0 +1,23 @@ +// import { newLine } from '../../../domain/helper-methods'; + +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _meme(text, src, href, altText) { + const params = { + src: src.trim(), + altText: altText.trim(), + href: href.trim(), + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'meme', + debug: true, + }; + + const replaced = commonReplace(config); + return replaced; +} + +export default _meme; diff --git a/src/callbacksReact/methods/advanced/preview.js b/src/callbacksReact/methods/advanced/preview.js new file mode 100644 index 000000000..d1b1feef6 --- /dev/null +++ b/src/callbacksReact/methods/advanced/preview.js @@ -0,0 +1,20 @@ +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _previewText(text, content) { + const params = { + content, + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'previewText', + debug: true, + }; + + // this.previewText = true; + + const replaced = commonReplace(config); + return replaced; +} +export default _previewText; diff --git a/src/callbacksReact/methods/advanced/separator.js b/src/callbacksReact/methods/advanced/separator.js new file mode 100644 index 000000000..1811a7d52 --- /dev/null +++ b/src/callbacksReact/methods/advanced/separator.js @@ -0,0 +1,21 @@ +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { newLine } from '../../../domain/helper-methods'; + +function _separator(text) { + const params = { + content: text.trim(), // we have an issue, when we passing empty params + }; + + const config = { + configurationMap: this.configurationMap, + params, + + name: 'separator', + debug: true, + }; + + const replaced = commonReplace(config); + return newLine + replaced + newLine; +} + +export default _separator; diff --git a/src/callbacksReact/methods/advanced/sponsor.js b/src/callbacksReact/methods/advanced/sponsor.js new file mode 100644 index 000000000..7b2663324 --- /dev/null +++ b/src/callbacksReact/methods/advanced/sponsor.js @@ -0,0 +1,37 @@ +// import { newLine } from '../../../domain/helper-methods'; + +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _sponsorship(text) { + // TODO move out this regex into constants file. + const regex = /\[(.*?)\]/g; + + const regex2 = /[\[\]]/g; + + const [content, href, src] = text + .match(regex) + .map((match) => match.replace(regex2, '')); + + const params = { + src: src.trim(), + href: href.trim(), + content: content.trim(), + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'sponsor', + debug: true, + }; + const replaced = commonReplace(config); + return replaced; + + // TODO upgrade a way to handle errors in state object + // eslint-disable-next-line no-unused-expressions + // this.errors.sponsorshipTop + // ? (this.errors.sponsorshipBottom = true) + // : (this.errors.sponsorshipTop = true); +} + +export default _sponsorship; diff --git a/src/callbacksReact/methods/custom.js b/src/callbacksReact/methods/custom.js deleted file mode 100644 index cb0ff5c3b..000000000 --- a/src/callbacksReact/methods/custom.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/callbacksReact/methods/simple.js b/src/callbacksReact/methods/simple.js index de70bc812..6afaa016b 100644 --- a/src/callbacksReact/methods/simple.js +++ b/src/callbacksReact/methods/simple.js @@ -122,85 +122,10 @@ function _blockquote() { // }; } -function _meme(text, src, href, altText) { - const params = { - src: src.trim(), - altText: altText.trim(), - href: href.trim(), - }; - - const config = { - configurationMap: this.configurationMap, - params, - name: 'meme', - debug: true, - }; - - const replaced = commonReplace(config); - return replaced; -} - -// function _header(text, chars, content) { -// const params = { -// content: content.trim(), -// }; - -// const titleType = ['mainTitle', 'subtitle', 'heading']; -// const name = titleTypes[chars.length - 1]; - -// const config = { -// configurationMap: this.configurationMap, -// params, -// name, - -// // debug: true, -// }; - -// const replaced = commonReplace(config); -// return newLine + replaced; - -// } - -function _separator(text) { - const params = { - content: text.trim(), // we have an issue, when we passing empty params - }; - - const config = { - configurationMap: this.configurationMap, - params, - - name: 'separator', - debug: true, - }; - - const replaced = commonReplace(config); - return newLine + replaced + newLine; -} - -function _previewText(text, content) { - const params = { - content, - }; - - const config = { - configurationMap: this.configurationMap, - params, - name: 'previewText', - debug: true, - }; - - // this.previewText = true; - - const replaced = commonReplace(config); - return replaced; -} - export { _strong, _link, _blockquote, - _meme, // _header, _italic, _del, @@ -208,6 +133,4 @@ export { _code, _hr, _empty, - _previewText, - _separator, }; diff --git a/src/constants/addon.js b/src/constants/addon.js index 39ce9aea8..f01832275 100644 --- a/src/constants/addon.js +++ b/src/constants/addon.js @@ -9,8 +9,6 @@ const REGEXP_SECTION_TAGS = /^<\/?(ul|ol|li|h|p|bl)/i; const REGEXP_IMAGE_TOOLTIP = /\"image_tooltip\"/; const REGEXP_NEWLINE = `${newLine}g`; -// const REGEXP_SPONSORHSHIP = - // command-line-methods.js // const REGEXP_BASIC_TABLE_TAGS = new RegExp('(
)', 'i');
diff --git a/src/constants/customTags.js b/src/constants/customTags.js
index a46843da9..eb19c824f 100644
--- a/src/constants/customTags.js
+++ b/src/constants/customTags.js
@@ -5,12 +5,17 @@ import os from 'os';
const platform = os.platform();
const newLine = platform === 'win32' ? '\r\n' : '\n';
-
+// those RegEx`es might gone after integration of front matter
const REGEXP_SPONSORSHIP = /~(\[(.*?)\]){3}/g;
const REGEXP_HTML_COMMENTS = //g;
// eslint-disable-next-line no-useless-escape
const REGEXP_MEM = /\!\[(.*?)\]\[(.*?)\]\[(.*?)\]/g;
const REGEXP_PREVIEW_TEXT = new RegExp(`#~(.*?)${newLine}`);
+//-------
+// TODO add that beforeMethod
+const regexString = `\\[separator\\]`;
+const REGEXP_SEPARATOR = new RegExp(newLine + regexString + newLine, 'g');
+//----------
const REGEXP_HASH_TAG = new RegExp(
// eslint-disable-next-line no-control-regex
@@ -24,9 +29,8 @@ const REGEXP_LINK_HTTPS = new RegExp('>https', 'g');
const REGEXP_STR_BEGIN = '>https';
const REGEXP_STR_END = 'f<';
-// TODO add that beforeMethod
-const regex_string = `\\[separator\\]`;
-const REGEXP_SEPARATOR = new RegExp(newLine + regex_string + newLine, 'g');
+const regexString2 = `\\[image\\d\\]`;
+const REGEXP_IMAGES_FRONT = new RegExp(newLine + regexString2 + newLine, 'g');
export {
REGEXP_SPONSORSHIP,
@@ -39,4 +43,6 @@ export {
REGEXP_STR_BEGIN,
REGEXP_STR_END,
REGEXP_SEPARATOR,
+ // ------------
+ REGEXP_IMAGES_FRONT,
};
diff --git a/src/constants/regexp/_to-try.js b/src/constants/regexp/_to-try.js
deleted file mode 100644
index 387e2966f..000000000
--- a/src/constants/regexp/_to-try.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// @todo or expand this thing
-// this.rules = [
-// {regex: /(#+)(.*)/g, replacement: header}, // headers
-// {regex: /!\[([^\[]+)\]\(([^\)]+)\)/g, replacement: ''}, // image
-// {regex: /\[([^\[]+)\]\(([^\)]+)\)/g, replacement: '$1'}, // hyperlink
-// {regex: /(\*\*|__)(.*?)\1/g, replacement: '$2'}, // bold
-// {regex: /(\*|_)(.*?)\1/g, replacement: '$2'}, // emphasis
-// {regex: /\~\~(.*?)\~\~/g, replacement: '$1'}, // quote -// {regex: /`(.*?)`/g, replacement: ' $1 '}, // inline code
-// {regex: /\n\*(.*)/g, replacement: ulList}, // ul lists
-// {regex: /\n[0-9]+\.(.*)/g, replacement: olList}, // ol lists
-// {regex: /\n(>|\>)(.*)/g, replacement: blockquote}, // blockquotes
-// {regex: /\n-{5,}/g, replacement: '\n'}, // horizontal rule -// {regex: /\n([^\n]+)\n/g, replacement: para}, // add paragraphs -// {regex: /<\/ul>\s?
/g, replacement: '\n'} // fix extra blockquote -// ]; - -// const REGEXP_H3 = /^### (.*$)/gim; -// const REGEXP_H2 = /^## (.*$)/gim; -// const REGEXP_H1 = /^# (.*$)/gim; -// const REGEXP_BLOCKQUOTE = /^\> (.*$)/gim; -// const REGEXP_B = /\*\*(.*)\*\*/gim; -// const REGEXP_I = /\*(.*)\*/gim; -// const REGEXP_IMG = /!\[(.*?)\]\((.*?)\)/gim; -// const REGEXP_A = /\[(.*?)\]\((.*?)\)/gim; diff --git a/src/domain/content-source/index.js b/src/domain/content-source/index.js new file mode 100644 index 000000000..d4f94fe1f --- /dev/null +++ b/src/domain/content-source/index.js @@ -0,0 +1,40 @@ +import { resolve } from 'path'; +import { readSourceFile, readFrontMatter } from 'markup-generator'; +// ------------------ +// will be removed later +// import { getPreview, getTitle, getAds, getImages } from '../frontmatter-data'; +// ------------------- +const FULL_SOURCE = resolve('./source/source.md'); +const RECIPES_SOURCE = resolve('./source/recipes/source-nmtg.md'); +// updated version +// console.log(resolve('./source/front-matter/03-hackernoon-source.md')) +const FRONT_HN_SOURCE = resolve( + './source/front-matter/03-hackernoon-source.md', +); +// const FRONT_NMTG_SOURCE = resolve( +// './source/front-matter/05-source-weekly-menu.md', +// ); +// -------------- +const frontMarkdownHackernoon = readFrontMatter(FRONT_HN_SOURCE); +// const front_makrdown_nmtg = readFrontMatter(FRONT_NMTG_SOURCE); + +// console.log(frontMarkdownHackernoon); +// const dddata = frontMarkdownHackernoon.frontMatter; +// adding it here right now just for trsting purposes + +// getPreview(dddata), getTitle(dddata), getAds(dddata), getImages(dddata); +// console.log(getPreview(dddata)); +// console.log(getTitle(dddata)); +// console.log(getAds(dddata)); +// console.log(getImages(dddata)); + +const hackernoonContent = readSourceFile(FULL_SOURCE); +const nomoretogoContent = readSourceFile(RECIPES_SOURCE); + +export { + hackernoonContent, + FULL_SOURCE, + nomoretogoContent, + // RECIPES_SOURCE, + frontMarkdownHackernoon, +}; diff --git a/src/domain/deliver/deliver.js b/src/domain/deliver/deliver.js index 9f830c2be..ee3f5b858 100644 --- a/src/domain/deliver/deliver.js +++ b/src/domain/deliver/deliver.js @@ -1,6 +1,5 @@ -// import { writeHTML, generateTemplateName } from '../write'; import { writeHTML, generateTemplateName } from 'markup-generator'; -import { printMessage } from '../../helper'; +import { printMessage } from '../helper-methods/cli'; export const deliver = (template, name, message) => { const fileName = generateTemplateName(name, 'html'); diff --git a/src/domain/frontmatter-data/index.js b/src/domain/frontmatter-data/index.js new file mode 100644 index 000000000..1ce55890f --- /dev/null +++ b/src/domain/frontmatter-data/index.js @@ -0,0 +1,16 @@ +import _ from 'lodash'; + +const getPreview = (data) => { + return _.get(data, 'preview'); +}; +const getTitle = (data) => { + return _.get(data, 'title'); +}; +const getAds = (data) => { + return _.get(data, 'ads'); +}; +const getImages = (data) => { + return _.get(data, 'images'); +}; + +export { getPreview, getTitle, getAds, getImages }; diff --git a/src/domain/helper-methods/cli.js b/src/domain/helper-methods/cli.js new file mode 100644 index 000000000..c8c196f9d --- /dev/null +++ b/src/domain/helper-methods/cli.js @@ -0,0 +1,48 @@ +import chalk from 'chalk'; +import { forEach } from 'lodash'; + +const printMessage = ({ message, type }) => { + if (!message) return; + + switch (type) { + case 'yellow': + console.log(chalk.yellow(message)); + break; + case 'red': + console.log(chalk.red(message)); + break; + case 'red2': + console.log(chalk.red.bold(message)); + break; + case 'green1': + console.log(chalk.green(message)); + break; + case 'green2': + console.log(chalk.green.bold(message)); + break; + + default: + console.log(`Sorry, we are out of ${type}.`); + } +}; + +function checkErrors(errors) { + if (Object.values(errors).includes(false)) { + // TODO replace with lodash + forEach(errors, (_, error) => { + if (!errors[error]) { + const message = `ERROR source.md doesn't have ${error}`; + + printMessage(message, 'red'); + } + }); + + const message = 'The full template has not been parsed!'; + printMessage(message, 'red2'); + + return true; + } + return false; +} + +export { checkErrors, printMessage }; diff --git a/src/domain/helper-methods/index.js b/src/domain/helper-methods/index.js index b40f89979..31f65e62f 100644 --- a/src/domain/helper-methods/index.js +++ b/src/domain/helper-methods/index.js @@ -1,10 +1,6 @@ -import { forEach } from 'lodash'; - import os from 'os'; -import { - // checkHtml, - printMessage, -} from '../../helper'; +import { forEach } from 'lodash'; +import { checkErrors, printMessage } from './cli'; const platform = os.platform(); @@ -60,4 +56,19 @@ function verification(warnings, content = false) { if (content) checkHtml(content); } -export { verification, checkWarnings, checkHtml, newLine }; +function displayCLIErrors(errors, warnings) { + if (checkErrors(errors)) { + // there should be something in here + } else { + checkWarnings(warnings); + } +} + +export { + verification, + checkWarnings, + checkHtml, + newLine, + displayCLIErrors, + checkErrors, +}; diff --git a/src/domain/parse.js b/src/domain/parse.js index b37bf765b..d40615e3d 100644 --- a/src/domain/parse.js +++ b/src/domain/parse.js @@ -1,9 +1,10 @@ import stateInit from './state'; -function parse(markdown, configureReplacer, configurationMap) { +function parse(markdown, configureReplacer, config, data = false) { // passing content into the state, // so we can do our updates step by step and track any errors - const state = stateInit(markdown, configurationMap); + const dataX = data || false; + const state = stateInit(markdown, config, dataX); configureReplacer(state); diff --git a/src/domain/state/index.js b/src/domain/state/index.js index 69693854a..9f64b0132 100644 --- a/src/domain/state/index.js +++ b/src/domain/state/index.js @@ -1,14 +1,11 @@ -//------------------ -// ---- helper > command-line-methods -import { - checkErrors, - checkWarnings, - // checkHtml, -} from '../../helper'; +import { checkErrors } from '../helper-methods/cli'; +import { checkWarnings } from '../helper-methods'; + // TODO convert into singleton -const stateInit = (markdown, configurationMap) => { +const stateInit = (markdown, configurationMap, data = false) => { const stateObject = { content: markdown, + data: data || false, previewText: '', warnings: { images: 0, diff --git a/src/helper/command-line-methods.js b/src/helper/command-line-methods.js index ff0d02057..232ed5774 100644 --- a/src/helper/command-line-methods.js +++ b/src/helper/command-line-methods.js @@ -1,69 +1,7 @@ /* eslint-disable no-use-before-define */ -import chalk from 'chalk'; -import { forEach } from 'lodash'; - -// import { readSourceFile } from './utils'; - // TODO should we remake whole state as a class with "frozen" methods? - -import { checkWarnings, checkHtml } from '../domain/helper-methods'; - // TODO enable const messages // import { WARNING_IMAGE_VERSION, ERROR_SOURCE_DONT_HAVE, FULL_TEMPLATE_ERROR, HTML_EMAIL_SUCCESS, HTML_EMAIL_ERROR } from './constants'; - -function checkErrors(errors) { - if (Object.values(errors).includes(false)) { - // TODO replace with lodash - forEach(errors, (_, error) => { - if (!errors[error]) { - const message = `ERROR source.md doesn't have ${error}`; - - printMessage(message, 'red'); - } - }); - - const message = 'The full template has not been parsed!'; - printMessage(message, 'red2'); - - return true; - } - return false; -} - -// move inside... -function displayCLIErrors(errors, warnings) { - if (checkErrors(errors)) { - // there should be something in here - } else { - checkWarnings(warnings); - } -} - -const printMessage = ({ message, type }) => { - if (!message) return; - - switch (type) { - case 'yellow': - console.log(chalk.yellow(message)); - break; - case 'red': - console.log(chalk.red(message)); - break; - case 'red2': - console.log(chalk.red.bold(message)); - break; - case 'green1': - console.log(chalk.green(message)); - break; - case 'green2': - console.log(chalk.green.bold(message)); - break; - - default: - console.log(`Sorry, we are out of ${type}.`); - } -}; - //--------------------- // const ERROR_TITLE = '`title` is a required option for `renderTemplate`' const checkingTitle = (title) => { @@ -89,15 +27,10 @@ const checkingPreviewText = (previewText) => { // --- export { - displayCLIErrors, - checkErrors, - checkWarnings, - checkHtml, //------- checkingTitle, checkingBodyContent, checkingPreviewText, //---------------- - printMessage, // stateInit, }; diff --git a/src/helper/index.js b/src/helper/index.js index f887d07e4..d128e6aea 100644 --- a/src/helper/index.js +++ b/src/helper/index.js @@ -5,25 +5,10 @@ import { generateTemplateName, } from '../domain/write'; -import { - displayCLIErrors, - checkErrors, - checkWarnings, - checkHtml, - printMessage, - - // stateInit, -} from './command-line-methods'; - export { writeHTML, readSourceFile, isFolderExists, generateTemplateName, - displayCLIErrors, - checkErrors, - checkWarnings, - checkHtml, - printMessage, // stateInit, }; diff --git a/src/index.js b/src/index.js index 682cc23f4..9b40570ea 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,13 @@ import { generateReactFullTemplateHackernoon } from './templates/HackernoonTemplate/react/generateReactFullTemplate'; import { generateHtmlFullTemplateHackernoon } from './templates/HackernoonTemplate/html/generateHtmlFullTemplate'; import { generateHtmlFullTemplateRecipes } from './templates/RecipesTemplate/html/generateHtmlFullTemplate'; +// ------------- +import { generateFrontHackernoon } from './templates/HackernoonTemplate/front/generateFront'; export { generateHtmlFullTemplateHackernoon, generateReactFullTemplateHackernoon, generateHtmlFullTemplateRecipes, + // --------------- + generateFrontHackernoon, }; diff --git a/src/templates/HackernoonTemplate/front/generateFront.js b/src/templates/HackernoonTemplate/front/generateFront.js new file mode 100644 index 000000000..26450276f --- /dev/null +++ b/src/templates/HackernoonTemplate/front/generateFront.js @@ -0,0 +1,48 @@ +import TObject from 'atherdon-old-newsletter-js-outertemplate'; +import parse from '../../../domain/parse'; +import { verification } from '../../../domain/helper-methods'; +import Replace from '../html/components/Replace.class'; +import configurationMap from '../html/components/configurationMap'; +// this method will be updated in order to fit with front matter integration +const parseContent = ({ markdown, data }) => { + return parse( + markdown, + (state) => Replace.configure(state), + configurationMap, + data, + ); +}; +// printTemplate must support content + data attributes +const hackernoonFrontTemplate = (settings) => + TObject.printTemplateData(settings); +// i'm using 2 arguments for back dependency ability +export const generateFrontHackernoon = (options) => { + const { frontMatter, markdown } = options; + // const data = options.frontMatter; + // const markdown = options.markdown; + // should warnings be returned here? + // + // console.log(markdown); + // console.log(frontMatter); + const { + content, + warnings, + // previewText + } = parseContent({ + markdown, + frontMatter, + }); + + verification(warnings, content); + + const settings = { + string: content, + data: frontMatter, + }; + + const hackernoonFullTemplate = hackernoonFrontTemplate(settings); + + // console.log(hackernoonFullTemplate); + + return hackernoonFullTemplate; +}; diff --git a/src/templates/HackernoonTemplate/html/components/Replace.class.js b/src/templates/HackernoonTemplate/html/components/Replace.class.js index 2870e5cb5..df9da3767 100644 --- a/src/templates/HackernoonTemplate/html/components/Replace.class.js +++ b/src/templates/HackernoonTemplate/html/components/Replace.class.js @@ -5,13 +5,8 @@ import { replaceMarkdown } from '../../../../domain/replace-markdown/html/replac class Replace { constructor() { this.replaceMDBinded = () => {}; - // I think this version isnt working well // Replacer.replaceMDBindedPreviewText = replaceMarkdownPreviewText.bind(state); - // this.replaceMDBindedPreviewText = () => {}; - - this.previewText = () => this.replaceMDBinded('previewText'); - this.strong = () => this.replaceMDBinded('strong'); this.em = () => this.replaceMDBinded('italic'); // TODO finish this case @@ -21,6 +16,7 @@ class Replace { this.header = () => this.replaceMDBinded('header'); this.subtitle = () => this.replaceMDBinded('header'); this.title = () => this.replaceMDBinded('header'); + //--- this.image = () => this.replaceMDBinded('image'); this.link = () => this.replaceMDBinded('link'); this.del = () => this.replaceMDBinded('del'); @@ -32,11 +28,13 @@ class Replace { this.hr = () => this.replaceMDBinded('hr'); this.paragraph = () => this.replaceMDBinded('paragraph'); this.br = () => this.replaceMDBinded('br'); + //------- + // those methods might get replaced with front-matter + this.previewText = () => this.replaceMDBinded('previewText'); this.sponsorship = () => this.replaceMDBinded('sponsorship'); // here we have a different name this.memes = () => this.replaceMDBinded('memes'); this.separator = () => this.replaceMDBinded('separator'); - // TODO hiding for now, let's fix it after our release // this.emptyUl = () => this.replaceMDBinded('REGEXP_EMPTY_UL'); // this.emptyOl = () => this.replaceMDBinded('REGEXP_EMPTY_OL'); @@ -57,10 +55,6 @@ class Replace { this.miscellaneous(); } - template() { - this.header(); - } - // TODO I think we need to upgrade this class, // in order to match it with our updated logic of organizing components @@ -74,11 +68,15 @@ class Replace { if (!process.env.PARSE === 'noAdv' || process.env.PARSE === 'full') { this.sponsorship(); } - + // might get removed after integration of front-matter this.memes(); this.separator(); } + template() { + this.header(); + } + typography() { this.strong(); diff --git a/src/templates/HackernoonTemplate/html/components/configurationMap.js b/src/templates/HackernoonTemplate/html/components/configurationMap.js index 310c903e1..035cff844 100644 --- a/src/templates/HackernoonTemplate/html/components/configurationMap.js +++ b/src/templates/HackernoonTemplate/html/components/configurationMap.js @@ -4,10 +4,7 @@ import body from 'atherdon-newsletter-js-layouts-body'; import { _strong, - _link, _blockquote, - _meme, - _header, //-------- _italic, // _italicAsterix, @@ -22,12 +19,15 @@ import { _olList, getParsedSubList, //-------------- - _image, _paragraphWrapper, - _sponsorship, _br, + // those callbacks might get replaced with front-matter integration + _image, + _link, + _meme, + _header, + _sponsorship, _separator, - // _previewText, } from '../../../../callbacks/html/index'; @@ -35,6 +35,7 @@ import { REGEXP_HEADER, REGEXP_IMAGE, REGEXP_LINK, + REGEXP_PARAGRAPH, REGEXP_STRONG, REGEXP_DEL, REGEXP_Q, @@ -48,7 +49,6 @@ import { REGEXP_SPONSORSHIP, REGEXP_MEM, REGEXP_PREVIEW_TEXT, - REGEXP_PARAGRAPH, REGEXP_SEPARATOR, } from '../../../../constants/index'; @@ -79,6 +79,7 @@ const { strongComponent, } = typography; +// custom components that can be simplified with front-matter const { sponsorComponent, previewTextComponent } = body; const map = { @@ -86,20 +87,13 @@ const map = { link: objectBuilder(REGEXP_LINK, _link, linkComponent), del: objectBuilder(REGEXP_DEL, _del, false), image: objectBuilder(REGEXP_IMAGE, _image, imageComponent), - previewText: objectBuilder( - REGEXP_PREVIEW_TEXT, - _previewText, - previewTextComponent, - ), + italic: objectBuilder(REGEXP_UNDERSCORE_ITALIC, _italic, italicComponent), italic_asterix: objectBuilder( REGEXP_ASTERIX_ITALIC, _italic, italicComponent, ), - header: objectBuilder(REGEXP_HEADER, _header, headingComponent), - subtitle: objectBuilder(REGEXP_HEADER, _header, subtitleComponent), - title: objectBuilder(REGEXP_HEADER, _header, titleComponent), q: objectBuilder(REGEXP_Q, _q, false), code: objectBuilder(REGEXP_CODE, _code, false), listItem: objectBuilder( @@ -120,6 +114,15 @@ const map = { paragraphComponent, ), br: objectBuilder(REGEXP_BR, _br), + // custom and complex objects, front-matter replacable + previewText: objectBuilder( + REGEXP_PREVIEW_TEXT, + _previewText, + previewTextComponent, + ), + header: objectBuilder(REGEXP_HEADER, _header, headingComponent), + subtitle: objectBuilder(REGEXP_HEADER, _header, subtitleComponent), + title: objectBuilder(REGEXP_HEADER, _header, titleComponent), sponsorship: objectBuilder( REGEXP_SPONSORSHIP, _sponsorship, @@ -132,24 +135,4 @@ const map = { // OLD version // const italic:objectBuilder(REGEXP_EM, _italic, italicLiteral); -// REGEXP_UNDERSCORE_ITALIC, -// REGEXP_ASTERIX_ITALIC, -// qLiteral, -// empty as emptyLiteral, - -// 'REGEXP_EMPTY_UL': { -// constant: REGEXP_EMPTY_UL, -// replacer: emptyUl -// }, - -// 'REGEXP_EMPTY_OL': { -// constant: REGEXP_EMPTY_OL, -// replacer: emptyOl -// }, - -// 'REGEXP_EMPTY_BLOCKQUOTE': { -// constant: REGEXP_EMPTY_BLOCKQUOTE, -// replacer: emptyBlockQuote -// }, - export default map; diff --git a/src/templates/HackernoonTemplate/html/generateHtmlFullTemplate.js b/src/templates/HackernoonTemplate/html/generateHtmlFullTemplate.js index f641db3b9..061fa8925 100644 --- a/src/templates/HackernoonTemplate/html/generateHtmlFullTemplate.js +++ b/src/templates/HackernoonTemplate/html/generateHtmlFullTemplate.js @@ -3,14 +3,19 @@ import parse from '../../../domain/parse'; import { verification } from '../../../domain/helper-methods'; import Replace from './components/Replace.class'; import configurationMap from './components/configurationMap'; - -const parseContent = ({ markdown }) => { - return parse(markdown, (state) => Replace.configure(state), configurationMap); +// this method will be updated in order to fit with front matter integration +const parseContent = ({ markdown, data }) => { + return parse( + markdown, + (state) => Replace.configure(state), + configurationMap, + data, + ); }; - +// printTemplate must support content + data attributes const hackernoonTemplate = (content) => TObject.printTemplate(content); - -export const generateHtmlFullTemplateHackernoon = (markdown) => { +// i'm using 2 arguments for back dependency ability +export const generateHtmlFullTemplateHackernoon = (markdown, data = false) => { // should warnings be returned here? const { content, @@ -18,6 +23,7 @@ export const generateHtmlFullTemplateHackernoon = (markdown) => { // previewText } = parseContent({ markdown, + data, }); verification(warnings, content); diff --git a/start.js b/start.js index 4c62efba0..e6039c43c 100644 --- a/start.js +++ b/start.js @@ -1,30 +1,31 @@ import { writeHTML, isFolderExists, - readSourceFile, generateTemplateName, } from 'markup-generator'; import { generateHtmlFullTemplateHackernoon, generateReactFullTemplateHackernoon, generateHtmlFullTemplateRecipes, + generateFrontHackernoon, } from './src'; -import { printMessage } from './src/helper'; - +import { printMessage } from './src/domain/helper-methods/cli'; import { deliver } from './src/domain/deliver/deliver'; import { MESSAGE_HTML_FULL_TEMPLATE2 } from './src/domain/deliver/deliver.constants'; - +import { + hackernoonContent, + FULL_SOURCE, + nomoretogoContent, + frontMarkdownHackernoon, +} from './src/domain/content-source'; // TODO add more messages here, and finally replace messages in our methods const MESSAGE_REACT_FULL_TEMPLATE = 'The FullTemplate has been parsed successfully'; // const MESSAGE_REACT_CONTENT = 'The Content has been parsed successfully'; - -//------------------- -// @TODO add path package, in order to make it work PERFECTLY -const FULL_SOURCE = 'source/source.md'; -const RECIPES_SOURCE = 'source/recipes/source-nmtg.md'; - -const markdown = readSourceFile(FULL_SOURCE); +// connection to source files moved into /domain/content-source/index.js +const markdown = hackernoonContent; +// console.log('-----'); +// console.log(frontMarkdownHackernoon); isFolderExists('./generated'); isFolderExists('./tests/_generated'); @@ -48,7 +49,7 @@ export const modes = { printMessage(MESSAGE_REACT_FULL_TEMPLATE, 'green2'); }, recipesFull: () => { - const markdownRecipes = readSourceFile(RECIPES_SOURCE); + const markdownRecipes = nomoretogoContent; const recipesFullTemplate = generateHtmlFullTemplateRecipes(markdownRecipes); @@ -59,6 +60,19 @@ export const modes = { MESSAGE_HTML_FULL_TEMPLATE2, ); }, + hackernnonFront: () => { + // const markdownRecipes = nomoretogoContent; + + const HNFrontFullTemplate = generateFrontHackernoon( + frontMarkdownHackernoon, + ); + + deliver( + HNFrontFullTemplate, + 'frontmatter-full-template', + MESSAGE_HTML_FULL_TEMPLATE2, + ); + }, }; modes[process.env.PARSE ?? 'full'](FULL_SOURCE); |