This is a solution to the In-browser markdown editor challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- Create, Read, Update, and Delete markdown documents
- Name and save documents to be accessed as needed
- Edit the markdown of a document and see the formatted preview of the content
- View a full-page preview of the formatted content
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Bonus: If you're building a purely front-end project, use localStorage to save the current state in the browser that persists when the browser is refreshed
- Bonus: Build this project as a full-stack application
- Solution URL: Add solution URL here
- Netlify URL: Markdown Editor
- AWS URL aws link
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
- React - JS library
- React-showdown - HTML markup convertor
- AWS amplify- hosting and authentication
- Cyclic- hosting backend and database
react-showdown is a tool that converts markdown to html . The installation and usage process is as follows:
- install using
npm
oryarn
. That isnpm install --save react-showdown
with npm or the yarn equivalenceyarn add react-showdown
- import it in your project file with
import MarkdownView from 'react-showdown';
const markdown = `
# Welcome to React Showdown :+1:
To get started, edit the markdown in \`example/src/App.tsx\`.
| Column 1 | Column 2 |
|----------|----------|
| A1 | B1 |
| A2 | B2 |
`;
return (
<MarkdownView
markdown={markdown}
options={{ tables: true, emoji: true }}
/>
);
};
AWS Amplify
- amplify allows hosting on the AWS platform and a lot more other additionals, such as authentication and database management.
- several tutorials can be found on their website including the following AWS amplify Here are the steps that I took to deploy on aws amplify.
- log into your aws account.
- under
services
look foraws amplify
and select it. - look for options to
host
an application. Since this was not my first application the display shown below is a bit different when deploying the first time. Here it shows the list of already deployed applications and on the top right some options tohost web app
or tobuild web app
. Host web app allows you to host your already created application, so this was the selection to choose. - Choose where your project is hosted or choose the other options as in the image below:
- My projects are hosted on GitHub, hence I had to choose
GitHub
. Then press the continue button - The next step will allow to choose the
repository
andbranch
to deploy. Select any other choices that needs filling. - One most important step is in the
Build settings
page, I had on numerous occassions failed to create a successfully build because of wrong configurations. The amplify.yml will look as below
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run build
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- on
preBuild commands
change it to be the command that is used to install dependencies. In this casenpm install
then thebuild command
should also be edited to thebuild
command in your project.npm run build
in my case. Lastly I changed thebaseDirectory
to the directory created with thebuild
command . Here it was thedist
folder.
CYCLIC - connecting database , backend and frontend
- Heroku was a popular site hosting/deploying such applications. The service was free on Heroku until 28/11/2022. After a few search for a replacement , i settled for CYCLIC. Procedure followed is shown below
- Open a free account on Cyclic using the link above. You can open the account using your Github account if you have one
- Open your Cyclic dashboard to proceed and look for an option to
Create an app
- The next page gives you an option to
Link your project
or to select fromStarter Templates
. Select theLink your project
option and any other option that allows you to view the projects in your GitHub account. You will be able to view all the projects in your account. - For a Fullstack Application, select the repository that has your backend configurations. Accept any other options and choose the branch to deploy.
- The deploy does not take long and will be done in less than a minute. A link will be generated that will connect the backend to the mongoDB. Test the link if it will give you the results in your mongoDb.
- Importantly you need to update the Environment Variables of your project
- In the frontend project , use the link generated in your Cyclic as the end point. See code below
export const API_ENDPOINT_PATH = process.env.NODE_ENV === 'production'
? "https://lime-smoggy-camel.cyclic.app/"
: "http://localhost:4000/api/editor"
First we check the value of process.env.NODE_ENV
if it is equal to production
, it true then the https://lime-smoggy-camel.cyclic.app/
will be assigned to the endpoint else we are in development mode hence the locahost value will be used.
See and listen to the video How to deploy MERN App in 2 minutes | cyclic.sh | Heroku alternative
- Progressive Web App (pwa) pwa
- aws react tutorial setting - a step by step guide for setting up AWS hosting using amplify
- Website - Chamu Mutezva
- Frontend Mentor - @ChamuMutezva
- Twitter - @ChamuMutezva