mirror of
https://github.com/imfing/hextra.git
synced 2025-05-14 11:06:25 -04:00
feat: add rss template
feat: enhance sidebar on mobile chore: simplify settings by having defaults chore: update footer template
This commit is contained in:
parent
64e27cbc4e
commit
04a5c7378a
@ -2130,10 +2130,6 @@ video {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.mr-1 {
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
.mr-2 {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ title: "Hextra"
|
||||
|
||||
enableRobotsTXT: true
|
||||
enableGitInfo: true
|
||||
# enableEmoji: false
|
||||
# hasCJKLanguage: true
|
||||
|
||||
outputs:
|
||||
@ -88,22 +89,15 @@ params:
|
||||
# height: 20
|
||||
|
||||
footer:
|
||||
disabled: false
|
||||
displayCopyright: true
|
||||
displayPoweredBy: true
|
||||
|
||||
displayUpdatedDate: true
|
||||
dateFormat: "January 2, 2006"
|
||||
|
||||
toc:
|
||||
disabled: false
|
||||
|
||||
search:
|
||||
disabled: false
|
||||
|
||||
math:
|
||||
disabled: false
|
||||
enable: true
|
||||
|
||||
editURL:
|
||||
disabled: false
|
||||
enable: true
|
||||
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
|
||||
|
@ -347,7 +347,6 @@
|
||||
"min-w-full",
|
||||
"ml-1",
|
||||
"ml-4",
|
||||
"mr-1",
|
||||
"mr-2",
|
||||
"mt-1.5",
|
||||
"mt-12",
|
||||
|
@ -11,15 +11,16 @@
|
||||
<hr class="dark:border-neutral-800" />
|
||||
<div class="mx-auto flex max-w-screen-xl justify-center py-12 pl-[max(env(safe-area-inset-left),1.5rem)] pr-[max(env(safe-area-inset-right),1.5rem)] text-gray-600 dark:text-gray-400 md:justify-start">
|
||||
<div class="flex w-full flex-col items-center sm:items-start">
|
||||
{{- if .Site.Params.footer.displayPoweredBy }}<div class="font-semibold">{{ template "theme-credit" . }}</div>{{ end -}}
|
||||
{{- if .Site.Params.footer.displayCopyright }}<p class="mt-6 text-xs">{{ i18n "footer.copyright" }}</p>{{ end -}}
|
||||
{{- if (.Site.Params.footer.displayPoweredBy | default true) }}<div class="font-semibold">{{ template "theme-credit" . }}</div>{{ end }}
|
||||
{{- if .Site.Params.footer.displayCopyright }}<p class="mt-6 text-xs">{{ i18n "footer.copyright" }}</p>{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{{- define "theme-credit" -}}
|
||||
<a class="flex items-center gap-1 text-current" target="_blank" rel="noopener noreferrer" title="Hextra homepage" href="https://github.com/imfing/hextra">
|
||||
<span class="mr-1">Powered by Hextra</span>
|
||||
{{- partial "utils/icon.html" (dict "name" "hextra" "attributes" "height=1em") -}}
|
||||
<a class="flex text-sm items-center gap-1 text-current" target="_blank" rel="noopener noreferrer" title="Hextra GitHub Homepage" href="https://github.com/imfing/hextra">
|
||||
<span>Powered by Hextra
|
||||
{{- partial "utils/icon.html" (dict "name" "hextra" "attributes" "height=1em class=\"inline-block ml-1 align-text-bottom\"") -}}
|
||||
</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
@ -10,11 +10,13 @@
|
||||
|
||||
<nav class="mx-auto flex items-center justify-end gap-2 h-16 px-6 max-w-[90rem]">
|
||||
<a class="flex items-center hover:opacity-75 ltr:mr-auto rtl:ml-auto" href="{{ $logoLink }}">
|
||||
{{- if (.Site.Params.navbar.displayLogo | default true) }}
|
||||
<img class="block dark:hidden" src="{{ $logoPath | relURL }}" alt="{{ .Site.Title }}" height="{{ $logoWidth }}" width="{{ $logoHeight }}" />
|
||||
<img class="hidden dark:block" src="{{ $logoDarkPath | relURL }}" alt="{{ .Site.Title }}" height="{{ $logoWidth }}" width="{{ $logoHeight }}" />
|
||||
{{- if .Site.Params.navbar.displayTitle -}}
|
||||
{{- end }}
|
||||
{{- if (.Site.Params.navbar.displayTitle | default true) }}
|
||||
<span class="mx-2 font-extrabold inline select-none" title="{{ .Site.Title }}">{{- .Site.Title -}}</span>
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
</a>
|
||||
|
||||
{{- $currentPage := . -}}
|
||||
@ -25,7 +27,7 @@
|
||||
{{- $external := strings.HasPrefix .URL "http" -}}
|
||||
{{/* Display icon menu item */}}
|
||||
{{- if .Params.icon -}}
|
||||
<a class="p-2 text-current" {{ if $external }}target="_blank" rel="noreferer"{{ end }} href="{{ .URL | relLangURL }}">
|
||||
<a class="p-2 text-current" {{ if $external }}target="_blank" rel="noreferer"{{ end }} href="{{ .URL | relLangURL }}" title="{{ or (T .Identifier) .Name | safeHTML }}">
|
||||
{{- partial "utils/icon.html" (dict "name" .Params.icon "attributes" "height=24") -}}
|
||||
<span class="sr-only">{{ or (T .Identifier) .Name | safeHTML }}</span>
|
||||
</a>
|
||||
@ -33,6 +35,7 @@
|
||||
{{- $active := or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .) -}}
|
||||
{{- $activeClass := cond $active "font-medium" "text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200" -}}
|
||||
<a
|
||||
title="{{ or (T .Identifier) .Name | safeHTML }}"
|
||||
href="{{ .URL | relLangURL }}"
|
||||
{{ if $external }}target="_blank" rel="noreferer"{{ end }}
|
||||
class="text-sm contrast-more:text-gray-700 contrast-more:dark:text-gray-100 relative -ml-2 hidden whitespace-nowrap p-2 md:inline-block {{ $activeClass }}"
|
||||
|
@ -13,7 +13,7 @@
|
||||
<script defer src="{{ $scripts.RelPermalink }}" integrity="{{ $scripts.Data.Integrity }}"></script>
|
||||
|
||||
{{/* FlexSearch */}}
|
||||
{{- if not site.Params.search.disabled -}}
|
||||
{{- if (site.Params.search.enable | default true) -}}
|
||||
{{- $jsSearchScript := printf "%s.search.js" .Language.Lang -}}
|
||||
{{- $jsSearch := resources.Get "js/flexsearch.js" | resources.ExecuteAsTemplate $jsSearchScript . -}}
|
||||
{{- if hugo.IsProduction -}}
|
||||
@ -38,7 +38,7 @@
|
||||
{{- end -}}
|
||||
|
||||
{{/* KaTex */}}
|
||||
{{- if and (not site.Params.math.disabled) .Page.Params.math -}}
|
||||
{{- if .Page.Params.math -}}
|
||||
{{- $katexCSS := resources.Get "lib/katex/katex.min.css" | fingerprint -}}
|
||||
{{- $katexJS := resources.Get "lib/katex/katex.min.js" | fingerprint -}}
|
||||
{{- $mhchemJS := resources.Get "lib/katex/mhchem.min.js" | fingerprint -}}
|
||||
|
@ -15,20 +15,8 @@
|
||||
<div class="overflow-y-auto overflow-x-hidden p-4 grow md:h-[calc(100vh-var(--navbar-height)-var(--menu-height))]">
|
||||
<ul class="flex flex-col gap-1 md:hidden">
|
||||
<!-- Nav -->
|
||||
{{- range site.Menus.main }}
|
||||
{{- if and .URL (and (ne .Params.type "search") (not .Params.icon)) -}}
|
||||
<li>{{ template "sidebar-item-link" dict "active" false "title" .Name "link" .URL }}</li>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ template "sidebar-separator" -}}
|
||||
{{ template "sidebar-main" (dict "context" $navRoot "pageURL" $pageURL "page" $context "toc" true) -}}
|
||||
|
||||
|
||||
<!-- Sidebar footer -->
|
||||
{{ with site.Params.sidebar.footer -}}
|
||||
{{ template "sidebar-separator" }}
|
||||
{{ template "sidebar-main" (dict "context" site.Home "pageURL" $pageURL "page" $context "toc" true) -}}
|
||||
{{ template "sidebar-footer" }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
<!-- Sidebar on large screen -->
|
||||
|
@ -1,7 +1,6 @@
|
||||
{{/* Table of Contents */}}
|
||||
{{/* TODO: toc bottom part should be able to hide */}}
|
||||
{{- $toc := .Params.toc | default true -}}
|
||||
{{- with site.Params.toc.disabled -}}{{ $toc = not . }}{{- end -}}
|
||||
|
||||
|
||||
<nav class="hextra-toc order-last hidden w-64 shrink-0 xl:block print:hidden px-4" aria-label="table of contents">
|
||||
@ -23,7 +22,7 @@
|
||||
|
||||
{{/* TOC bottom part */}}
|
||||
<div class="{{ $borderClass }} sticky bottom-0 flex flex-col items-start gap-2 pb-8 dark:border-neutral-800 contrast-more:border-t contrast-more:border-neutral-400 contrast-more:shadow-none contrast-more:dark:border-neutral-400">
|
||||
{{- if not site.Params.editURL.disabled -}}
|
||||
{{- if site.Params.editURL.enable -}}
|
||||
{{- $editURL := site.Params.editURL.base | default "" -}}
|
||||
{{- with .File -}}{{ $editURL = urls.JoinPath $editURL .Path }}{{- end -}}
|
||||
{{- with .Params.editURL -}}{{ $editURL = .Params.editURL }}{{- end -}}
|
||||
|
40
layouts/section/section.rss.xml
Normal file
40
layouts/section/section.rss.xml
Normal file
@ -0,0 +1,40 @@
|
||||
{{- $pctx := . -}}
|
||||
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
|
||||
{{- $pages := slice -}}
|
||||
{{- if or $.IsHome $.IsSection -}}
|
||||
{{- $pages = $pctx.RegularPages -}}
|
||||
{{- else -}}
|
||||
{{- $pages = $pctx.Pages -}}
|
||||
{{- end -}}
|
||||
{{- $limit := .Site.Config.Services.RSS.Limit -}}
|
||||
{{- if ge $limit 1 -}}
|
||||
{{- $pages = $pages | first $limit -}}
|
||||
{{- end -}}
|
||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} of {{ end }}{{ .Site.Title }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
|
||||
<generator>Hugo -- gohugo.io</generator>
|
||||
<language>{{ site.Language.LanguageCode }}</language>{{ with .Site.Author.email }}
|
||||
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
|
||||
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
|
||||
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
|
||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||
{{- with .OutputFormats.Get "RSS" -}}
|
||||
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
|
||||
{{- end -}}
|
||||
{{ range $pages }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description>
|
||||
<content:encoded>{{ (printf "<![CDATA[%s]]>" .Content) | safeHTML }}</content:encoded>
|
||||
</item>
|
||||
{{ end }}
|
||||
</channel>
|
||||
</rss>
|
Loading…
x
Reference in New Issue
Block a user