First batch of day one
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
|
||||
<style>
|
||||
#R-body img.bg-white {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
<span class="github-buttons"></span>
|
||||
<p>Built with <a href="https://github.com/McShelby/hugo-theme-relearn" title="love"><i class="fas fa-heart"></i></a> by <a href="https://gohugo.io/">Hugo</a></p>
|
||||
<script>
|
||||
function githubButtonsScheme(){
|
||||
var scheme = 'light';
|
||||
var colorPropertyValue = window.getComputedStyle( document.querySelector( '#R-sidebar' ) ).getPropertyValue( 'background-color' );
|
||||
var colorValues = colorPropertyValue.match( /\d+/g ).map( function( e ){ return parseInt(e,10); });
|
||||
if( colorValues.length === 3 && ((0.2126 * colorValues[0]) + (0.7152 * colorValues[1]) + (0.0722 * colorValues[2]) < 165) ){
|
||||
// Luma, https://en.wikipedia.org/wiki/Luma_%28video%29, SMPTE C, Rec. 709 weightings
|
||||
scheme = 'dark';
|
||||
}
|
||||
return scheme;
|
||||
}
|
||||
function githubButtonsInit(){
|
||||
if( !window.githubButtons ){
|
||||
// wait for the script to load
|
||||
setTimeout( githubButtonsInit, 50 );
|
||||
return;
|
||||
}
|
||||
var scheme = githubButtonsScheme();
|
||||
var githubButtonsHTML = `
|
||||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn/archive/main.zip" data-color-scheme="${scheme}" data-icon="octicon-cloud-download" aria-label="Download McShelby/hugo-theme-relearn on GitHub">Download</a>
|
||||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn" data-color-scheme="${scheme}" data-icon="octicon-star" data-show-count="true" aria-label="Star McShelby/hugo-theme-relearn on GitHub">Star</a>
|
||||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn/fork" data-color-scheme="${scheme}" data-icon="octicon-repo-forked" data-show-count="true" aria-label="Fork McShelby/hugo-theme-relearn on GitHub">Fork</a>
|
||||
`;
|
||||
document.querySelector( '.github-buttons' ).innerHTML = githubButtonsHTML;
|
||||
document.querySelectorAll( '.github-button' ).forEach( function( anchor ){
|
||||
anchor.dataset.colorScheme = scheme;
|
||||
window.githubButtons.render( anchor, function( el ){
|
||||
anchor.parentNode.replaceChild( el, anchor );
|
||||
});
|
||||
});
|
||||
}
|
||||
document.addEventListener( 'themeVariantLoaded', function( e ){
|
||||
// we have to wait until the CSS class .default-animation has settled and and the buttons have loaded to recalculate the scheme again
|
||||
setTimeout( githubButtonsInit, 400 );
|
||||
});
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
setTimeout( githubButtonsInit, 400 );
|
||||
});
|
||||
</script>
|
||||
<script async src="{{"js/github-buttons.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
|
||||
@@ -0,0 +1 @@
|
||||
{{ if (eq .Params.archetype "chapter") }}<b style="display: inline-block; font-weight: 200; padding-left: .3rem; text-align: left; width: 1.1rem;">{{ .Params.weight }}.</b> {{ end }}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
{{- /*
|
||||
Heavily modified from https://github.com/gohugoio/hugoDocs/blob/master/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/code-toggle.html
|
||||
|
||||
Renders syntax-highlighted configuration data in TOML, YAML and JSON formats.
|
||||
|
||||
@param {Page} [page] The page to render on.
|
||||
@param {string} [content] Plain content to render.
|
||||
@param {string} [config] The section of site.Data.docs.config to render.
|
||||
@param {string} [dataKey] Only render specific section
|
||||
@param {string} [file] The file name to display above the rendered code.
|
||||
@param {bool} [fm=false] If true, render the code as front matter.
|
||||
@param {bool} [skipHeader=false] If false, omit top level key(s) when rendering a section of site.Data.docs.config.
|
||||
|
||||
@returns {template.HTML}
|
||||
*/}}
|
||||
|
||||
{{- /* Get parameters. */}}
|
||||
{{- $page := .page }}
|
||||
{{- $content := .content }}
|
||||
{{- $config := .config }}
|
||||
{{- $dataKey := .dataKey }}
|
||||
{{- $file := .file }}
|
||||
{{- $fm := false }}
|
||||
{{- if in (slice "false" false 0) .fm }}
|
||||
{{- $fm = false }}
|
||||
{{- else if in (slice "true" true 1) .fm }}
|
||||
{{- $fm = true }}
|
||||
{{- end }}
|
||||
{{- $skipHeader := false }}
|
||||
{{- if in (slice "false" false 0) .skipHeader }}
|
||||
{{- $skipHeader = false }}
|
||||
{{- else if in (slice "true" true 1) .skipHeader }}
|
||||
{{- $skipHeader = true }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Define constants. */}}
|
||||
{{- $delimiters := dict "toml" "+++" "yaml" "---" }}
|
||||
{{- $langs := slice "toml" "yaml" "json" }}
|
||||
|
||||
{{- /* Render. */}}
|
||||
{{- $code := "" }}
|
||||
{{- if $config }}
|
||||
{{- $file = $file | default "hugo" }}
|
||||
{{- $sections := (split $config ".") }}
|
||||
{{- $configSection := index $page.Site.Data.docs.config $sections }}
|
||||
{{- $code = dict $sections $configSection }}
|
||||
{{- if $skipHeader }}
|
||||
{{- $code = $configSection }}
|
||||
{{- end }}
|
||||
{{- else if $dataKey }}
|
||||
{{- $file = $file | default $dataKey }}
|
||||
{{- $sections := (split $dataKey ".") }}
|
||||
{{- $code = index $page.Site.Data.docs $sections }}
|
||||
{{- else }}
|
||||
{{- $code = $content }}
|
||||
{{- end }}
|
||||
{{- $params := dict "page" $page "groupid" "config-code" }}
|
||||
{{- with $file }}
|
||||
{{- $params = $params | merge (dict "title" (printf "%s%s" . (cond $fm "" "."))) }}
|
||||
{{- end }}
|
||||
{{- $contentparam := slice }}
|
||||
{{- range $langs }}
|
||||
{{- /* Remove toml comments. */}}
|
||||
{{- $hCode := $code | replaceRE `#.*(\r\n|\r|\n)?` "" }}
|
||||
{{- $hCode = $hCode | transform.Remarshal . }}
|
||||
{{- if and $fm (in (slice "toml" "yaml") .) }}
|
||||
{{- $placeHolder := (index $delimiters .) }}
|
||||
{{- $hCode = printf "%s\n%s%s\n" $placeHolder $hCode $placeHolder }}
|
||||
{{- end }}
|
||||
{{- $contentparam = $contentparam | append (dict "title" . "content" (printf "````%s\n%s````" . $hCode | $page.RenderString)) }}
|
||||
{{- end }}
|
||||
{{- $params = $params | merge (dict "content" $contentparam) }}
|
||||
{{- partial "shortcodes/tabs.html" $params }}
|
||||
@@ -0,0 +1,152 @@
|
||||
{{- $page := .page }}
|
||||
{{- if and (not $page) .context }}
|
||||
{{- $page = .context }}
|
||||
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'piratify' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }}
|
||||
{{- end }}
|
||||
{{- $content := .content }}
|
||||
{{- $pagefield := cond (ne $content nil) nil (.pagefield | default "Content") }}
|
||||
{{- $writenotice := cond (ne .writenotice nil) .writenotice false }}
|
||||
{{- $langtrg := "pir" }}
|
||||
{{- $langsrc := cond (eq $page.Language.Lang $langtrg) (.langsrc | default "en") $page.Language.Lang }}
|
||||
{{- $baseURL := urls.Parse site.BaseURL }}
|
||||
{{- $baseURLpath := $baseURL.Path | default "/" }}
|
||||
{{- $l := $page.RelPermalink }}
|
||||
{{- $c := "" }}
|
||||
{{- $srcPage := "" }}
|
||||
{{- if ne $content nil }}
|
||||
{{- $c = $content }}
|
||||
{{- else if eq $pagefield "Content" }}
|
||||
{{- $c = $page.Content }}
|
||||
{{- else if eq $pagefield "TableOfContents" }}
|
||||
{{- $c = $page.TableOfContents }}
|
||||
{{- end }}
|
||||
{{- range $page.AllTranslations }}
|
||||
{{- if eq .Language.Lang $langsrc }}
|
||||
{{- $l = .RelPermalink }}
|
||||
{{- if ne $content nil }}
|
||||
{{- $c = $content }}
|
||||
{{- else if eq $pagefield "Content" }}
|
||||
{{- $c = .Content }}
|
||||
{{- $srcPage = . }}
|
||||
{{- else if eq $pagefield "TableOfContents" }}
|
||||
{{- $c = .TableOfContents }}
|
||||
{{- end }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq $page.Language.Lang $langtrg }}
|
||||
{{- if $writenotice }}
|
||||
{{- partial "shortcodes/notice.html" (dict
|
||||
"page" $page
|
||||
"content" "<p>Fello' pirrrates, grog made us dizzy! Be awarrre <b>some stuff may look weird</b> in this trrranslat'n. Like <b>Merrrmaids</b>, do'n <b>math or chemistrrry</b> and stuff.</p>\n"
|
||||
"icon" "skull-crossbones"
|
||||
"style" "warning"
|
||||
"title" "Arrr! Pirrrates"
|
||||
) }}
|
||||
{{- end }}
|
||||
{{- $words := dict
|
||||
"Hugo" "Cap'n Hugo"
|
||||
"Info" "Ahoi"
|
||||
"Note" "Avast"
|
||||
"Tip" "Smarrrt Arrrse"
|
||||
"Warning" "Arrr"
|
||||
"good" "bloody"
|
||||
"shortcodes" "shorrrtcodes"
|
||||
"Shortcodes" "Shorrrtcodes"
|
||||
"Mermaid" "Merrrmaid"
|
||||
"Markdown" "Marrrkdown"
|
||||
"Markup" "Marrrkup"
|
||||
"markup" "marrrkup"
|
||||
"for" "fer"
|
||||
"Your" "Yer"
|
||||
"your" "yer"
|
||||
"You" "Ye"
|
||||
"you" "ye"
|
||||
"the" "th'"
|
||||
"The" "Th'"
|
||||
"is" "be"
|
||||
"Is" "Be"
|
||||
"are" "be"
|
||||
"Are" "Be"
|
||||
"Of" "O'"
|
||||
"of" "o'"
|
||||
"To" "T'"
|
||||
"to" "t'"
|
||||
"in" "'n"
|
||||
"With" "Wit'"
|
||||
"with" "wit'"
|
||||
"Where" "Whar'"
|
||||
"where" "whar'"
|
||||
"After" "Aft"
|
||||
"And" "An'"
|
||||
"and" "an'"
|
||||
"Load" "Board"
|
||||
"load" "board"
|
||||
"Loaded" "Boarded"
|
||||
"loaded" "boarded"
|
||||
"Content" "Rrrambling"
|
||||
"content" "rrrambling"
|
||||
"icon" "ay'con"
|
||||
"Icon" "Ay'con"
|
||||
"icons" "ay'cons"
|
||||
"Icons" "Ay'cons"
|
||||
"syntax" "rules"
|
||||
"Syntax" "Rules"
|
||||
"Site" "Ship"
|
||||
"site" "ship"
|
||||
"Page" "Plank"
|
||||
"page" "plank"
|
||||
"Pages" "Planks"
|
||||
"pages" "planks"
|
||||
"Relearn" "Relearrrn"
|
||||
"Learn" "Learrrn"
|
||||
-}}
|
||||
{{- $specials := dict
|
||||
"(\\w)ing([\\s\\n<.,;?!:])" "'n"
|
||||
"(\\w)ings([\\s\\n<.,;?!:])" "'ns"
|
||||
"(\\w)tion([\\s\\n<.,;?!:])" "t'n"
|
||||
"(\\w)tions([\\s\\n<.,;?!:])" "t'ns"
|
||||
"(\\w)(?:[aeiou])ble([\\s\\n<.,;?!:])" "'ble"
|
||||
"(\\w)(?:[aeiou])mize([\\s\\n<.,;?!:])" "'mize"
|
||||
"(\\w)(?:[aeiou])mizes([\\s\\n<.,;?!:])" "'mizes"
|
||||
"(\\w)(?:[aeiou])nize([\\s\\n<.,;?!:])" "'nize"
|
||||
"(\\w)(?:[aeiou])nizes([\\s\\n<.,;?!:])" "'nizes"
|
||||
-}}
|
||||
{{- $links := slice
|
||||
"href"
|
||||
-}}
|
||||
{{- $fix := dict
|
||||
"warn'n" "warning"
|
||||
"sect'n" "section"
|
||||
"n Cap'n" "n"
|
||||
"Avast right o' John" "Note right of John"
|
||||
-}}
|
||||
{{- range $from, $to := $words }}
|
||||
{{- $c = replaceRE (printf "([\\s\\n>])%s([\\s\\n<.,;?!:])" $from) (printf "${1}%s${2}" $to) $c }}
|
||||
{{- end }}
|
||||
{{- range $from, $to := $specials }}
|
||||
{{- $c = replaceRE $from (printf "${1}%s${2}" $to) $c }}
|
||||
{{- end }}
|
||||
{{- range $attr := $links }}
|
||||
{{- $c = replaceRE (printf "\\b(%s)(=\"%s[^\"]*?\")" $attr $baseURLpath) "${1} data-piratify${2}" $c }}
|
||||
{{- $m := findRESubmatch (printf "%s data-piratify=\"(%s)([^\"]*?)\"" $attr $baseURLpath) $c }}
|
||||
{{- range $m }}
|
||||
{{- $r := printf "%s=\"%s\"" $attr (index . 2) }}
|
||||
{{- $u := urls.Parse (index . 2) }}
|
||||
{{- if and (not $u.IsAbs) $u.Path }}
|
||||
{{- $r = printf "%s=\"%s%s/%s\"" $attr $baseURLpath $langtrg (index . 2) }}
|
||||
{{- end }}
|
||||
{{- $c = replace $c (index . 0) $r }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $from, $to := $fix }}
|
||||
{{- $c = replace $c $from $to }}
|
||||
{{- end }}
|
||||
{{- if $srcPage }}
|
||||
{{- range $page.Site.Params.relearn.dependencies }}
|
||||
{{- $has := printf "has%s" .name }}
|
||||
{{- $page.Store.Set $has (or ($page.Store.Get $has) ($srcPage.Store.Get $has)) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ $c | safeHTML }}
|
||||
@@ -0,0 +1,4 @@
|
||||
{{- partial "shortcodes/piratify.html" (dict
|
||||
"page" .
|
||||
"pagefield" "TableOfContents"
|
||||
) }}
|
||||
@@ -0,0 +1,10 @@
|
||||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/multiconfig.html" (dict
|
||||
"page" .Page
|
||||
"content" .Inner
|
||||
"config" (.Get "config")
|
||||
"dataKey" (.Get "dataKey")
|
||||
"file" (.Get "file")
|
||||
"fm" (.Get "fm")
|
||||
"skipHeader" (.Get "skipHeader")
|
||||
) }}
|
||||
@@ -0,0 +1,5 @@
|
||||
{{- partial "shortcodes/piratify.html" (dict
|
||||
"page" .Page
|
||||
"pagefield" "Content"
|
||||
"writenotice" (.Get "writenotice" | default (.Get 0))
|
||||
) }}
|
||||
Reference in New Issue
Block a user