0.1.4 • Published 7 months ago
@htoojs/convert v0.1.4
Convert
Markdown to HTML with Showdown
Markdown to HTML converter with Showdown and Showdown Highlight for custom usage.
Usage
Reading Time
import {readTime} from '@htoojs/convert';
const readingTime = readTime(text)
// return {number} in seconds
Format Date
import { formatDate} from '@htoojs/convert';
const formatedDate = formatDate(date, locale);
// return {string}
Converter
Get data of post
import { converter } from '@htoojs/convert';
// Get Frontmatter
const frontmatter = converter('path_to_mdfile').getData;
// Get json format
const json = converter('path_to_mdfile').getJson;
// Get title of post
const post_title = converter('path_to_mdfile').postTitle;
// Get date of post , return {string}
const post_date = converter('path_to_mdfile').postDate;
// Get reading time of post , return {number} in seconds
const post_reading_time = converter('path_to_mdfile').readingTime;
Get HTML return
import { converter } from '@htoojs/convert';
/* Get blog post with HTML , return {post-title,post-date,reading time} and {converted-post-content}*/
const post_html = converter('path_to_mdfile').postHtml;
/* Get page with HTML , return {converted-page-content} */
const page_html = converter('path_to_mdfile').pageHtml;
Post HTML
<h1><!-- post_title --> </h1>
<small> <!-- post_date --> | Reading Time: <!-- post_reading_time --> minutes</small>
<div> <!-- converted-post-content --> </div>
Page HTML
<div> <!-- converted-post-content --> </div>