diff --git a/exampleSite/content/posts/rich-content.md b/exampleSite/content/posts/rich-content.md index 404d79b..85c7b5b 100755 --- a/exampleSite/content/posts/rich-content.md +++ b/exampleSite/content/posts/rich-content.md @@ -32,9 +32,9 @@ and no-JS versions of various social media embeds. --- -## Twitter Shortcode +## X(Twitter) Shortcode -{{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} +{{< x user="SanDiegoZoo" id="1453110110599868418" >}}
diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 2cc33f5..c38c5ed 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -106,11 +106,29 @@ params: twitter: 'Your Twitter username' github: 'Your GitHub username' linkedin: 'Your LinkedIn username' - disableShareByType: - - not-exist + + share: + disabled: false + disableByType: # content type + - not-exist + platforms: # available inherit platform: [redidit, x, facebook, google, telegram] + - name: reddit # inherit platform just need the name + - name: x + - name: facebook + - name: google + # - name: telegram # disable the inherit platform + - name: Linkedin # this is a custom platform + url: "https://www.linkedin.com/shareArticle?url=%s&title=%s" # args(Permalink, Title) + - name: WhatsApp + url: "https://wa.me/?text=%s %s" + connect: + platforms: # available inherit platform: [github, x, linkedin] + - github + - x + - linkedin articleMetadata: - position: header # Can be either header, sidebar or none. + position: header # Can be either [header, sidebar, none]. # Table of contents toc: diff --git a/exampleSite/hugo_stats.json b/exampleSite/hugo_stats.json index c92bd72..53bdfdf 100644 --- a/exampleSite/hugo_stats.json +++ b/exampleSite/hugo_stats.json @@ -134,7 +134,6 @@ "dark:bg-neutral-900", "dark:bg-neutral-900/50", "dark:bg-neutral-900/70", - "dark:bg-neutral-900/80", "dark:bg-sky-400/90", "dark:bg-sky-800/50", "dark:bg-sky-950/30", @@ -393,7 +392,6 @@ "lg:gap-8", "lg:grid-cols-3", "lg:h-12", - "lg:mb-12", "lg:mb-4", "lg:mb-8", "lg:min-h-screen", @@ -430,7 +428,6 @@ "md:hidden", "md:items-center", "md:mb-4", - "md:mb-8", "md:p-3", "md:px-2", "md:px-8", @@ -668,10 +665,10 @@ "toc", "toc-toggle", "toggle-sidebar", - "twitter-shortcode", "unordered-list", "vagus-elidunt", "vimeo-shortcode", + "xtwitter-shortcode", "youtube-privacy-enhanced-shortcode" ] } diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 7f440b1..d1f2595 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,4 +1,5 @@ {{- define "main" -}} + {{- $enableComments := and (not .Site.Params.comment.disabled) (not (in .Site.Params.comment.disableByType .Type)) -}} {{- $metadataPosition := lower (default "header" .Site.Params.articleMetadata.position) -}}
@@ -43,6 +44,7 @@

{{- partial "article-metadata" . -}} {{- end -}} +
transition-all duration-300 ease-out"> {{- $enableToc := and (gt .WordCount 400) (and (not (eq .Params.toc false)) (not .Site.Params.toc.disabled)) -}} {{- $enableToc = not (eq .TableOfContents "") -}} - {{- $enableShare := not (in .Site.Params.social.disableShareByType .Type) -}} + {{- $enableShare := false -}} + {{ if and (isset .Site.Params "social") (isset .Site.Params.social "share") }} + {{ $enableShare = and (not .Site.Params.social.share.disabled) (not (in .Site.Params.social.share.disableByType .Type)) }} + {{ end }} {{- if and $enableToc -}}
@@ -93,6 +98,7 @@

{{ i18n "backToTop" | default "Back to Top" | title }} + {{- if $enableComments }} + {{- end }}

@@ -124,22 +116,3 @@

- - - {{- partial "utils/icon" (dict "icon" $item.icon) -}} - - {{ $item.title }} - - -{{- end -}} diff --git a/layouts/partials/utils/share.html b/layouts/partials/utils/share.html index 3fc9165..c0dbe4c 100644 --- a/layouts/partials/utils/share.html +++ b/layouts/partials/utils/share.html @@ -1,49 +1,68 @@
-

- {{- i18n "shareWith" | strings.Title -}} -

-
- {{- $tag_list := "" -}} - {{- with .Params.Tags -}} - {{- $tag_list = delimit . "," -}} - {{- end -}} - {{- partial "inline/share/item.html" - (dict - "Name" "Reddit" - "Icon" "reddit" - "Title" .Title - "URL" (fmt.Print "https://reddit.com/submit?url=" .Permalink "&title=" .Title )) - -}} - {{- partial "inline/share/item.html" - (dict - "Name" "X.com" - "Icon" "twitter" - "Title" .Title - "URL" (fmt.Print "https://x.com/intent/tweet/?text=" .Title "&url= " .Permalink "&hashtags=" $tag_list)) - -}} - {{- partial "inline/share/item.html" - (dict - "Name" "Facebook" - "Icon" "facebook" - "Title" .Title - "URL" (fmt.Print "https://facebook.com/sharer/sharer.php?u= " .Permalink )) - -}} - {{- partial "inline/share/item.html" - (dict - "Name" "Google" - "Icon" "google" - "Title" .Title - "URL" (fmt.Print "https://www.google.com/bookmarks/mark?op=edit&bkmk=" .Permalink "&title=" .Title )) - -}} - {{- partial "inline/share/item.html" - (dict - "Name" "Telegram" - "Icon" "telegram" - "Title" .Title - "URL" (fmt.Print "https://telegram.me/share/url?url=" .Permalink "&text=" .Title )) - -}} -
+ {{- if not (or .Site.Params.social.share.disabled (in .Site.Params.social.share.disableByType .Type)) -}} +

