mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-13 19:56:18 +09:00
format code
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { formatInTimeZone } from "date-fns-tz";
|
||||
|
||||
const dateFormat = (date:Date | string, format:string = "dd MMM, yyyy"): string => {
|
||||
const dateFormat = (
|
||||
date: Date | string,
|
||||
format: string = "dd MMM, yyyy"
|
||||
): string => {
|
||||
return formatInTimeZone(date, "America/New_York", format);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// sort by date
|
||||
export const sortByDate = (array: any[]) => {
|
||||
const sortedArray = array.sort(
|
||||
(a:any, b:any) =>
|
||||
(a: any, b: any) =>
|
||||
new Date(b.data.date && b.data.date).valueOf() -
|
||||
new Date(a.data.date && a.data.date).valueOf()
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { slug } from 'github-slugger';
|
||||
import { slug } from "github-slugger";
|
||||
import { marked } from "marked";
|
||||
|
||||
marked.use({
|
||||
@@ -8,18 +8,16 @@ marked.use({
|
||||
|
||||
// slugify
|
||||
export const slugify = (content: string): string => {
|
||||
|
||||
return slug(content);
|
||||
};
|
||||
|
||||
// markdownify
|
||||
export const markdownify = (content: string, div?:boolean): string => {
|
||||
return div? marked.parse(content) : marked.parseInline(content);
|
||||
export const markdownify = (content: string, div?: boolean): string => {
|
||||
return div ? marked.parse(content) : marked.parseInline(content);
|
||||
};
|
||||
|
||||
// humanize
|
||||
export const humanize = (content: string): string => {
|
||||
|
||||
return content
|
||||
.replace(/^[\s_]+|[\s_]+$/g, "")
|
||||
.replace(/[_\s]+/g, " ")
|
||||
|
||||
Reference in New Issue
Block a user