aboutsummaryrefslogtreecommitdiffstats
path: root/new.sh
blob: 6634f52761dca163324d92c056d661fe13b0945f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash

# Load data
printf '%s' "Enter Title: "
read -r
title="$REPLY"

printf '%s' "Enter Author: "
read -r
author="$REPLY"

printf '%s' "Enter Category: "
read -r
category="$REPLY"

title="${title/\//}"

# Slug | lowercase, without accent mark
lug=$(printf '%s' "${title// /-}")
slug=$(echo "$lug" | sed 'y/áÁàÀãÃâÂéÉêÊíÍóÓõÕôÔúÚñÑçÇ/aAaAaAaAeEeEiIoOoOoOuUnNcC/' | sed -e 's/\(.*\)/\L\1/')

printf '%s' "Enter Tags: "
read -r
tag="$REPLY"

# output
o_author=$(printf '%s%s\n' "Author: " "$author")
o_category=$(printf '%s%s\n' "Category: " "$category")
o_date=$(printf '%s%s\n' "Date: " "$(date +"%Y-%m-%d %I:%M")")
o_slug=$(printf '%s%s\n' "Slug: " "$slug")
o_tag=$(printf '%s%s\n' "Tags: " "$tag")
o_title=$(printf '%s%s\n' "Title: " "$title")

# export to file.md
printf '%s\n%s\n%s\n%s\n%s\n%s\n' "$o_author"\
                                  "$o_category"\
                                  "$o_date"\
                                  "$o_slug"\
                                  "$o_tag"\
                                  "$o_title" > "content/articles/$slug.md"