Skip to content

Commit

Permalink
自定义设置分享链接
Browse files Browse the repository at this point in the history
  • Loading branch information
Waite0603 authored and AirboZH committed Sep 20, 2023
1 parent f6019de commit c3783a7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
36 changes: 35 additions & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,38 @@ spec:
label: 页脚版权协议
value: "Except where otherwise noted, the blog posts on this site are licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License by the author."
help: 页脚 "All rights reserved" 浮现时显示的版权协议


- group: post
label: 文章
formSchema:
- $formkit: repeater
name: share
label: 分享设置
value:
- name: Telegram
icon: fa-fw fab fa-telegram
url: https://t.me/share/url?url=@URL
- name: Facebook
icon: fa-fw fab fa-facebook-square
url: https://www.facebook.com/sharer/sharer.php?u=@URL
- name: Twitter
icon: fa-fw fa-brands fa-square-x-twitter
url: https://twitter.com/intent/tweet?&url=@URL
max: 5
children:
- $formkit: text
name: name
label: 名称
value: ""
required: true
- $formkit: text
name: icon
label: 图标
value: ""
required: true
- $formkit: text
name: url
label: 链接
value: ""
required: true

40 changes: 11 additions & 29 deletions templates/modules/post/postShaing.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<th:block th:fragment="postShaing" class="share-wrapper"
th:with="siteUrl = ${#strings.substring(site.url, #strings.length(site.url) - 1)== '/'}? ${#strings.substring(site.url,0,#strings.length(site.url) - 1)}:${site.url}">
<div class="share-wrapper"
Expand All @@ -9,35 +8,18 @@
Share
</span>
<span class="share-icons">
<a
th:href="'https://t.me/share/url?url=' + ${postUrl}"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="Telegram"
target="_blank"
rel="noopener">
<i class="fa-fw fab fa-telegram"></i>
</a>

<a
th:href="'https://www.facebook.com/sharer/sharer.php?u=' + ${postUrl}"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="Facebook"
target="_blank"
rel="noopener">
<i class="fa-fw fab fa-facebook-square"></i>
</a>
<span th:each="entry : ${theme.config.post.share}">
<a
th:href="${#strings.replace(entry.url, '@URL', postUrl)}"
data-bs-toggle="tooltip"
data-bs-placement="top"
th:title="${entry.name}"
target="_blank"
rel="noopener">
<i th:class="${entry.icon}"></i>
</a>
</span>

<a
href="https://www.linkedin.com/shareArticle?mini=true&url={{ post.url }}&title={{ post.title }}&summary={{ post.description }}&source={{ site.url }}"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="LinkedIn"
target="_blank"
rel="noopener">
<i class="fa-fw fab fa-linkedin"></i>
</a>
<a href="javascript:void(0);"
onclick="navigator.clipboard.writeText(window.location.href);">
<i
Expand Down

0 comments on commit c3783a7

Please sign in to comment.