调整评论显示
This commit is contained in:
@@ -4,3 +4,4 @@ how_to_use_theme
|
||||
move_old_to_now
|
||||
.mimocode
|
||||
.vscode
|
||||
public/*
|
||||
@@ -1,13 +1,14 @@
|
||||
{{- with site.Params.comments.remark42 -}}
|
||||
<div id="remark42"></div>
|
||||
<script>
|
||||
var remark42_config = {
|
||||
var remark_config = {
|
||||
host: '{{ .host }}',
|
||||
site_id: '{{ .site_id }}',
|
||||
max_shown_comments: 15,
|
||||
theme: 'light',
|
||||
page_title: '{{ $.Title }}',
|
||||
locale: '{{ site.Language.Lang | default "zh" }}',
|
||||
locale: '{{ with site.Params.locale }}{{ if hasPrefix . "zh" }}zh{{ else }}{{ . }}{{ end }}{{ else }}zh{{ end }}',
|
||||
custom_css: '{{ site.BaseURL }}css/remark42.css',
|
||||
};
|
||||
</script>
|
||||
<script src="{{ .host }}/web/embed.js"></script>
|
||||
@@ -29,12 +30,12 @@
|
||||
if (frame && frame.contentWindow) {
|
||||
frame.contentWindow.postMessage(
|
||||
{ theme: getRemark42Theme() },
|
||||
remark42_config.host
|
||||
remark_config.host
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
remark42_config.theme = getRemark42Theme();
|
||||
remark_config.theme = getRemark42Theme();
|
||||
|
||||
window.addEventListener('message', function (e) {
|
||||
if (e.data && e.data.remark42) {
|
||||
@@ -52,6 +53,53 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Remove "Powered by Remark42" branding
|
||||
function removeBranding() {
|
||||
var frame = document.querySelector('iframe#remark42-frame');
|
||||
if (!frame || !frame.contentDocument) return;
|
||||
var doc = frame.contentDocument;
|
||||
// Try multiple known selectors for the branding element
|
||||
var selectors = [
|
||||
'a[href*="remark42"]',
|
||||
'a[href*="remark42.com"]',
|
||||
'.powered-by',
|
||||
'.remark42 .footer a',
|
||||
'footer a',
|
||||
];
|
||||
selectors.forEach(function (sel) {
|
||||
doc.querySelectorAll(sel).forEach(function (el) {
|
||||
el.style.display = 'none';
|
||||
});
|
||||
});
|
||||
// Also hide any parent container that only contains the branding
|
||||
doc.querySelectorAll('.powered-by, .footer').forEach(function (el) {
|
||||
if (el.children.length === 0 || el.textContent.trim().indexOf('Remark42') !== -1) {
|
||||
el.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Observe iframe content changes to catch dynamically rendered branding
|
||||
function observeBranding() {
|
||||
var frame = document.querySelector('iframe#remark42-frame');
|
||||
if (!frame || !frame.contentDocument) return;
|
||||
var observer = new MutationObserver(function () {
|
||||
removeBranding();
|
||||
});
|
||||
observer.observe(frame.contentDocument.body, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
// Run on iframe load and also poll briefly in case it loads fast
|
||||
var frame = document.querySelector('iframe#remark42-frame');
|
||||
if (frame) {
|
||||
frame.addEventListener('load', function () {
|
||||
removeBranding();
|
||||
observeBranding();
|
||||
});
|
||||
}
|
||||
setTimeout(removeBranding, 2000);
|
||||
setTimeout(removeBranding, 5000);
|
||||
})();
|
||||
</script>
|
||||
{{- else -}}
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
/* remark42 custom theme matching Hextra */
|
||||
|
||||
/* ===== Light mode (default) ===== */
|
||||
:root {
|
||||
--color-bg: #ffffff;
|
||||
--color-bg-secondary: #f8fafc;
|
||||
--color-text: #1e293b;
|
||||
--color-text-secondary: #64748b;
|
||||
--color-border: #e2e8f0;
|
||||
--color-border-hover: #cbd5e1;
|
||||
--color-primary: #3b82f6;
|
||||
--color-primary-hover: #2563eb;
|
||||
--color-danger: #ef4444;
|
||||
--color-success: #22c55e;
|
||||
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
|
||||
--radius: 12px;
|
||||
--shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
/* ===== Dark mode ===== */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--color-bg: #0f172a;
|
||||
--color-bg-secondary: #1e293b;
|
||||
--color-text: #e2e8f0;
|
||||
--color-text-secondary: #94a3b8;
|
||||
--color-border: #334155;
|
||||
--color-border-hover: #475569;
|
||||
--color-primary: #60a5fa;
|
||||
--color-primary-hover: #93bbfd;
|
||||
--color-danger: #f87171;
|
||||
--color-success: #4ade80;
|
||||
--shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remark42 dark theme override */
|
||||
.remark42 .root-498a3,
|
||||
.remark42[data-theme="dark"] {
|
||||
--color-bg: #0f172a !important;
|
||||
--color-bg-secondary: #1e293b !important;
|
||||
--color-text: #e2e8f0 !important;
|
||||
--color-text-secondary: #94a3b8 !important;
|
||||
--color-border: #334155 !important;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-family) !important;
|
||||
background: var(--color-bg) !important;
|
||||
color: var(--color-text) !important;
|
||||
}
|
||||
|
||||
/* Comment container */
|
||||
.remark42 #root {
|
||||
max-width: 100% !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
/* Comment thread */
|
||||
.remark42 .comment {
|
||||
border-radius: var(--radius) !important;
|
||||
border: 1px solid var(--color-border) !important;
|
||||
background: var(--color-bg) !important;
|
||||
padding: 16px !important;
|
||||
margin-bottom: 12px !important;
|
||||
box-shadow: var(--shadow) !important;
|
||||
transition: border-color 0.2s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .comment:hover {
|
||||
border-color: var(--color-border-hover) !important;
|
||||
}
|
||||
|
||||
/* Comment header / user info */
|
||||
.remark42 .comment__author {
|
||||
color: var(--color-text) !important;
|
||||
font-weight: 600 !important;
|
||||
font-size: 14px !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__time {
|
||||
color: var(--color-text-secondary) !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
/* Comment body text */
|
||||
.remark42 .comment__text {
|
||||
color: var(--color-text) !important;
|
||||
font-size: 15px !important;
|
||||
line-height: 1.7 !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__text p {
|
||||
margin: 0 0 8px 0 !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__text p:last-child {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
/* Links inside comments */
|
||||
.remark42 .comment__text a {
|
||||
color: var(--color-primary) !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__text a:hover {
|
||||
text-decoration: underline !important;
|
||||
color: var(--color-primary-hover) !important;
|
||||
}
|
||||
|
||||
/* Code blocks inside comments */
|
||||
.remark42 .comment__text code {
|
||||
background: var(--color-bg-secondary) !important;
|
||||
color: var(--color-text) !important;
|
||||
padding: 2px 6px !important;
|
||||
border-radius: 6px !important;
|
||||
font-size: 13px !important;
|
||||
border: 1px solid var(--color-border) !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__text pre {
|
||||
background: var(--color-bg-secondary) !important;
|
||||
border: 1px solid var(--color-border) !important;
|
||||
border-radius: 8px !important;
|
||||
padding: 12px !important;
|
||||
overflow-x: auto !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__text pre code {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
/* Vote buttons */
|
||||
.remark42 .vote {
|
||||
color: var(--color-text-secondary) !important;
|
||||
}
|
||||
|
||||
.remark42 .vote__value {
|
||||
color: var(--color-text) !important;
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
|
||||
.remark42 .vote__button {
|
||||
color: var(--color-text-secondary) !important;
|
||||
border-radius: 8px !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .vote__button:hover {
|
||||
color: var(--color-primary) !important;
|
||||
background: var(--color-bg-secondary) !important;
|
||||
}
|
||||
|
||||
/* Reply button */
|
||||
.remark42 .comment__reply {
|
||||
color: var(--color-text-secondary) !important;
|
||||
font-size: 13px !important;
|
||||
cursor: pointer !important;
|
||||
transition: color 0.15s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .comment__reply:hover {
|
||||
color: var(--color-primary) !important;
|
||||
}
|
||||
|
||||
/* Comment input / textarea */
|
||||
.remark42 .input {
|
||||
background: var(--color-bg) !important;
|
||||
color: var(--color-text) !important;
|
||||
border: 1px solid var(--color-border) !important;
|
||||
border-radius: var(--radius) !important;
|
||||
padding: 12px 16px !important;
|
||||
font-size: 15px !important;
|
||||
font-family: var(--font-family) !important;
|
||||
line-height: 1.6 !important;
|
||||
transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
|
||||
width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
.remark42 .input:focus {
|
||||
outline: none !important;
|
||||
border-color: var(--color-primary) !important;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
|
||||
}
|
||||
|
||||
.remark42 textarea.input {
|
||||
min-height: 100px !important;
|
||||
resize: vertical !important;
|
||||
}
|
||||
|
||||
/* Submit button */
|
||||
.remark42 .button_submit {
|
||||
background: var(--color-primary) !important;
|
||||
color: #ffffff !important;
|
||||
border: none !important;
|
||||
border-radius: 8px !important;
|
||||
padding: 8px 20px !important;
|
||||
font-size: 14px !important;
|
||||
font-weight: 500 !important;
|
||||
cursor: pointer !important;
|
||||
transition: background 0.15s ease, transform 0.1s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .button_submit:hover {
|
||||
background: var(--color-primary-hover) !important;
|
||||
}
|
||||
|
||||
.remark42 .button_submit:active {
|
||||
transform: scale(0.97) !important;
|
||||
}
|
||||
|
||||
/* Toolbar buttons (bold, italic, etc.) */
|
||||
.remark42 .button {
|
||||
color: var(--color-text-secondary) !important;
|
||||
border-radius: 6px !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .button:hover {
|
||||
color: var(--color-text) !important;
|
||||
background: var(--color-bg-secondary) !important;
|
||||
}
|
||||
|
||||
/* Tabs (Comments / Profile) */
|
||||
.remark42 .tabs {
|
||||
border-bottom: 1px solid var(--color-border) !important;
|
||||
margin-bottom: 16px !important;
|
||||
}
|
||||
|
||||
.remark42 .tabs__tab {
|
||||
color: var(--color-text-secondary) !important;
|
||||
font-weight: 500 !important;
|
||||
padding: 8px 16px !important;
|
||||
border-bottom: 2px solid transparent !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .tabs__tab:hover {
|
||||
color: var(--color-text) !important;
|
||||
}
|
||||
|
||||
.remark42 .tabs__tab_active {
|
||||
color: var(--color-primary) !important;
|
||||
border-bottom-color: var(--color-primary) !important;
|
||||
}
|
||||
|
||||
/* Separator / horizontal rule */
|
||||
.remark42 hr {
|
||||
border: none !important;
|
||||
border-top: 1px solid var(--color-border) !important;
|
||||
margin: 12px 0 !important;
|
||||
}
|
||||
|
||||
/* Scrollbar styling */
|
||||
.remark42 ::-webkit-scrollbar {
|
||||
width: 6px !important;
|
||||
}
|
||||
|
||||
.remark42 ::-webkit-scrollbar-track {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.remark42 ::-webkit-scrollbar-thumb {
|
||||
background: var(--color-border) !important;
|
||||
border-radius: 3px !important;
|
||||
}
|
||||
|
||||
.remark42 ::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--color-border-hover) !important;
|
||||
}
|
||||
|
||||
/* "Show more" / pagination */
|
||||
.remark42 .more-button {
|
||||
color: var(--color-primary) !important;
|
||||
font-weight: 500 !important;
|
||||
border-radius: 8px !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.remark42 .more-button:hover {
|
||||
background: var(--color-bg-secondary) !important;
|
||||
}
|
||||
|
||||
/* Hide "Powered by Remark42" branding */
|
||||
.remark42 .powered-by,
|
||||
.remark42 .footer,
|
||||
.remark42 [class*="branding"] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.remark42 a[href*="remark42"] {
|
||||
display: none !important;
|
||||
}
|
||||
Reference in New Issue
Block a user