commit d808819bc8442204314ce150c8fef52631f71782 Author: Jörn-Michael Miehe <jmm@yavook.de> Date: Sat Aug 17 02:35:18 2024 +0200 initial commit diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..a570529 --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,53 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Hugo", + + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/go:1-bookworm", + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/git-lfs:1": {}, + "ghcr.io/devcontainers/features/hugo:1": { + // "version": "0.128.2", + "version": "latest", + "extended": true + }, + "ghcr.io/devcontainers-contrib/features/apt-get-packages:1": { + "packages": "git-flow" + }, + "ghcr.io/devcontainers-contrib/features/go-task:1": {}, + // "ghcr.io/devcontainers/features/node:1": {}, + // SVG optimization tool + "ghcr.io/devcontainers-contrib/features/npm-package:1": { + "package": "svgo" + } + }, + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "zsh" + }, + "extensions": [ + "gruntfuggly.todo-tree", + "kaellarkin.hugo-shortcode-syntax", + "mhutchie.git-graph", + "streetsidesoftware.code-spell-checker", + "streetsidesoftware.code-spell-checker-german", + "tamasfe.even-better-toml", + "timonwong.shellcheck" + ] + } + }, + + "postCreateCommand": "mkdir -p \"${HOME}/.oh-my-zsh/custom/completions\" && hugo completion zsh > \"${HOME}/.oh-my-zsh/custom/completions/_hugo\"" + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9a02398 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +/public +/resources +/.* diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2c48f6b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.jpg filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text +*.ico filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86c95ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Generated files by hugo +/public/ +/resources/_gen/ +/assets/jsconfig.json +hugo_stats.json + +# Executable may be added to repository +hugo.exe +hugo.darwin +hugo.linux + +# Temporary lock file while building +/.hugo_build.lock diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..f505e2c --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-vscode-remote.remote-containers", + "simonsiefke.svg-preview" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7285497 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "git.closeDiffOnOperation": true, + "todo-tree.tree.showCountsInTree": true, + "todo-tree.filtering.excludeGlobs": [ + "**/node_modules/*/**", + "**/themes/**" + ], + "cSpell.language": "en,de-DE" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..8795290 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,25 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Hugo: Server", + "detail": "Run development server with hot reload", + "type": "shell", + "command": "hugo server --bind '0.0.0.0' --baseURL 'http://localhost:1313/' --gc --forceSyncStatic --cleanDestinationDir --buildDrafts --buildFuture --buildExpired", + "presentation": { + "echo": false, + "reveal": "silent" + }, + "problemMatcher": [] + }, + { + "label": "Hugo: Build", + "detail": "Build this site for deployment", + "type": "shell", + "command": "hugo", + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d409795 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 Yavook!de + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..eb5b883 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,23 @@ +version: '3' + +tasks: + new-content: + vars: + content_file: content/{{ .content_section }}/{{ .NAME | default "new-post" }}/{{ .content_name | default "index" }}.md + cmds: + - hugo new content --kind "{{ .content_kind | default "default" }}" "{{ .content_file }}" + - code --reuse-window "{{ .content_file }}" + + new-post: + cmds: + - task: new-content + vars: + content_section: blog + content_name: + ref: .content_name + + new-post-en: + cmds: + - task: new-post + vars: + content_name: index.en diff --git a/archetypes/default.md b/archetypes/default.md new file mode 100644 index 0000000..7fe0eef --- /dev/null +++ b/archetypes/default.md @@ -0,0 +1,11 @@ ++++ +title = "{{ replace .File.ContentBaseName "-" " " | title }}" +summary = "" +tags = [] + +date = "{{ time.Now.Format "2006-01-02" }}" +# lastmod = + +draft = true +# showDateUpdated = true ++++ diff --git a/tools/chores/.publish/Dockerfile b/tools/chores/.publish/Dockerfile new file mode 100644 index 0000000..4ebb790 --- /dev/null +++ b/tools/chores/.publish/Dockerfile @@ -0,0 +1,50 @@ +############## +# build site # +############## + +ARG DEBIAN_VERSION=bookworm-slim +FROM debian:${DEBIAN_VERSION} AS build + +ARG HUGO_VERSION +ARG HUGO_FILENAME=hugo_extended_${HUGO_VERSION}_linux-amd64.deb + +# env setup +WORKDIR /usr/local/src/hugo-site + +# install hugo +RUN set -ex; \ + \ + apt-get update; apt-get install -y \ + curl \ + ; \ + \ + curl -sSL -o /tmp/hugo.deb \ + "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_FILENAME}"; \ + apt-get install -y /tmp/hugo.deb; \ + rm -f /tmp/hugo.deb; \ + \ + apt-get autoremove --purge -y \ + curl \ + ; rm -rf /var/lib/apt/lists/*; + +# copy and build site +COPY ./ ./ +RUN hugo \ + --cleanDestinationDir \ + --minify \ + --destination /tmp/hugo-site/html + +############## +# serve site # +############## + +FROM nginx:mainline-alpine AS production + +# remove default site +RUN rm -rf /usr/share/nginx/html + +# add conf.d directory +COPY tools/chores/.publish/nginx_conf.d /etc/nginx/conf.d + +# add built site +COPY --from=build /tmp/hugo-site/html /usr/share/nginx/html diff --git a/tools/chores/.publish/nginx_conf.d/compression.conf b/tools/chores/.publish/nginx_conf.d/compression.conf new file mode 100644 index 0000000..ca9690d --- /dev/null +++ b/tools/chores/.publish/nginx_conf.d/compression.conf @@ -0,0 +1,71 @@ +# ---------------------------------------------------------------------- +# | Compression | +# ---------------------------------------------------------------------- + +# https://nginx.org/en/docs/http/ngx_http_gzip_module.html + +# Enable gzip compression. +# Default: off +gzip on; + +# Compression level (1-9). +# 5 is a perfect compromise between size and CPU usage, offering about 75% +# reduction for most ASCII files (almost identical to level 9). +# Default: 1 +gzip_comp_level 5; + +# Don't compress anything that's already small and unlikely to shrink much if at +# all (the default is 20 bytes, which is bad as that usually leads to larger +# files after gzipping). +# Default: 20 +gzip_min_length 256; + +# Compress data even for clients that are connecting to us via proxies, +# identified by the "Via" header (required for CloudFront). +# Default: off +gzip_proxied any; + +# Tell proxies to cache both the gzipped and regular version of a resource +# whenever the client's Accept-Encoding capabilities header varies; +# Avoids the issue where a non-gzip capable client (which is extremely rare +# today) would display gibberish if their proxy gave them the gzipped version. +# Default: off +gzip_vary on; + +# Compress all output labeled with one of the following MIME-types. +# `text/html` is always compressed by gzip module. +# Default: text/html +gzip_types + application/atom+xml + application/geo+json + application/javascript + application/x-javascript + application/json + application/ld+json + application/manifest+json + application/rdf+xml + application/rss+xml + application/vnd.ms-fontobject + application/wasm + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/eot + font/otf + font/ttf + image/bmp + image/svg+xml + image/vnd.microsoft.icon + image/x-icon + text/cache-manifest + text/calendar + text/css + text/javascript + text/markdown + text/plain + text/xml + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy; \ No newline at end of file diff --git a/tools/chores/.publish/nginx_conf.d/default.conf b/tools/chores/.publish/nginx_conf.d/default.conf new file mode 100644 index 0000000..c2795cc --- /dev/null +++ b/tools/chores/.publish/nginx_conf.d/default.conf @@ -0,0 +1,31 @@ +server { + listen [::]:80; + listen 80; + + server_name ~^www\.(?<domain>.+)$; + return 301 https://$domain$request_uri; +} + +server { + listen [::]:80; + listen 80 default_server; + + server_name _; + root /usr/share/nginx/html; + index index.html; + + location / { + error_page 404 /404.html; + } + + location ~ '^/(?<lang_dir>\w{2})/' { + error_page 404 /${lang_dir}/404.html; + } + + # redirect server error pages to the static page /50x.html + + # error_page 500 502 503 504 /50x.html; + # location = /50x.html { + # root /usr/share/nginx/html; + # } +} diff --git a/tools/chores/publish b/tools/chores/publish new file mode 100755 index 0000000..18f6c83 --- /dev/null +++ b/tools/chores/publish @@ -0,0 +1,19 @@ +#!/bin/sh + +script="$( readlink -f "${0}" )" +script_dir="$( dirname "${script}" )" +repo_dir="$( readlink -f "${script_dir}/../.." )" + +# get hugo feature version from devcontainer.json +dc_json_file="${repo_dir}/.devcontainer.json" +HUGO_VERSION=$( grep -A3 'features/hugo' "${dc_json_file}" | grep 'version' | sed -r 's/^.*"([^"]+)",?\s*$/\1/' ) + +# TODO add --push to publish to registry +# TODO change --tag value +docker buildx build \ + --pull \ + --file "${script_dir}/.publish/Dockerfile" \ + --build-arg "HUGO_VERSION=${HUGO_VERSION}" \ + --tag "localhost/hugo-site:latest" \ + --platform "linux/amd64" \ + "${repo_dir}"