0.1.4 • Published 7 months ago

@htoojs/convert v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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>
0.1.4

7 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago