Create custom index page and add social.lol link

Links now have rel="noopener noreferrer me", a title set to the link text and open in a new tab
This commit is contained in:
Aadi Desai 2023-05-10 12:14:33 +01:00
parent 8c8d9b2f71
commit 8771efa29e
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
2 changed files with 57 additions and 0 deletions

View file

@ -30,6 +30,8 @@ params: # Customise Guide: https://github.com/Yukuro/hugo-theme-shell/blob/maste
- "https://8bit.omg.lol/" - "https://8bit.omg.lol/"
- - My /now Page - - My /now Page
- "https://8bit.omg.lol/now/" - "https://8bit.omg.lol/now/"
- - Mastodon (social.lol)
- "https://social.lol/@8bit/"
- - LinkedIn - - LinkedIn
- "https://www.linkedin.com/in/aadidesai/" - "https://www.linkedin.com/in/aadidesai/"
- - Peerlist - - Peerlist

55
layouts/index.html Normal file
View file

@ -0,0 +1,55 @@
{{ define "main" }}
{{ $env := printf "<strong><span id='user'>%s@%s</span><span id='terminal'>:</span><span id='dir'>~/%s</span></strong><span id='terminal'>$</span>" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName "" | safeHTML }}
{{ $envWithDir := printf "<strong><span id='user'>%s@%s</span><span id='terminal'>:</span><span id='dir'>~/%s</span></strong><span id='terminal'>$</span>" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName .Site.Params.Terminal.workDir | safeHTML }}
{{ $cd := printf "<span id='terminal'>cd %s</span>" .Site.Params.Terminal.workDir | safeHTML }}
{{ $cat := printf "<span id=terminal>cat %s</span>" .Site.Params.Terminal.profile | safeHTML }}
{{ $description := "" }}
{{ if eq (substr .Site.Params.Terminal.description -3 3) ".md" }}
{{ $s := "" }}
{{ with .Site.GetPage .Site.Params.Terminal.description }}
<!-- replace the first p tag with a br tag -->
{{ $s = replaceRE "</?p[^>]*>" "" .Content 1 }}
{{ end }}
{{ $description = printf "<span id='terminal'>%s</span>" $s | safeHTML}}
{{ else }}
{{ $limit := sub (len (findRE "\n" .Site.Params.Terminal.description)) 1 }}
{{ $description = printf "<span id='terminal'>%s</span>" .Site.Params.Terminal.description }}
{{ $description = replaceRE "\n" "<br>" $description $limit| safeHTML }}
{{ end }}
{{ $tree := "" }}
{{ $leaf := "" }}
{{ if .Site.Params.Tree.use }}
{{ $tree = printf "<span id='terminal'>tree ./%s/</span>" .Site.Params.Tree.folderName | safeHTML}}
{{ $leaf = printf "%s<strong><span id='dir'>./%s/</span></strong><br>" $leaf .Site.Params.Tree.folderName | safeHTML}}
{{ range $index, $val := .Site.Params.Tree.files }}
{{ $ac := index $val 0}}
{{ $link := index $val 1}}
<!-- pass link (i.e. http, https) and mailto -->
{{ $l := $.Site.GetPage $link }}
{{ if $l }}
{{ $link = $l.Permalink}}
{{ end }}
{{ if eq (add $index 1) (len $.Site.Params.Tree.files) }}
{{ $leaf = printf "<span id='terminal'>%s└── <a href='%s' target='_blank' rel='noopener noreferrer me' title='%s'>%s</a></span>" $leaf $link $ac $ac | safeHTML}}
{{ else }}
{{ $leaf = printf "<span id='terminal'>%s├── <a href='%s' target='_blank' rel='noopener noreferrer me' title='%s'>%s</a></span><br>" $leaf $link $ac $ac | safeHTML}}
{{ end }}
{{ end }}
{{ end }}
{{ $end := $env }}
{{ $payload := delimit (slice $cd $cat $description $tree $leaf $end) "" }}
{{ $ps1Delay := $.Site.Params.Terminal.ps1Delay }}
{{ $stdoutDelay := $.Site.Params.Terminal.stdoutDelay }}
{{ $commandDelay := $.Site.Params.Terminal.commandDelay }}
{{ partial "partials/typeIndex.html" (dict "context" . "env" $env "cd" $cd "envWithDir" $envWithDir "cat" $cat "description" $description "tree" $tree "leaf" $leaf "ps1delay" $ps1Delay "stdoutdelay" $stdoutDelay "commanddelay" $commandDelay ) }}
{{ end }}