Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 564 additions and 0 deletions
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
<article class="bb b--black-10">
<div class="db pv4 ph3 ph0-l no-underline dark-gray">
<div class="flex flex-column flex-row-ns">
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
{{ $featured_image := (trim $featured_image "/") | absURL }}
<div class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }} mb4 mb0-ns w-100 w-40-ns">
<a href="{{.RelPermalink}}" class="db grow">
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
</a>
</div>
{{ end }}
<div class="blah w-100{{ if $featured_image }} w-60-ns {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr3-ns" "pl3-ns" }}{{ end }}">
<h1 class="f3 fw1 athelas mt0 lh-title">
<a href="{{.RelPermalink}}" class="color-inherit dim link">
{{ .Title }}
</a>
</h1>
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
{{/* TODO: add author
<p class="f6 lh-copy mv0">By {{ .Author }}</p> */}}
</div>
</div>
</div>
</article>
<div class="relative w-100 mb4 bg-white nested-copy-line-height">
<div class="bg-white mb3 pa4 gray overflow-hidden">
{{with .CurrentSection.Title }}<span class="f6 db">{{ . }}</span>{{end}}
<h1 class="f3 near-black">
<a href="{{ .RelPermalink }}" class="link black dim">
{{ .Title }}
</a>
</h1>
<div class="nested-links f5 lh-copy nested-copy-line-height">
{{ .Summary }}
</div>
</div>
</div>
{{ define "main" }}
<article class="cf pa3 pa4-m pa4-l">
<div class="measure-wide-l center f4 lh-copy nested-copy-line-height nested-links {{ $.Param "text_color" | default "mid-gray" }}">
<p>{{ i18n "taxonomyPageList" . }}</p>
</div>
</article>
<div class="mw8 center">
<section class="flex-ns flex-wrap justify-around mt5">
{{ range .Pages }}
<div class="relative w-100 mb4 bg-white">
{{ .Render "summary" }}
</div>
{{ end }}
</section>
</div>
{{ end }}
{{ define "main" }}
{{ $data := .Data }}
<article class="cf pa3 pa4-m pa4-l">
<div class="measure-wide-l center f4 lh-copy nested-copy-line-height nested-links {{ $.Param "text_color" | default "mid-gray" }}">
{{ .Content }}
</div>
</article>
<div class="mw8 center">
<section class="ph4">
{{ range $key, $value := .Data.Terms }}
<h2 class="f1">
<a href="{{ "/" | relLangURL }}{{ $.Data.Plural | urlize }}/{{ $key | urlize }}" class="link blue hover-black">
{{ $.Data.Singular | humanize }}: {{ $key }}
</a>
</h2>
{{ range $value.Pages }}
{{ .Render "summary" }}
{{ end }}
{{ end }}
</section>
</div>
{{ end }}
{{ define "main" }}
<article class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | default "mid-gray" }}">
{{ .Content }}
</article>
{{/* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. */}}
{{ $mainSections := .Site.Params.mainSections | default (slice "post") }}
{{/* Create a variable with that section to use in multiple places. */}}
{{ $section := where .Site.RegularPages "Section" "in" $mainSections }}
{{/* Check to see if the section is defined for ranging through it */}}
{{ $section_count := len $section }}
{{ if ge $section_count 1 }}
{{/* Derive the section name */}}
{{ $section_name := index (.Site.Params.mainSections) 0 }}
<div class="pa3 pa4-ns w-100 w-70-ns center">
{{/* Use $section_name to get the section title. Use "with" to only show it if it exists */}}
{{ with .Site.GetPage "section" $section_name }}
<h1 class="flex-none">
{{ $.Param "recent_copy" | default (i18n "recentTitle" .) }}
</h1>
{{ end }}
{{ $n_posts := $.Param "recent_posts_number" | default 3 }}
<section class="w-100 mw8">
{{/* Range through the first $n_posts items of the section */}}
{{ range (first $n_posts $section) }}
<div class="relative w-100 mb4">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
</section>
{{ if ge $section_count (add $n_posts 1) }}
<section class="w-100">
<h1 class="f3">{{ i18n "more" }}</h1>
{{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}}
{{ range (first 4 (after $n_posts $section)) }}
<h2 class="f5 fw4 mb4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "ml3" "mr3" }}">
<a href="{{ .RelPermalink }}" class="link black dim">
{{ .Title }}
</a>
</h2>
{{ end }}
{{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}}
{{ with .Site.GetPage "section" $section_name }}
<a href="{{ .RelPermalink }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">{{ i18n "allTitle" . }}</a>
{{ end }}
</section>
{{ end }}
</div>
{{ end }}
{{ end }}
{{ define "header" }}{{ partial "page-header.html" . }}{{ end }}
{{ define "main" }}
<div class="flex-l mt2 mw8 center">
<article class="center cf pv5 ph3 ph4-ns mw7">
<header>
<h1 class="f1">
{{ .Title }}
</h1>
</header>
<div class="nested-copy-line-height lh-copy f4 nested-links {{ $.Param "text_color" | default "mid-gray" }}">
{{ .Content }}
</div>
</article>
</div>
{{ end }}
<div id="commento"></div>
<script defer src="https://cdn.commento.io/js/commento.js"></script>
{{/*
GetFeaturedImage
This partial gets the url for featured image for a given page.
If a featured_image was set in the page's front matter, then that will be used.
If not set, this will search page resources to find an image that contains the word
"cover", and if found, returns the path to that resource.
If no featured_image was set, and there's no "cover" image in page resources, then
this partial returns an empty string (which evaluates to false).
@return RelPermalink to featured image, or an empty string if not found.
*/}}
{{/* Declare a new string variable, $linkToCover */}}
{{ $linkToCover := "" }}
{{ $matches := "feature,cover" }}
{{/* Use the value from front matter if present */}}
{{ with .Params.featured_image }}
{{ $linkToCover = . }}
{{/* If we find a Page Resource matching the exact value, we use it instead. */}}
{{ with $.Resources.GetMatch . }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
{{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }}
{{ with .Resources.ByType "image" }}
{{ with .GetMatch (printf "**{%s}*" $matches) }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
{{/* return either a permalink, or an empty string. Note that partials can only have a single
return statement, so this needs to be at the end of the partial (and not in the if block) */}}
{{ return $linkToCover }}
{{ $dir := "" }}
{{ if ge hugo.Version "0.67.1" }}
{{ with site.Language.LanguageDirection }}
{{ $dir = . }}
{{ end }}
{{ end }}
{{ return $dir }}
{{/*
socials/Get
Returns the list of services registered by the user complemented by the built-in service default data if found.
@author @regisphilibert
@context Any (.)
@access public
@returns Slice of Maps
- String (.name)
String (.url)
String (.label)
String (.color)?
Bool (.share)?
@uses
- partial
@example - Go Template
{{ with partialCached "socials/Get" context context }}
{{ something = . }}
{{ end }}
*/}}
{{ $socials := slice }}
{{ with partial "func/socials/GetRegisteredServices" "GetRegisteredServices" }}
{{ range . }}
{{ $service := . }}
{{/* We fetch the default data and add it to service map if found */}}
{{ with partialCached "func/socials/GetServiceData" .name .name }}
{{ $service = merge . $service }}
{{ end }}
{{/* We fetch the icon and add it to service map fi found */}}
{{ with partialCached "func/socials/GetServiceIcon" .name .name }}
{{ $service = $service | merge (dict "icon" . ) }}
{{ end }}
{{/* In case no label is provided (on a non-built-in service) we add the .name as label to the service map */}}
{{ with .label }}{{ else }}
{{ $service = $service | merge (dict "label" $service.name ) }}
{{ end }}
{{ $socials = $socials | append $service }}
{{ end }}
{{ end }}
{{ return $socials }}
\ No newline at end of file
{{/*
GetBuiltInServicesData
Returns a map whose keys stores the map of defaults data for any built-in service.
We use a key to easily grab the data with `index $that github`
@author @regisphilibert
@context Any (.)
@access public
@returns Map
## Contributors can add a built-in service
1. Adding it to the following map with the following format:
```yaml
# [...]
shinyandnew:
label: Shiny And New
color: '#cccccc'
```
2. Edit README file with new service https://github.com/theNewDynamic/gohugo-theme-ananke/tree/422-improve-socials#built-in-services
*/}}
{{ return (`
facebook:
share: true
label: Facebook
color: '#3b5998'
twitter:
share: true
label: Twitter
color: '#1da1f2'
instagram:
label: Instagram
color: '#e1306c'
youtube:
label: YouTube
color: '#cd201f'
github:
label: GitHub
color: '#6cc644'
gitlab:
label: GitLab
color: '#FC6D26'
keybase:
label: Keybase
color: '#3d76ff'
linkedin:
share: true
label: LinkedIn
color: '#0077b5'
medium:
label: Medium
color: '#0077b5'
mastodon:
label: Mastodon
color: '#3088d4'
slack:
label: Slack
color: '#E01E5A'
stackoverflow:
label: Stack Overflow
color: '#f48024'
rss:
label: RSS
color: '#ff6f1a'
tiktok:
label: TikTok
color: '#fe2c55'
` | transform.Unmarshal) }}
\ No newline at end of file
{{/*
socials/GetRegisteredServices
Retrieves the list of user registered services.
Support legacy settings (root of params with service name as key)
@author @regisphilibert
@context Any (.)
@access private
@returns Slice of Maps
- String (.name)
String (.url)
String (.label)?
String (.color)?
*/}}
{{ $registered_services := slice }}
{{/* We first look for legacy settings that lives at the root of the site.Params as such (github: https://github.com/
theNewDynamic) and them to the list with key as .name and value as .url */}}
{{ $user_using_legacy := false }}
{{ $legacy_api_services := slice "facebook" "twitter" "instagram" "youtube" "github" "gitlab" "keybase" "linkedin" "medium" "mastodon" "slack" "stackoverflow" "rss" }}
{{ range $name := $legacy_api_services }}
{{ with $url := index site.Params . }}
{{/* If we can find a parameter matching the key with a set value, we add it with proper name and url */}}
{{/* We also note that user is using legacy for potential potential deprecation warnings */}}
{{ $user_using_legacy = true }}
{{ $registered_services = $registered_services | append (dict "name" $name "url" $url) }}
{{ end }}
{{ end }}
{{/* Then we go through the current way of registering services as per referenced in README */}}
{{ with site.Params.ananke_socials }}
{{ range $service := . }}
{{/* Only if the service has a .name, we add it all its keys to the slice of registered services */}}
{{ with .name }}
{{ $registered_services = $registered_services | append $service }}
{{ end }}
{{ end }}
{{ end }}
{{ return $registered_services }}
\ No newline at end of file
{{/*
socials/GetServiceDefaults
Returns the defaults of any given service as stored in GetBuildInServicesDefaults
@author @regisphilibert
@context String (.)
@access private
@returns Map
- String (.label)
String (.color)
@uses
- func/socials/GetBuiltInServicesDefaults
*/}}
{{ $service_data := dict }}
{{ with partialCached "func/socials/GetBuiltInServicesDefaults" "socials/GetBuiltInServicesDefaults" }}
{{/* If the passed context string (held in $) is found as a key of the map returned by the above returning partial
We store it in the returning variable */}}
{{ with index . $ }}
{{ $service_data = . }}
{{ end }}
{{ end }}
{{ return $service_data }}
\ No newline at end of file
{{/*
GetServiceIcon
User can overwrite/complement in assets/ananke/socials/{service_name}.svg
@author @regisphilibert
@context String (.)
@access private
@return String of safe HTML
@example - Go Template
{{ $icon := partialCached "tnd-socials/private/GetIcon" $icon $icon }}
*/}}
{{ $icon := "" }}
{{ with resources.Get (printf "ananke/socials/%s.svg" $) }}
{{ $icon = .Content | safeHTML }}
{{ end }}
{{ return $icon }}
\ No newline at end of file
{{/*
style/GetMainCSS
Process the main css stylesheet and return as resource
@author @regisphilibert
@context Any (.)
@returns Resource
@uses
- func/style/GetResource
*/}}
{{ $main_style := dict }}
{{/* We prepare a slice of resources to be concatenated as one */}}
{{ $assets_to_concat := slice }}
{{/* We add locale css files to the slice in the proper order */}}
{{ range slice "_tachyons.css" "_code.css" "_hugo-internal-templates.css" "_social-icons.css" "_styles.css" }}
{{ with partialCached "func/style/GetResource" . . }}
{{ $assets_to_concat = $assets_to_concat | append . }}
{{ end }}
{{ end }}
{{ with partialCached "func/socials/Get" "socials/Get" }}
{{ $socials_rules := slice }}
{{ range $service := . }}
{{ with .color }}
{{ $rule := printf `
.ananke-socials a.%s:hover {
color: %s
}` $service.name $service.color }}
{{ $socials_rules = $socials_rules | append $rule }}
{{ end }}
{{ end }}
{{ with $socials_rules }}
{{ $socials_rules = delimit . "" }}
{{ $socials_css := $socials_rules | resources.FromString "ananke/css/generated_socials.css" }}
{{ $assets_to_concat = $assets_to_concat | append $socials_css }}
{{ end }}
{{ end }}
{{/* We look for any custom css files registered by the user under `site.params.custom_css and if found in the theme's
css asset directory we (unless condition below) add to aforementioned slice */}}
{{ with site.Params.custom_css }}
{{ range . }}
{{ with partialCached "func/style/GetResource" . . }}
{{ if eq .MediaType.SubType "x-scss" "x-sass" "scss" "sass" }}
{{ if hugo.IsExtended }}
{{/* as we cannot concatenate styles of different types, we sass/scss to be transformed to css beforehand */}}
{{ $assets_to_concat = $assets_to_concat | append (. | resources.ToCSS) }}
{{ else }}
{{ partial "func/warn" (printf "Processing of stylesheet %s of type %s has been skipped. You need Hugo Extended to process such files." .Name .MediaType.SubType) }}
{{ end }}
{{ else }}
{{ $assets_to_concat = $assets_to_concat | append . }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ with $assets_to_concat }}
{{/* We proceed to concatenate the $assets_to_concat */}}
{{ $style := . | resources.Concat "ananke/css/main.css" }}
{{/* We then use toCSS to add sourceMap and minify */}}
{{ $options := dict "enableSourceMap" true "precision" 6 }}
{{ $style = $style | resources.ToCSS $options | minify }}
{{/* We fingerprint in production for cache busting purposes */}}
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ $style = $style | fingerprint }}
{{ end }}
{{/* We're ready to set returning variable with resulting resource */}}
{{ $main_style = $style }}
{{ end }}
{{ return $main_style }}
\ No newline at end of file
{{/*
style/GetResource
Get a style asset stored at `/assets/ananke/css`
@author @regisphilibert
@context String (.)
@access private
@returns Resource
*/}}
{{ $resource := dict }}
{{ with resources.Get (print "/ananke/css/" .) }}
{{ $resource = . }}
{{ end }}
{{ return $resource }}
\ No newline at end of file
{{/*
warn
Emits a warning using the theme's Header.
@author @regisphilibert
@context String
@access private
@example - Go Template
{{ partial "func/warn" $message }}
*/}}
{{ $header := "Ananke Theme Warning" }}
{{ warnf "\n%s:\n%s" $header . }}
\ No newline at end of file
{{ if .IsTranslated }}
<h4>{{ i18n "translations" }}</h4>
<ul class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr0 ml3" "pl0 mr3" }}">
{{ range .Translations }}
<li class="list f5 f4-ns fw4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3" "pr3" }}">
<a class="hover-white no-underline white-90" href="{{ .RelPermalink }}">{{ .Lang }}</a>
</li>
{{ end}}
</ul>
{{ end }}
{{/*
Use Hugo's native Table of contents feature. You must set `toc: true` in your parameters for this to show.
https://gohugo.io/content-management/toc/
*/}}
{{- if .Params.toc -}}
<div class="bg-light-gray pa3 nested-list-reset nested-copy-line-height nested-links">
<p class="f5 b mb3">{{ i18n "whatsInThis" . }}</p>
{{ .TableOfContents }}
</div>
{{- end -}}
{{/*
Use Hugo's native related content feature to pull in content that may have similar parameters, like tags. etc.
https://gohugo.io/content-management/related/
*/}}
{{ $related := .Site.RegularPages.Related . | first 15 }}
{{ with $related }}
<div class="bg-light-gray pa3 nested-list-reset nested-copy-line-height nested-links">
<p class="f5 b mb3">{{ i18n "related" }}</p>
<ul class="pa0 list">
{{ range . }}
<li class="mb2">
<a href="{{ .RelPermalink }}">
{{- .Title -}}
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}