Explorar o código

Preview Handling and Patreon Linking

Steffen Cole Blake %!s(int64=4) %!d(string=hai) anos
pai
achega
560cdb76d0

+ 2 - 0
config.toml

@@ -4,6 +4,8 @@ title = 'Nightmares'
 pluralizelisttitles = false
 
 [params]
+    ShowFuture = 'FALSE'
+    PatreonLink = 'https://www.patreon.com/technically_fun'
     css = [
         '/css/lib/bootstrap.min.css',
         '/css/site.css'

+ 7 - 0
content/catalogue/test.md

@@ -0,0 +1,7 @@
++++
+author = "Steffen Blake"
+title = "TEST"
+date = "2021-10-21"
++++
+
+This content only shows up for Patrons

+ 6 - 4
layouts/_default/list.html

@@ -10,10 +10,12 @@
     {{ .Content }}
 
     <ol>
-        {{ range .Pages }}
-        <li>
-            <a href="{{.Permalink}}">{{ .Title }}</a> <span class="date">- {{ .Date.Format "2006-01-02" }}</span>
-        </li>
+        {{ range .Pages.Reverse }}
+            {{ if (or (lt .Date now) (eq ( .Site.Params.ShowFuture ) "TRUE") ) }}
+                <li>
+                    <a href="{{.Permalink}}">{{ .Title }}</a><span class="date"> - {{ .Date.Format "2006-01-02" }}</span>
+                </li>
+            {{ end}}
         {{ end }}
     </ol>
 

+ 42 - 14
layouts/_default/single.html

@@ -9,11 +9,17 @@
     </aside>
 
     <article>
-        {{ with .Date }}<h3>{{ .Format "January 2, 2006" }} -  {{ $.Param "author" }}</h3>{{ end }}
-
-        <h1>{{ .Title }}</h1>
-    
-        {{ .Content }}
+        {{ if or ( or ( not ( isset .Params "date" ) ) ( lt .Date now ) ) ( eq ( .Site.Params.ShowFuture ) "TRUE" ) }}
+            {{ with .Date }}<h3>{{ .Format "January 2, 2006" }} -  {{ $.Param "author" }}</h3>{{ end }}
+            <h1>{{ .Title }}</h1>
+            {{ .Content }}
+        {{ else }}
+            <h1>Soon to come, check back on {{ .Date.Format "January 2, 2006" }}!</h1>
+            <br/>
+            <h4>Want early access to content? <a href="{{ .Site.Params.PatreonLink }}">Come support us on Patreon!</a></h4>
+            <h4>Already a patron? <a href="https://prev.nightmares.technically.fun">Access early content here!</a> (Requires Logging in via Patreon)</h4>
+            <br/>
+        {{ end }}
 
         {{ $.Scratch.Set "pageTitle" .Title }}
         {{ $.Scratch.Set "site" .Site }}
@@ -38,24 +44,46 @@
                     {{ end }}
                 {{ end }}
             {{ end }}
+            {{ if eq ( ($.Scratch.Get "site").Params.ShowFuture ) "TRUE" }}
+                <!-- Direct link to latest article regardles of date -->
+                {{ range first 1 (where ($.Scratch.Get "site").RegularPages "Section" "catalogue") }}
+                    {{ $.Scratch.Set "latestTitle" .Title }}
 
-            {{ range first 1 (where ($.Scratch.Get "site").RegularPages "Section" "catalogue") }}
-                {{ $.Scratch.Set "latestTitle" .Title }}
+                    {{ with ($.Scratch.Get "next") }}
+                        {{ if ne .Title ($.Scratch.Get "latestTitle") }}
+                            <p>
+                                <a href="{{ .Permalink }}">Spin me another tale, keeper ></a>
+                            </p>
+                        {{ end }}
+                    {{ end }}
 
-                {{ with ($.Scratch.Get "next") }}
-                    {{ if ne .Title ($.Scratch.Get "latestTitle") }}
+                    {{ if ne .Title ($.Scratch.Get "pageTitle") }}
                         <p>
-                            <a href="{{ .Permalink }}">Spin me another tale, keeper ></a>
+                            <a href="{{ .Permalink }}">Give us something new >></a>
                         </p>
                     {{ end }}
                 {{ end }}
+            {{ else }}
+                <!-- Direct link to latest article not in the future -->
+                {{ range first 1 (where (where ($.Scratch.Get "site").RegularPages "Section" "catalogue") "Params.date" "lt" now) }}
+                    {{ $.Scratch.Set "latestTitle" .Title }}
 
-                {{ if ne .Title ($.Scratch.Get "pageTitle") }}
-                    <p>
-                        <a href="{{ .Permalink }}">Give us something new >></a>
-                    </p>
+                    {{ with ($.Scratch.Get "next") }}
+                        {{ if ne .Title ($.Scratch.Get "latestTitle") }}
+                            <p>
+                                <a href="{{ .Permalink }}">Spin me another tale, keeper ></a>
+                            </p>
+                        {{ end }}
+                    {{ end }}
+
+                    {{ if ne .Title ($.Scratch.Get "pageTitle") }}
+                        <p>
+                            <a href="{{ .Permalink }}">Give us something new >></a>
+                        </p>
+                    {{ end }}
                 {{ end }}
             {{ end }}
+            
         {{ end }}
         
         {{- partial "footer.html" . -}}

+ 7 - 1
layouts/index.html

@@ -15,8 +15,14 @@
         <a href="/catalogue/index.html">Catalogue</a>
     </p>
     <p class="shift-right">
+        {{ if (eq ( .Site.Params.ShowFuture ) "TRUE") }}
         {{ range first 1 (where .Site.RegularPages "Section" "catalogue") }}
-        <a href="{{ .Permalink }}">Latest</a>
+            <a href="{{ .Permalink }}">Latest</a>
+        {{ end }}
+        {{ else }}
+            {{ range first 1 (where (where .Site.RegularPages "Section" "catalogue") "Params.date" "lt" now) }}
+                <a href="{{ .Permalink }}">Latest</a>
+            {{ end }}
         {{ end }}
     </p>
 

+ 3 - 3
layouts/partials/header.html

@@ -4,7 +4,7 @@
         <span class="spacer">|</span>
         <a href="/catalogue">Catalogue</a>
         <span class="spacer">|</span>
-        <a href="#">Support me on Patreon</a>
+        <a href="{{ .Site.Params.PatreonLink }}">Support me on Patreon</a>
         <span class="spacer">|</span>
         <a href="/about">About</a>
     </nav>
@@ -16,7 +16,7 @@
         <span class="spacer">|</span>
         <a href="/catalogue">Catalogue</a>
         <span class="spacer">|</span>
-        <a href="#">Patreon</a>
+        <a href="{{ .Site.Params.PatreonLink }}">Patreon</a>
         <span class="spacer">|</span>
         <a href="/about">About</a>
     </nav>
@@ -33,7 +33,7 @@
                     <a href="/catalogue">Catalogue</a>
                 </p>
                 <p>
-                    <a href="#">Support me on Patreon</a>
+                    <a href="{{ .Site.Params.PatreonLink }}">Support me on Patreon</a>
                 </p>
                 <p>
                     <a href="/about">About</a>