GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add create blog post wrapper from documentation repo · secureCodeBox/secureCodeBox@2507ea8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bin
    • create-blog-post.sh
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bin/create-blog-post.sh‎

Copy file name to clipboard
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-FileCopyrightText: the secureCodeBox authors
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
#
8+
# Helper script to create new blog posts
9+
#
10+
# What does this script for you?
11+
# 1. It creates the proper filename (eg. blog/2020-10-01-this-is-a-title.md).
12+
# - current date
13+
# - lower case
14+
# - spaces replaced by dashes
15+
# 2. Adds basic frontmatter into it.
16+
#
17+
# You may place a file .author_meta into the root of the repo to define some variables
18+
# for the frontmatter. The script will tell you if no meta file was found.
19+
#
20+
21+
set -ue
22+
23+
# @see: http://wiki.bash-hackers.org/syntax/shellvars
24+
[ -z "${SCRIPT_DIRECTORY:-}" ] \
25+
&& SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" \
26+
&& export SCRIPT_DIRECTORY
27+
28+
BASE_DIR=$(dirname "${SCRIPT_DIRECTORY}")/docs-builder
29+
BLOG_DIR="${BASE_DIR}/blog"
30+
USAGE="Usage: $(basename "$0") 'The title of Your Post'"
31+
32+
if (( $# != 1 )); then
33+
echo "Error: The title is missing!"
34+
echo "${USAGE}"
35+
exit 1
36+
fi
37+
38+
if [ '-h' = "${1}" ]; then
39+
echo "${USAGE}"
40+
exit 0
41+
fi
42+
43+
AUTHOR_META_FILE="${BASE_DIR}/.author_meta"
44+
if [ -f "${AUTHOR_META_FILE}" ]; then
45+
echo "Using author meta file ${AUTHOR_META_FILE}."
46+
# shellcheck disable=SC1090
47+
source "${AUTHOR_META_FILE}"
48+
else
49+
echo "No author meta file found at ${AUTHOR_META_FILE}!"
50+
echo
51+
echo "You could use one to predefine some variables. Just put this:"
52+
echo
53+
echo "AUTHOR='Gordon Shumway'"
54+
echo "AUTHOR_TITLE='Core Developer'"
55+
echo "AUTHOR_URL='https://...'"
56+
echo "AUTHOR_IMAGE_URL='https://...'"
57+
echo
58+
echo "Into the file ${AUTHOR_META_FILE}."
59+
fi
60+
61+
TITLE="${1}"
62+
TITLE_CLEANSED=$(echo "${TITLE}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
63+
DATE=$(date +'%Y-%m-%d')
64+
BLOG_POST_FILE="${BLOG_DIR}/${DATE}-${TITLE_CLEANSED}.md"
65+
cat << EOF > "${BLOG_POST_FILE}"
66+
---
67+
title: ${TITLE}
68+
author: ${AUTHOR:-}
69+
author_title: ${AUTHOR_TITLE:-}
70+
author_url: ${AUTHOR_URL:-}
71+
author_image_url: ${AUTHOR_IMAGE_URL:-}
72+
tags:
73+
description:
74+
image:
75+
draft: true
76+
---
77+
EOF

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.