feat: draft_by_default and lang
All checks were successful
Lint / shellcheck (push) Successful in 36s
Release Standalone Builder / build (release) Successful in 31s
Release Standalone Builder / publish-aur (release) Successful in 34s
Release Standalone Builder / publish-homebrew (release) Successful in 7s

This commit is contained in:
2026-03-30 09:55:26 +02:00
parent 99e1f5dd24
commit aac9198878
2 changed files with 12 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ BEGIN {
style_path = ENVIRON["AWK_STYLE_PATH"] style_path = ENVIRON["AWK_STYLE_PATH"]
head_extra = ENVIRON["AWK_HEAD_EXTRA"] head_extra = ENVIRON["AWK_HEAD_EXTRA"]
header_brand = ENVIRON["AWK_HEADER_BRAND"] header_brand = ENVIRON["AWK_HEADER_BRAND"]
lang = ENVIRON["AWK_LANG"]
if (current_url != "") { if (current_url != "") {
nav = replace_all(nav, "href=\"" current_url "\"", "href=\"" current_url "\" class=\"current-page\"") nav = replace_all(nav, "href=\"" current_url "\"", "href=\"" current_url "\" class=\"current-page\"")
} }
@@ -24,6 +25,7 @@ BEGIN {
{ {
line = $0 line = $0
line = replace_all(line, "{{TITLE}}", title) line = replace_all(line, "{{TITLE}}", title)
line = replace_all(line, "{{LANG}}", lang)
line = replace_all(line, "{{NAV}}", nav) line = replace_all(line, "{{NAV}}", nav)
line = replace_all(line, "{{FOOTER}}", footer) line = replace_all(line, "{{FOOTER}}", footer)
line = replace_all(line, "{{CSS}}", style_path) line = replace_all(line, "{{CSS}}", style_path)

14
kewt.sh
View File

@@ -40,6 +40,8 @@ trap 'exit 0' HUP INT TERM
DEFAULT_CONF='title = "kewt" DEFAULT_CONF='title = "kewt"
style = "kewt" style = "kewt"
lang = "en"
draft_by_default = false
dir_indexes = true dir_indexes = true
single_file_index = true single_file_index = true
flatten = false flatten = false
@@ -66,7 +68,7 @@ posts_per_page = 12
custom_admonitions = ""' custom_admonitions = ""'
DEFAULT_TMPL='<!doctype html> DEFAULT_TMPL='<!doctype html>
<html> <html lang="{{LANG}}">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -145,9 +147,9 @@ create_new_post() {
post_date_val="$(date "+%Y-%m-%d %H:%M")" post_date_val="$(date "+%Y-%m-%d %H:%M")"
if [ -n "$post_user_title" ]; then if [ -n "$post_user_title" ]; then
printf -- '---\ntitle = "%s"\ndate = "%s"\ndraft = false\n---\n# %s\n' "$post_user_title" "$post_date_val" "$post_user_title" > "$file_path" printf -- '---\ntitle = "%s"\ndate = "%s"\ndraft = %s\n---\n# %s\n' "$post_user_title" "$post_date_val" "$draft_by_default" "$post_user_title" > "$file_path"
else else
printf -- '---\ndate = "%s"\ndraft = false\n---\n' "$post_date_val" > "$file_path" printf -- '---\ndate = "%s"\ndraft = %s\n---\n' "$post_date_val" "$draft_by_default" > "$file_path"
fi fi
echo "Created new post at '$file_path'." echo "Created new post at '$file_path'."
@@ -420,6 +422,8 @@ generate_nav() {
title="kewt" title="kewt"
style="kewt" style="kewt"
lang="en"
draft_by_default="false"
footer="made with <a href=\"https://kewt.krzak.org\">kewt</a>" footer="made with <a href=\"https://kewt.krzak.org\">kewt</a>"
dir_indexes="true" dir_indexes="true"
single_file_index="true" single_file_index="true"
@@ -498,6 +502,8 @@ load_config() {
posts_dir) posts_dir="${val#/}" ;; posts_dir) posts_dir="${val#/}" ;;
posts_per_page) posts_per_page="$val" ;; posts_per_page) posts_per_page="$val" ;;
custom_admonitions) custom_admonitions="$val" ;; custom_admonitions) custom_admonitions="$val" ;;
lang) lang="$val" ;;
draft_by_default) draft_by_default="$val" ;;
esac esac
done < "$1" done < "$1"
} }
@@ -757,7 +763,7 @@ render_markdown() {
head_extra="$head_extra_og" head_extra="$head_extra_og"
fi fi
ENABLE_HEADER_LINKS="$enable_header_links" CUSTOM_ADMONITIONS="$custom_admonitions" MARKDOWN_SITE_ROOT="$src" MARKDOWN_FALLBACK_FILE="$script_dir/styles/$style.css" sh "$script_dir/markdown.sh" "$content_file" | AWK_CURRENT_URL="$current_url" AWK_TITLE="$page_title" AWK_NAV="$nav" AWK_FOOTER="$footer" AWK_STYLE_PATH="${style_path}${asset_version}" AWK_HEADER_BRAND="$header_brand" AWK_HEAD_EXTRA="$head_extra" awk -f "$awk_dir/render_template.awk" "$local_template" ENABLE_HEADER_LINKS="$enable_header_links" CUSTOM_ADMONITIONS="$custom_admonitions" MARKDOWN_SITE_ROOT="$src" MARKDOWN_FALLBACK_FILE="$script_dir/styles/$style.css" sh "$script_dir/markdown.sh" "$content_file" | AWK_LANG="$lang" AWK_CURRENT_URL="$current_url" AWK_TITLE="$page_title" AWK_NAV="$nav" AWK_FOOTER="$footer" AWK_STYLE_PATH="${style_path}${asset_version}" AWK_HEADER_BRAND="$header_brand" AWK_HEAD_EXTRA="$head_extra" awk -f "$awk_dir/render_template.awk" "$local_template"
} }
needs_rebuild() { needs_rebuild() {