butiran

edit button on post

· 2 mins read · edit

info

  • Date:
    • Created 13-oct-2025
    • Edited 14-oct-2025
  • Files: notes/single.html, css/notes.css.
  • Requirement: npprel:/// protocol from 25i67 , 25j24 .

notes

  • After a short discussion 1, the button is included in notes (posts) template instead of as a shortcode.
  • For older notes without filetopath parameter in the front matter, the text with link will not be displayed.
  • Rename filetopath to pathtofile on 14-oct-2025.

contents

  • Filename layouts/notes/single.html
    {{ define "main" }}
      <head>
        <link rel="stylesheet" href='{{ "css/notes.css" | relURL }}?v={{ now.Unix }}'>
      </head>
    
      <div class="note-container">
        <h1 class="note-title">
          {{ .Title }}
        </h1>
    
        <div class="info-after-title">
    
          <ul class='authors-container'>
          {{- range .Params.authors }}
            {{- with $.Site.GetPage "taxonomyTerm" (printf "authors/%s" (urlize .)) }}
              <li class='author'>
                <a href="{{ .Permalink }}">{{ .Params.name }}</a>
              </li>
            {{ end }}
          {{ end }}
          </ul>
    
          {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05 07:00" }}
          {{ $dateHuman := .Date | time.Format "2 Jan 2006" }}
    
          {{ $file := .Page.Params.filetopath }}
    
          <div class="date-reading-time-edit">
            <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
            &middot;
            {{ partial "reading-time.html" . }}
            {{ if .Page.Params.pathtofile }}
              &middot;
              <a class="link" href="npprel:///{{ $file }}">edit</a>
            {{ else }}
            {{ end }}
          </div>
    
        </div>
    
        <div class="note-content">
          {{ .Content }}
        </div>
    
      </div>
    
      {{ partial "posts/math.html" . }}
    {{ end }}
    
  • Filename static/css/notes.css
    /* note.css */
    
    .note-container {
    }
    
    .note-title {
    }
    
    .note-content {
    }
    
    .note-content h2 {
      border: 0px #4f81bd solid;
      margin-bottom: -0.5em;
    }
    
    .info-after-title {
      display: flex;
    }
    
    .date-reading-time-edit {
      flex: 2.5;
      text-align: right;
      border: 0px solid blue;
    }
    
    .authors-container {
      flex: 5;
      padding-left: 0;
      margin: 0;
      border: 0px solid blue;
    }
    
    .author {
      display: inline-block;
    }
    
    .author::after {
      content: ",";
    }
    
    .author:last-child::after {
      content: "";
    }
    
    .note-content pre {
      padding: 1.5em 2em;
      word-wrap: break-word;
      overflow-x: scroll;
    }
    
    .mol-container {
      margin: auto;
      position: relative;
      height: 300px;
      width: 300px;
    }
    
    .scatter-container {
      width: 360px;
      height: 200px;
    }
    

refs


  1. GPT-5, “Shortcode vs Template”, ChatGPT, 13 Oct 2025, url https://chatgpt.com/share/68ec8e46-058c-800a-8329-488a293c2b57 [20251013]. ↩︎