Skip to content

Commit

Permalink
modules: namespace Core module
Browse files Browse the repository at this point in the history
Hugo does not namespace modules by default, leading to conflicts. Hence, load partials from a namespaced sub-folder to prevent conflicts with similarly named files in other modules.
  • Loading branch information
gcushen committed Nov 1, 2023
1 parent 53a94b5 commit 7b61e2f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 23 deletions.
4 changes: 1 addition & 3 deletions modules/wowchemy-plugin-reveal/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ module github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-reveal

go 1.15

require (
github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core v0.1.0
)
require github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core v0.2.1-0.20231101183355-53a94b591ea8
4 changes: 2 additions & 2 deletions modules/wowchemy-plugin-reveal/layouts/slides/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<link rel="manifest" href="{{ .RelPermalink }}">
{{ end }}

<link rel="icon" type="image/png" href="{{(partial "functions/get_icon" 32).RelPermalink}}">
<link rel="apple-touch-icon" type="image/png" href="{{(partial "functions/get_icon" 192).RelPermalink}}">
<link rel="icon" type="image/png" href="{{(partial "wowchemy-core/functions/get_icon" 32).RelPermalink}}">
<link rel="apple-touch-icon" type="image/png" href="{{(partial "wowchemy-core/functions/get_icon" 192).RelPermalink}}">

<link rel="canonical" href="{{ .Permalink }}">

Expand Down
4 changes: 1 addition & 3 deletions modules/wowchemy-seo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ module github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-seo

go 1.15

require (
github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core v0.1.0
)
require github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core v0.2.1-0.20231101183355-53a94b591ea8
4 changes: 2 additions & 2 deletions modules/wowchemy-seo/layouts/index.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"theme_color": "{{ $theme_color }}",
"background_color": "{{ $theme_color }}",
"icons": [{
"src": "{{ (partial "functions/get_icon" 192).RelPermalink }}",
"src": "{{ (partial "wowchemy-core/functions/get_icon" 192).RelPermalink }}",
"sizes": "192x192",
"type": "image/png"
}, {
"src": "{{ (partial "functions/get_icon" 512).RelPermalink }}",
"src": "{{ (partial "wowchemy-core/functions/get_icon" 512).RelPermalink }}",
"sizes": "512x512",
"type": "image/png"
}],
Expand Down
6 changes: 3 additions & 3 deletions modules/wowchemy-seo/layouts/partials/jsonld/article.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{{- $page := .page }}
{{ $summary := .summary }}
{{ $featured_image := partial "functions/get_featured_image.html" $page }}
{{ $featured_image := partial "wowchemy-core/functions/get_featured_image.html" $page }}

{{/* Get schema type. */}}
{{ $schema := "Article" }}
{{ if eq $page.Type "post" }}
{{ $schema = "BlogPosting" }}
{{ end }}

{{ $author := partial "functions/get_author_name" $page }}
{{ $author := partial "wowchemy-core/functions/get_author_name" $page }}
{{ $publisher := site.Params.marketing.seo.org_name | default site.Title }}
{{ $logo_url := partial "functions/get_logo_url" $page -}}
{{ $logo_url := partial "wowchemy-core/functions/get_logo_url" $page -}}

<script type="application/ld+json">
{
Expand Down
2 changes: 1 addition & 1 deletion modules/wowchemy-seo/layouts/partials/jsonld/business.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@type": {{site.Params.marketing.seo.site_type | default site.Params.marketing.seo.site_type}},
"@id": {{site.BaseURL}},
"name": {{site.Params.marketing.seo.org_name | default site.Title}},
"logo": {{ partial "functions/get_logo_url" . }},
"logo": {{ partial "wowchemy-core/functions/get_logo_url" . }},
{{with $sharing_image}}"image": {{.Permalink}},{{end}}
{{ if (eq site.Params.marketing.seo.site_type "LocalBusiness") | and site.Params.marketing.seo.coordinates }}
"geo": {
Expand Down
4 changes: 2 additions & 2 deletions modules/wowchemy-seo/layouts/partials/jsonld/event.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ $page := .page }}
{{ $summary := .summary }}
{{ $featured_image := partial "functions/get_featured_image.html" $page }}
{{ $author := partial "functions/get_author_name" $page }}
{{ $featured_image := partial "wowchemy-core/functions/get_featured_image.html" $page }}
{{ $author := partial "wowchemy-core/functions/get_author_name" $page }}

