From 48ebeca90c6a11b77bc53cbbaae66481a74686d3 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Fri, 16 Oct 2026 00:21:23 +0800 Subject: Simplify source links and show HTML filenames in breadcrumbs --- Makefile | 1 - README.md | 2 +- content/projects/_index.md | 2 +- layouts/partials/document-view.html | 16 +-------------- layouts/partials/site-identity.html | 3 +-- scripts/publish-raw | 40 ------------------------------------- static/style.css | 3 --- 7 files changed, 4 insertions(+), 63 deletions(-) delete mode 100755 scripts/publish-raw diff --git a/Makefile b/Makefile index e6b1d33..adb3ad1 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ BASE_URL ?= http://localhost:1314/ build: clean $(HUGO) --baseURL "$(BASE_URL)" - ./scripts/publish-raw serve: build $(HUGO) server --disableFastRender --disableLiveReload --port $(PORT) --baseURL "http://localhost:$(PORT)/" diff --git a/README.md b/README.md index 750c513..7817c20 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ make serve make clean ``` -`make build` recreates `public/`, runs Hugo, and then copies every public Markdown source and its page-bundle attachments without changing their bytes. The default `BASE_URL` is `http://localhost:1314/`; pass `BASE_URL=https://example.org/` to generate absolute production URLs. `make serve` prepares that same output before starting Hugo at `http://localhost:1314/`; override the port with `make serve PORT=8080`. Hugo rebuilds HTML while serving; restart the command after editing Markdown when the raw `.md` snapshot also needs to change. +`make build` recreates `public/` and runs Hugo. Each document links to its Markdown source in the Git repository. The default `BASE_URL` is `http://localhost:1314/`; pass `BASE_URL=https://example.org/` to generate absolute production URLs. `make serve` prepares that same output before starting Hugo at `http://localhost:1314/`; override the port with `make serve PORT=8080`. Hugo rebuilds the site while serving. The source repository URL, per-file Git base URL, and public email are configured once in `hugo.toml`. diff --git a/content/projects/_index.md b/content/projects/_index.md index d2360cf..303f2f3 100644 --- a/content/projects/_index.md +++ b/content/projects/_index.md @@ -8,7 +8,7 @@ license: CC-BY-SA-4.0 ## rhomepage -A document-first personal website that publishes each article as readable HTML and unchanged Markdown. +A document-first personal website that publishes each article as readable HTML, with links to its Markdown source in the Git repository. - Technology: Hugo, HTML, CSS, POSIX shell - License: GPL-3.0-or-later diff --git a/layouts/partials/document-view.html b/layouts/partials/document-view.html index 5bfc7b6..ffe49eb 100644 --- a/layouts/partials/document-view.html +++ b/layouts/partials/document-view.html @@ -1,19 +1,5 @@ {{- if .File -}} - {{- $rawURL := "" -}} - {{- if .IsPage -}} - {{- $htmlBase := strings.TrimSuffix ".html" .RelPermalink -}} - {{- $rawURL = printf "%s/index.md" $htmlBase -}} - {{- else if .IsSection -}} - {{- $rawURL = printf "%s_index.md" .RelPermalink -}} - {{- end -}} {{- $gitBase := strings.TrimSuffix "/" site.Params.gitBase -}} {{- $gitURL := printf "%s/content/%s" $gitBase .File.Path -}} - +

source

{{- end -}} diff --git a/layouts/partials/site-identity.html b/layouts/partials/site-identity.html index 0f18d35..631969a 100644 --- a/layouts/partials/site-identity.html +++ b/layouts/partials/site-identity.html @@ -4,14 +4,13 @@ {{ $identity }} {{- if not $page.IsHome -}} {{- $path := strings.TrimSuffix "/" $page.RelPermalink -}} - {{- $path = strings.TrimSuffix ".html" $path -}} {{- $prefix := "/" -}} {{- $segments := split $path "/" -}} {{- range $index, $segment := $segments -}} {{- if ne $segment "" -}} {{- $prefix = printf "%s%s/" $prefix $segment -}} {{- if eq (add $index 1) (len $segments) -}} - {{ $segment }} + {{ $segment }}{{ if strings.HasSuffix $page.RelPermalink "/" }}{{ end }} {{- else -}} {{ $segment }} {{- end -}} diff --git a/scripts/publish-raw b/scripts/publish-raw deleted file mode 100755 index cc05958..0000000 --- a/scripts/publish-raw +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -set -eu - -content_dir=${1:-content} -public_dir=${2:-public} - -[ -d "$content_dir" ] || exit 0 -mkdir -p "$public_dir" - -find "$content_dir" -type f -print | while IFS= read -r source -do - relative=${source#"$content_dir"/} - - case "$relative" in - updates/_index.md) - # Updates is an aggregate index, not a published Markdown document. - continue - ;; - journal/_index.md) - target=$public_dir/journal/_index.md - ;; - journal/*/_index.md|journal/*/*/_index.md) - target=$public_dir/$relative - ;; - journal/*/*/*/*) - target=$public_dir/$relative - ;; - journal/*) - # Only source files for published journal sections and entries are public. - continue - ;; - *) - target=$public_dir/$relative - ;; - esac - - mkdir -p "$(dirname "$target")" - cp "$source" "$target" -done diff --git a/static/style.css b/static/style.css index 2dc2af2..30bc5d8 100644 --- a/static/style.css +++ b/static/style.css @@ -257,9 +257,6 @@ a:focus-visible { } .document-view { - display: flex; - flex-wrap: wrap; - gap: 0 0.55rem; margin-block: 1rem; color: var(--muted); font-size: 0.875rem; -- cgit v1.2.3