+ {{- i18n "shareWith" | strings.Title -}} +

+
+ {{- $tag_list := "" -}} + {{- with .Params.Tags -}} + {{- $tag_list = delimit . "," -}} + {{- end -}} + + {{/* Define default social platforms */}} + {{- $default_platforms := dict + "reddit" (dict + "name" "Reddit" + "url" "https://reddit.com/submit?url=%s&title=%s") + "x" (dict + "name" "X.com" + "url" "https://x.com/intent/tweet/?text=%s&url=%s&hashtags=%s") + "facebook" (dict + "name" "Facebook" + "url" "https://facebook.com/sharer/sharer.php?u=%s") + "google" (dict + "name" "Google" + "url" "https://www.google.com/bookmarks/mark?op=edit&bkmk=%s&title=%s") + "telegram" (dict + "name" "Telegram" + "url" "https://telegram.me/share/url?url=%s&text=%s") + -}} + + {{/* Render configured platforms */}} + {{- range .Site.Params.social.share.platforms -}} + {{- $platform_name := .name | lower -}} + {{- $url := .url -}} + {{- $display_name := .name | title -}} + + {{/* Handle inherit platform */}} + {{- with index $default_platforms $platform_name -}} + {{- if not $url -}} + {{- $url = .url -}} + {{- end -}} + {{- $display_name = .name -}} + {{- end -}} + + {{/* Generate share URL */}} + {{- $final_url := "" -}} + {{- if eq $platform_name "x" -}} + {{- $final_url = printf $url $.Title $.Permalink $tag_list -}} + {{- else if or (eq $platform_name "reddit") (eq $platform_name "google") -}} + {{- $final_url = printf $url $.Permalink $.Title -}} + {{- else if eq $platform_name "facebook" -}} + {{- $final_url = printf $url $.Permalink -}} + {{- else -}} + {{- $final_url = printf $url $.Permalink $.Title -}} + {{- end -}} + + {{- partial "inline/share/item.html" (dict + "Name" $display_name + "Title" $.Title + "URL" $final_url) + -}} + {{- end -}} +
+ {{- end -}}
{{- define "partials/inline/share/item.html" -}} diff --git a/layouts/partials/utils/social-connect.html b/layouts/partials/utils/social-connect.html new file mode 100644 index 0000000..72bd9ed --- /dev/null +++ b/layouts/partials/utils/social-connect.html @@ -0,0 +1,43 @@ +{{- with .Site.Params.social -}} + {{- $social := . -}} + {{- with .connect -}} + + {{- $platformMap := dict + "github" (dict "icon" "github" "title" "Github" "config" $social.github "urlFormat" "https://github.com/%s") + "x" (dict "icon" "xcom" "title" "X.com" "config" $social.twitter "urlFormat" "https://x.com/%s") + "linkedin" (dict "icon" "linkedin" "title" "LinkedIn" "config" $social.linkedin "urlFormat" "https://linkedin.com/in/%s") + }} + + {{- range .platforms -}} + {{- $platformName := . -}} + {{- $platform := index $platformMap $platformName -}} + {{- with $platform -}} + {{- if .config -}} + {{- $url := printf .urlFormat $platformName -}} + {{- partial "inline/connect/item.html" (dict "icon" .icon "title" .title "url" $url) -}} + {{- end -}} + {{- end -}} + + {{- end -}} + {{- end -}} + +{{- end -}} + +{{- define "partials/inline/connect/item.html" -}} + {{- $item := . -}} +
  • + + + {{- partial "utils/icon" (dict "icon" $item.icon) -}} + + {{ $item.title }} + +
  • +{{- end -}} diff --git a/theme.toml b/theme.toml index 3a6e05a..2e4fe8d 100644 --- a/theme.toml +++ b/theme.toml @@ -3,6 +3,7 @@ license = 'MIT' licenselink = 'https://github.com/wayjam/hugo-theme-fluidity/blob/master/LICENSE' description = 'A fluid and responsive Hugo theme.' homepage = 'https://github.com/wayjam/hugo-theme-fluidity' +demositev = "https://wayjam.github.io/hugo-theme-fluidity" tags = ["blog", "fluent", "clean", "simple", "light", "dark" ,"writing", "syntax highlighting", "archives", "tailwindcss", "search", "emoji", "math typesetting", "fluent-design"] features = ["blog", "responsive", "social media", "archives"] [author]