<script type="application/ld+json">
{
Expand Down
31 changes: 24 additions & 7 deletions modules/wowchemy-seo/layouts/partials/seo_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
{{- end -}}

{{/* Attempt to load superuser (the main site author). */}}
{{ $superuser := index (first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true)) 0 }}
{{ $superuser_name := "" }}
{{ $superuser_username := "" }}
{{ $superuser_role := "" }}
{{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }}
{{ with $superuser }}
{{ $superuser_name = .Title }}
{{ $superuser_username = path.Base .File.Dir }}
{{ $superuser_role = .Params.role }}
Expand Down Expand Up @@ -50,15 +51,15 @@
{{ end }}

{{/* Progressive Web App (PWA) Icon */}}
<link rel="icon" type="image/png" href="{{ (partial "functions/get_icon" 32).RelPermalink }}" />
<link rel="apple-touch-icon" type="image/png" href="{{ (partial "functions/get_icon" 180).RelPermalink }}" />
<link rel="icon" type="image/png" href="{{ (partial "wowchemy-core/functions/get_icon" 32).RelPermalink }}" />
<link rel="apple-touch-icon" type="image/png" href="{{ (partial "wowchemy-core/functions/get_icon" 180).RelPermalink }}" />
{{ $theme_color := ($scr.Get "primary") | default site.Params.appearance.primary_color | default "#fff" }}
<meta name="theme-color" content="{{ $theme_color }}" />

{{/* Get page image for social sharing. */}}
{{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }}
{{/* Search for an image "*featured*" in post folder */}}
{{ $featured_image := partial "functions/get_featured_image.html" . }}
{{ $featured_image := partial "wowchemy-core/functions/get_featured_image.html" . }}
{{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }}
{{ $has_logo := fileExists "assets/media/logo.png" | or (fileExists "assets/media/logo.svg") }}
{{ $og_image := "" }}
Expand All @@ -72,15 +73,15 @@
{{ else if $sharing_image }}
{{ $og_image = $sharing_image.Permalink }}
{{ else if $has_logo }}
{{ $og_image = (partial "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }}
{{ $og_image = (partial "wowchemy-core/functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }}
{{ $twitter_card = "summary" }}
{{ else }}
{{ $og_image = (partial "functions/get_icon" 512).Permalink }}
{{ $og_image = (partial "wowchemy-core/functions/get_icon" 512).Permalink }}
{{ $twitter_card = "summary" }}
{{ end }}
{{ $scr.Set "og_image" $og_image }}{{/* Set `og_image` globally for `rss.xml`. */}}

{{ $title := partial "functions/get_page_title" . }}
{{ $title := partial "wowchemy-core/functions/get_page_title" . }}

{{/* Twitter metadata. */}}
<meta property="twitter:card" content="{{ $twitter_card }}" />
Expand All @@ -93,6 +94,22 @@
{{- end -}}

{{/* Open Graph metadata. */}}
{{ $site_type := lower (site.Params.marketing.seo.site_type | default "Person") }}
{{ $og_type := "website" }}
{{ if .IsHome }}
{{ if eq $site_type "person" }}
{{ $og_type = "profile" }}
{{ with $superuser.Params.first_name }}<meta property="profile:first_name" content="{{ . }}">{{end}}
{{ with $superuser.Params.last_name }}<meta property="profile:last_name" content="{{ . }}">{{end}}
{{ else }}
{{ $og_type = "website" }}
{{ end }}
{{ else if .IsPage | and (in (slice "post" "publication" "project" "book") .Type ) }}
{{ $og_type = "article" }}
{{ else }}
{{ $og_type = "website" }}
{{ end }}
<meta property="og:type" content="{{ $og_type }}" />
<meta property="og:site_name" content="{{ site.Title }}" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:title" content="{{ $title }}" />
Expand Down

0 comments on commit 7b61e2f

Please sign in to comment.