feat: support custom social media

This commit is contained in:
Erzbir
2026-08-17 17:07:24 +08:00
parent 23d303863f
commit 38639e3199
3 changed files with 69 additions and 156 deletions
+30 -35
View File
@@ -469,41 +469,36 @@ spec:
name: rss name: rss
label: RSS label: RSS
value: false value: false
- $formkit: text
name: github - $formkit: array
label: GitHub name: social_media
placeholder: "用户名" label: 社交媒体
value: value: [ ]
- $formkit: text itemLabels:
name: email - type: "iconify"
label: Email label: "$value.iconify"
placeholder: "邮箱地址" - type: "text"
value: label: "$value.name"
- $formkit: text - type: "text"
name: discord label: "$value.url"
label: Discord children:
placeholder: "分享链接" - $formkit: iconify
value: name: iconify
- $formkit: text label: 图标
name: telegram format: svg
label: Telegram validation: "required"
placeholder: "用户名" - $formkit: iconify
value: name: pixel_iconify
- $formkit: text label: 像素风格图标
name: facebook format: svg
label: Facebook help: "留空时使用普通图标"
placeholder: "用户名" - $formkit: text
value: name: name
- $formkit: text label: 名称
name: instagram - $formkit: text
label: Instagram name: url
placeholder: "用户名" label: 链接
value: validation: "required"
- $formkit: text
name: x
label: X
placeholder: "用户名"
value:
- group: icp - group: icp
label: 备案 label: 备案
+5 -1
View File
@@ -18,6 +18,10 @@
width: calc(var(--size-theme-font) * 1.2); width: calc(var(--size-theme-font) * 1.2);
height: calc(var(--size-theme-font) * 1.2); height: calc(var(--size-theme-font) * 1.2);
} }
span {
height: calc(var(--size-theme-font) * 1.2);
}
} }
.divider { .divider {
@@ -25,4 +29,4 @@
font-weight: 300; font-weight: 300;
user-select: none; user-select: none;
} }
} }
+34 -120
View File
@@ -1,117 +1,27 @@
<th:block th:fragment="sns"> <th:block th:fragment="sns">
<div class="sns-container"> <div class="sns-container">
<!-- Email --> <th:block th:each="social : ${theme.config.sns.social_media}">
<a class="sns-icon" <a class="sns-icon"
aria-label="Email" target="_blank"
target="_blank" rel="noopener noreferrer"
rel="noopener noreferrer" th:href="${social.url}"
th:href="'mailto:'+${theme.config.sns.email}" th:aria-label="${#strings.isEmpty(social.name) ? 'Social Media' : social.name}">
th:if="${not #strings.isEmpty(theme.config.sns.email)}">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="icon-regular" viewBox="0 0 24 24">
<path fill="#currentColor" d="M20.232 2.592H3.768A3.53 3.53 0 0 0 .24 6.12v11.76a3.53 3.53 0 0 0 3.528 3.528h16.464a3.53 3.53 0 0 0 3.528-3.528V6.12a3.53 3.53 0 0 0-3.528-3.528M3.768 4.944h16.464a1.176 1.176 0 0 1 1.176 1.176L12 11.859 2.592 6.12a1.176 1.176 0 0 1 1.176-1.176m17.64 12.936a1.176 1.176 0 0 1-1.176 1.176H3.768a1.176 1.176 0 0 1-1.176-1.176V8.801l8.797 5.375a1.18 1.18 0 0 0 1.175 0L21.408 8.8z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" class="icon-pixel" viewBox="0 0 32 32">
<g fill="currentColor">
<path d="M30.47 6.1H32v19.8h-1.53ZM28.95 25.9h1.52v1.53h-1.52ZM28.95 4.57h1.52V6.1h-1.52ZM27.43 7.62h1.52v3.05h-1.52ZM3.05 27.43h25.9v1.52H3.05ZM25.9 22.86h1.53v1.52H25.9ZM25.9 10.67h1.53v1.52H25.9ZM24.38 21.33h1.52v1.53h-1.52ZM24.38 12.19h1.52v1.52h-1.52ZM22.85 19.81h1.53v1.52h-1.53ZM22.85 13.71h1.53v1.53h-1.53ZM21.33 18.29h1.52v1.52h-1.52ZM21.33 15.24h1.52v1.52h-1.52Z"/>
<path d="M18.28 16.76h3.05v1.53h-3.05ZM13.71 18.29h4.57v1.52h-4.57ZM10.66 16.76h3.05v1.53h-3.05ZM9.14 18.29h1.52v1.52H9.14ZM9.14 15.24h1.52v1.52H9.14ZM7.62 19.81h1.52v1.52H7.62ZM7.62 13.71h1.52v1.53H7.62ZM6.09 21.33h1.53v1.53H6.09ZM6.09 12.19h1.53v1.52H6.09ZM4.57 22.86h1.52v1.52H4.57ZM4.57 10.67h1.52v1.52H4.57ZM3.05 3.05h25.9v1.52H3.05ZM3.05 7.62h1.52v3.05H3.05ZM1.52 25.9h1.53v1.53H1.52ZM1.52 4.57h1.53V6.1H1.52ZM0 6.1h1.52v19.8H0Z"/>
</g>
</svg>
</a>
<!-- GitHub --> <span class="icon-regular"
<a class="sns-icon" th:utext="${social.iconify.value}">
target="_blank" </span>
rel="noopener noreferrer" <span class="icon-pixel"
aria-label="GitHub" th:utext="${social.pixel_iconify != null and social.pixel_iconify.value != null
th:href="'https://github.com/'+${theme.config.sns.github}" ? social.pixel_iconify.value
th:if="${not #strings.isEmpty(theme.config.sns.github)}"> : social.iconify.value}">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="icon-regular" viewBox="0 0 24 24"> </span>
<path fill="#currentColor" d="M12 .53a11.76 11.76 0 0 0-3.72 22.917c.589.103.81-.25.81-.558 0-.28-.015-1.206-.015-2.19-2.955.543-3.72-.72-3.955-1.382a4.3 4.3 0 0 0-1.205-1.661c-.412-.22-1-.765-.015-.78a2.35 2.35 0 0 1 1.808 1.206 2.513 2.513 0 0 0 3.425.97c.051-.598.318-1.157.75-1.573-2.616-.294-5.35-1.308-5.35-5.806a4.58 4.58 0 0 1 1.205-3.16 4.23 4.23 0 0 1 .117-3.117S6.84 5.087 9.09 6.6c1.925-.529 3.956-.529 5.88 0 2.25-1.529 3.234-1.205 3.234-1.205.435.986.478 2.1.118 3.116a4.55 4.55 0 0 1 1.205 3.16c0 4.514-2.749 5.513-5.365 5.807a2.79 2.79 0 0 1 .794 2.176c0 1.573-.015 2.837-.015 3.234 0 .308.22.676.808.558A11.766 11.766 0 0 0 12 .53"/> </a>
</svg> </th:block>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="currentColor" d="M23 9v6h-1v2h-1v2h-1v1h-1v1h-1v1h-2v1h-1v-5h-1v-1h1v-1h2v-1h1v-1h1V9h-1V6h-2v1h-1v1h-1V7h-4v1H9V7H8V6H6v3H5v5h1v1h1v1h2v2H7v-1H6v-1H4v1h1v2h1v1h3v3H8v-1H6v-1H5v-1H4v-1H3v-2H2v-2H1V9h1V7h1V5h1V4h1V3h2V2h2V1h6v1h2v1h2v1h1v1h1v2h1v2z"/>
</svg>
</a>
<!-- Discord -->
<a class="sns-icon"
target="_blank"
rel="noopener noreferrer"
aria-label="Discord"
th:href="${theme.config.sns.discord}"
th:if="${not #strings.isEmpty(theme.config.sns.discord)}">
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0a12.64 12.64 0 0 0-.617-1.25a.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.078.078 0 0 0 .084-.028a14.09 14.09 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13.107 13.107 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10.2 10.2 0 0 0 .372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127a12.299 12.299 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028a19.839 19.839 0 0 0 6.002-3.03a.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418z"></path>
</svg>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="currentColor" d="M22 11V8h-1V6h-1V5h-2V4h-3v1H9V4H6v1H4v1H3v2H2v3H1v7h2v1h2v1h2v-2H6v-1h2v1h1v1h6v-1h1v-1h2v1h-1v2h2v-1h2v-1h2v-7ZM9 15H7v-1H6v-2h1v-1h2v1h1v2H9Zm9-1h-1v1h-2v-1h-1v-2h1v-1h2v1h1Z" />
</svg>
</a>
<!-- Telegram -->
<a class="sns-icon"
target="_blank"
rel="noopener noreferrer"
aria-label="Telegram"
th:href="'https://t.me/'+${theme.config.sns.telegram}"
th:if="${not #strings.isEmpty(theme.config.sns.telegram)}">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="icon-regular" viewBox="0 0 24 24">
<path fill="currentColor" d="M12 .24a11.76 11.76 0 1 0 0 23.52A11.76 11.76 0 0 0 12 .24m3.74 17.82a.83.83 0 0 1-1.18.413l-3.192-2.481-2.049 1.89a.35.35 0 0 1-.335.046l.393-3.514.013.01.008-.07s5.744-5.23 5.978-5.453c.237-.222.16-.27.16-.27.013-.271-.426 0-.426 0l-7.612 4.897-3.17-1.08s-.487-.175-.532-.559c-.049-.38.548-.588.548-.588l12.603-5.006s1.036-.462 1.036.302z"/>
</svg>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12">
<path fill="currentColor" d="M10 11h1V1h-1v1H8v1h1v1h1v5H8v1h2ZM0 7h2V6H0Zm4 5h1v-1h1v-1H5V8h1V7H2v1h2ZM2 6h2V5H2Zm4 4h1V9h1V8H6Zm0-3h1V6H6ZM4 5h2V4H4Zm3 1h1V5H7ZM6 4h2V3H6Zm2 1h1V4H8Zm0 0"/>
</svg>
</a>
<!-- Facebook -->
<a class="sns-icon"
target="_blank"
rel="noopener noreferrer"
aria-label="Facebook"
th:href="'https://www.facebook.com/'+${theme.config.sns.facebook}"
th:if="${not #strings.isEmpty(theme.config.sns.facebook)}">
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669c1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"></path>
</svg>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<path fill="currentColor" d="M30.47 9.905h-1.52v-3.05h-1.53v-1.52H25.9v-1.53h-3.05v-1.52h-3.04V.765h-7.62v1.52H9.14v1.52H6.09v1.53H4.57v1.52H3.04v3.05H1.52v3.05H0v7.61h1.52v3.05h1.52v3.05h1.53v1.52h1.52v1.53h3.05v1.52h4.57v-10.67H9.14v-4.57h4.57v-6.09h1.52v-1.53h7.62v4.58h-4.57v3.04h6.1v1.53h-1.53v1.52h-1.52v1.52h-3.05v10.67h4.57v-1.52h3.05v-1.53h1.52v-1.52h1.53v-3.05h1.52v-3.05H32v-7.61h-1.53z" />
</svg>
</a>
<!-- Instagram -->
<a class="sns-icon"
target="_blank"
rel="noopener noreferrer"
aria-label="Instagram"
th:href="'https://www.instagram.com/'+${theme.config.sns.instagram}"
th:if="${not #strings.isEmpty(theme.config.sns.instagram)}">
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2.163c3.204 0 3.584.012 4.85.07c3.252.148 4.771 1.691 4.919 4.919c.058 1.265.069 1.645.069 4.849c0 3.205-.012 3.584-.069 4.849c-.149 3.225-1.664 4.771-4.919 4.919c-1.266.058-1.644.07-4.85.07c-3.204 0-3.584-.012-4.849-.07c-3.26-.149-4.771-1.699-4.919-4.92c-.058-1.265-.07-1.644-.07-4.849c0-3.204.013-3.583.07-4.849c.149-3.227 1.664-4.771 4.919-4.919c1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072C2.695.272.273 2.69.073 7.052C.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948c.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072c4.354-.2 6.782-2.618 6.979-6.98c.059-1.28.073-1.689.073-4.948c0-3.259-.014-3.667-.072-4.947c-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 1 0 0 12.324a6.162 6.162 0 0 0 0-12.324zM12 16a4 4 0 1 1 0-8a4 4 0 0 1 0 8zm6.406-11.845a1.44 1.44 0 1 0 0 2.881a1.44 1.44 0 0 0 0-2.881z"></path>
</svg>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<path fill="currentColor" d="M30.47 3.05H32v25.9h-1.53Zm-1.52 25.9h1.52v1.53h-1.52Zm0-27.43h1.52v1.53h-1.52ZM3.04 30.48h25.91V32H3.04ZM27.42 4.57H25.9V3.05H6.09v1.52H4.57v1.52H3.04V25.9h1.53v1.53h1.52v1.52H25.9v-1.52h1.52V25.9h1.53V6.09h-1.53ZM25.9 24.38h-1.52v1.52H7.61v-1.52H6.09V7.62h1.52V6.09h16.77v1.53h1.52Z" />
<path fill="currentColor" d="M21.33 7.62h3.05v3.05h-3.05Zm0 4.57h-1.52v-1.52h-7.62v1.52h-1.53v1.52H9.14v7.62h1.52v1.53h1.53v1.52h7.62v-1.52h1.52v-1.53h1.52v-7.62h-1.52Zm-1.52 7.62h-1.53v1.52h-4.57v-1.52h-1.52v-4.57h1.52v-1.53h4.57v1.53h1.53ZM3.04 0h25.91v1.52H3.04ZM1.52 28.95h1.52v1.53H1.52Zm0-27.43h1.52v1.53H1.52ZM0 3.05h1.52v25.9H0Z" />
</svg>
</a>
<!-- X -->
<a class="sns-icon"
target="_blank"
rel="noopener noreferrer"
aria-label="X"
th:href="'https://x.com/'+${theme.config.sns.x}"
th:if="${not #strings.isEmpty(theme.config.sns.x)}">
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M18.244 2.25h3.308l-7.227 8.26l8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path>
</svg>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12">
<path fill="currentColor" d="M1 3h1V2h2V1H0v1h1Zm-1 9h1v-1H0Zm1-1h1v-1H1Zm1-1h1V9H2Zm1-1h1V8H3Zm3 2h1V9H6ZM5 9h1V8H5ZM4 8h1V6H4ZM3 6h1V5H3Zm4 6h4v-1h-1v-1H9v1H7ZM2 5h1V3H2Zm6 5h1V8H8ZM7 8h1V7H7ZM6 7h1V5H6ZM5 5h1V4H5ZM4 4h1V2H4Zm3 1h1V4H7Zm1-1h1V3H8Zm1-1h1V2H9Zm1-1h1V1h-1Zm0 0" />
</svg>
</a>
<!-- Divider -->
<span class="divider" th:if="${theme.config.sns.rss}">|</span>
<span class="divider"
th:if="${theme.config.sns.rss
and theme.config.sns.social_media != null
and not #lists.isEmpty(theme.config.sns.social_media)}">|</span>
<!-- RSS --> <!-- RSS -->
<a class="sns-icon" <a class="sns-icon"
target="_blank" target="_blank"
@@ -119,16 +29,20 @@
th:href="@{/rss.xml}" th:href="@{/rss.xml}"
aria-label="RSS" aria-label="RSS"
th:if="${theme.config.sns.rss}"> th:if="${theme.config.sns.rss}">
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" <span class="icon-regular">
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
<path d="M4 11a9 9 0 0 1 9 9"></path> stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 4a16 16 0 0 1 16 16"></path> <path d="M4 11a9 9 0 0 1 9 9"></path>
<circle cx="5" cy="19" r="1"></circle> <path d="M4 4a16 16 0 0 1 16 16"></path>
</svg> <circle cx="5" cy="19" r="1"></circle>
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> </svg>
<path fill="currentColor" d="M22 2V1H2v1H1v20h1v1h20v-1h1V2zm-6 16v-3h-1v-2h-1v-1h-1v-1h-1v-1h-1V9H9V8H7V7H4V4h3v1h2v1h2v1h2v1h1v1h1v1h1v1h1v2h1v2h1v2h1v3h-3v-2zm-5 0v-2h-1v-1H9v-1H8v-1H6v-1H4V9h2v1h2v1h2v1h1v1h1v1h1v2h1v2h1v2h-3v-2zm-7 1v-3h1v-1h3v1h1v3H8v1H5v-1z"/> </span>
</svg> <span class="icon-pixel">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="currentColor"
d="M22 2V1H2v1H1v20h1v1h20v-1h1V2zm-6 16v-3h-1v-2h-1v-1h-1v-1h-1v-1h-1V9H9V8H7V7H4V4h3v1h2v1h2v1h2v1h1v1h1v1h1v1h1v2h1v2h1v2h1v3h-3v-2zm-5 0v-2h-1v-1H9v-1H8v-1H6v-1H4V9h2v1h2v1h2v1h1v1h1v1h1v2h1v2h1v2h-3v-2zm-7 1v-3h1v-1h3v1h1v3H8v1H5v-1z"/>
</svg>
</span>
</a> </a>
</div> </div>
</th:block> </th:block>