Build a Markdown-based Blog with Spring Boot — Part 3

Build a Markdown Blog with Spring Boot — Part 3

Defining application properties

Inside the application.properties file, we specify our database URL, username, password, and the database initialization method.

application.properties file

Adding CommonMark to POM

pom.xml file after adding CommonMark dependency
Loading Maven changes in IntelliJ IDEA
Loading Maven changes in IntelliJ IDEA

Conventions for Markdown files

From this point on, we will assume that our blog posts will be stored as Markdown files in the resources/posts/ directory.

Reading lines from Markdown files

We need to write a utility class with methods that serve to read individual lines from a Markdown file, retrieve ID from a file name, and retrieve title from a file name.

Implementation of readLinesFromMdFile method
Implementations of getTitleFromFileName and getIdFromFileName methods

Rendering HTML

We need to write another utility class with a method that parses the passed List of Markdown lines and returns a String of rendered HTML content.

Implementation of render method

Code

This is it for part 3. In the next piece, we will pick up the project from this point on.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store