Browse Source

Merge https://github.com/gcushen/hugo-academic into HEAD

Pull updates from upstream.
Xi Ruoyao 6 years ago
parent
commit
7989035145

+ 2 - 2
README.md

@@ -50,9 +50,9 @@ Choose a stunning color and font theme for your site. Themes are fully customiza
 | --- | --- | --- | --- |
 | ![default theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-default.png) | ![ocean theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-ocean.png) | ![forest theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-forest.png) | ![dark theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-dark.png) |
 
-| `apogee` | `1950s` | `coffee` | `cupcake` |
+| `apogee` | `1950s` | `coffee` | `strawberry` |
 | --- | --- | --- | --- |
-| ![apogee theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-apogee.png) | ![1950s theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-1950s.png) | ![coffee theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-coffee-playfair.png) | ![cupcake theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-cupcake.png) |
+| ![apogee theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-apogee.png) | ![1950s theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-1950s.png) | ![coffee theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-coffee-playfair.png) | ![cupcake theme](https://raw.githubusercontent.com/gcushen/hugo-academic/master/images/theme-strawberry.png) |
 
 [Browse more themes...](https://sourcethemes.com/academic/themes/)
 

+ 1 - 1
assets/sass/academic/_root.scss

@@ -159,7 +159,7 @@ figcaption h4 {
 
 pre,
 code {
-  font-family: '$sta-font-mono', monospace;
+  font-family: $sta-font-mono, monospace;
   color: #c7254e;
   background-color: #f9f2f4;
 }

+ 58 - 0
data/page_sharer.toml

@@ -0,0 +1,58 @@
+# Page Sharer
+# Documentation: https://sourcethemes.com/academic/docs/customization/#page-sharer
+
+[[buttons]]
+  id = "twitter"
+  url = "https://twitter.com/intent/tweet?url={url}&text={title}"
+  title = "Twitter"
+  icon_pack = "fab"
+  icon = "twitter"
+  enable = true
+
+[[buttons]]
+  id = "facebook"
+  url = "https://www.facebook.com/sharer.php?u={url}&t={title}"
+  title = "Facebook"
+  icon_pack = "fab"
+  icon = "facebook-f"
+  enable = true
+
+[[buttons]]
+  id = "email"
+  url = "mailto:?subject={title}&body={url}"
+  title = "Email"
+  icon_pack = "fas"
+  icon = "envelope"
+  enable = true
+
+[[buttons]]
+  id = "linkedin"
+  url = "https://www.linkedin.com/shareArticle?url={url}&title={title}"
+  title = "LinkedIn"
+  icon_pack = "fab"
+  icon = "linkedin-in"
+  enable = true
+
+[[buttons]]
+  id = "whatsapp"
+  url = "https://web.whatsapp.com/send?text={title}%20{url}"
+  title = "WhatsApp"
+  icon_pack = "fab"
+  icon = "whatsapp"
+  enable = true
+
+[[buttons]]
+  id = "weibo"
+  url = "https://service.weibo.com/share/share.php?url={url}&title={title}"
+  title = "Weibo"
+  icon_pack = "fab"
+  icon = "weibo"
+  enable = true
+
+[[buttons]]
+  id = "reddit"
+  url = "https://reddit.com/submit?url={url}&title={title}"
+  title = "Reddit"
+  icon_pack = "fab"
+  icon = "reddit-alien"
+  enable = false

+ 1 - 0
exampleSite/config/_default/config.toml

@@ -35,6 +35,7 @@ enableGitInfo = false
 defaultContentLanguage = "en"
 hasCJKLanguage = false  # Set `true` for Chinese/Japanese/Korean languages.
 defaultContentLanguageInSubdir = false
+removePathAccents = true  # Workaround for https://github.com/gohugoio/hugo/issues/5687
 
 paginate = 10  # Number of items per page in paginated lists.
 enableEmoji = true

BIN
exampleSite/content/home/gallery/gallery/theme-cupcake.png


BIN
exampleSite/content/home/gallery/gallery/theme-strawberry.png


BIN
exampleSite/content/post/getting-started/gallery/theme-cupcake.png


BIN
exampleSite/content/post/getting-started/gallery/theme-strawberry.png


+ 2 - 2
exampleSite/content/post/getting-started/index.md

@@ -51,8 +51,8 @@ gallery_item:
   caption: Coffee theme with Playfair font
   image: theme-coffee-playfair.png
 - album: gallery
-  caption: Cupcake
-  image: theme-cupcake.png
+  caption: Strawberry
+  image: theme-strawberry.png
 ---
 
 **Create a free website with Academic using Markdown, Jupyter, or RStudio. Choose a beautiful color theme and build anything with the Page Builder - over 40 _widgets_, _themes_, and _language packs_ included!**

+ 14 - 34
layouts/partials/share.html

@@ -1,40 +1,20 @@
 {{ if and site.Params.sharing (ne .Params.share false) }}
 <div class="share-box" aria-hidden="true">
   <ul class="share">
-    <li>
-      <a class="twitter"
-         href="https://twitter.com/intent/tweet?text={{ .Title | html }}&amp;url={{ .Permalink | html }}"
-         target="_blank" rel="noopener">
-        <i class="fab fa-twitter"></i>
-      </a>
-    </li>
-    <li>
-      <a class="facebook"
-         href="https://www.facebook.com/sharer.php?u={{ .Permalink | html }}"
-         target="_blank" rel="noopener">
-        <i class="fab fa-facebook-f"></i>
-      </a>
-    </li>
-    <li>
-      <a class="linkedin"
-         href="https://www.linkedin.com/shareArticle?mini=true&amp;url={{ .Permalink | html }}&amp;title={{ .Title | html }}"
-         target="_blank" rel="noopener">
-        <i class="fab fa-linkedin-in"></i>
-      </a>
-    </li>
-    <li>
-      <a class="weibo"
-         href="http://service.weibo.com/share/share.php?url={{ .Permalink | html }}&amp;title={{ .Title | html }}"
-         target="_blank" rel="noopener">
-        <i class="fab fa-weibo"></i>
-      </a>
-    </li>
-    <li>
-      <a class="email"
-         href="mailto:?subject={{ .Title | html }}&amp;body={{ .Permalink | html }}">
-        <i class="fas fa-envelope"></i>
-      </a>
-    </li>
+    {{ range where site.Data.page_sharer.buttons "enable" true }}
+      {{ $pack := or .icon_pack "fas" }}
+      {{ $pack_prefix := $pack }}
+      {{ if in (slice "fab" "fas" "far" "fal") $pack }}
+        {{ $pack_prefix = "fa" }}
+      {{ end }}
+      {{ $link := replace .url "{url}" ($.Permalink | htmlEscape) }}
+      {{ $link = replace $link "{title}" ($.Title | htmlEscape) }}
+      <li>
+        <a href="{{$link|safeURL}}" target="_blank" rel="noopener" class="share-btn-{{.id}}">
+          <i class="{{$pack}} {{$pack_prefix}}-{{.icon}}"></i>
+        </a>
+      </li>
+    {{ end }}
   </ul>
 </div>
 {{ end }}

+ 6 - 6
layouts/shortcodes/gallery.html

@@ -21,14 +21,14 @@
   {{ range $images }}
     {{ $image := .Resize "x190" }}
     {{/* Check if the user set a caption for this image */}}
-    {{ $filename := .Name }}
+    {{ $filename := path.Base .Name }}
     {{ $caption := "" }}
     {{ if $.Page.Params.gallery_item }}
-    {{ range (where $.Page.Params.gallery_item "album" $album) }}
-      {{if eq (printf "%s/%s" $album .image) $filename}}{{ with .caption }}{{ $caption = . }}{{end}}{{end}}
+      {{ range (where (where $.Page.Params.gallery_item "album" $album) "image" $filename) }}
+        {{ $caption = .caption }}
+      {{ end }}
     {{ end }}
-    {{ end }}
-  <a data-fancybox="gallery-{{$album}}" href="{{ .RelPermalink }}" {{ with $caption }}data-caption="{{.}}"{{ end }}>
+  <a data-fancybox="gallery-{{$album}}" href="{{ .RelPermalink }}" {{ with $caption }}data-caption="{{.|markdownify|emojify|safeHTMLAttr}}"{{ end }}>
   <img src="{{ $image.RelPermalink }}" alt="">
   </a>
   {{end}}
@@ -45,7 +45,7 @@
       {{ $.Scratch.Set "src" (printf "img/%s" .image | relURL) }}
     {{ end }}
   {{ end }}
-  <a data-fancybox="gallery{{ with .album }}-{{.}}{{ end }}" {{ with .caption }}data-caption="{{.}}"{{ end }} href="{{$.Scratch.Get "src"}}">
+  <a data-fancybox="gallery{{ with .album }}-{{.}}{{ end }}" {{ with .caption }}data-caption="{{.|markdownify|emojify|safeHTMLAttr}}"{{ end }} href="{{$.Scratch.Get "src"}}">
     <img src="{{$.Scratch.Get "src"}}" alt="">
   </a>
   {{end}}