Val's Dreamscape Journal - initial
This commit is contained in:
323
assets/css/main.css
Normal file
323
assets/css/main.css
Normal file
@@ -0,0 +1,323 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* CSS Variables */
|
||||
:root {
|
||||
/* 浅色模式 */
|
||||
--color-bg-primary: #F7F5F0;
|
||||
--color-bg-secondary: #FFFFFF;
|
||||
--color-bg-tertiary: #EDE9E0;
|
||||
--color-text-primary: #2D3E50;
|
||||
--color-text-secondary: #5A6A7A;
|
||||
--color-text-tertiary: #8A94A6;
|
||||
--color-accent: #C9A961;
|
||||
--color-accent-hover: #B89850;
|
||||
--color-border: #E5E1D8;
|
||||
--color-code-bg: #F0EDE6;
|
||||
}
|
||||
|
||||
[data-theme="dark"] {
|
||||
/* 暗色模式 */
|
||||
--color-bg-primary: #1A1F2B;
|
||||
--color-bg-secondary: #232936;
|
||||
--color-bg-tertiary: #2D3544;
|
||||
--color-text-primary: #D4D4D4;
|
||||
--color-text-secondary: #A0AAB8;
|
||||
--color-text-tertiary: #6B7280;
|
||||
--color-accent: #D4B86A;
|
||||
--color-accent-hover: #E0C87A;
|
||||
--color-border: #3A4150;
|
||||
--color-code-bg: #1E2530;
|
||||
}
|
||||
|
||||
/* 系统偏好检测 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root:not([data-theme]) {
|
||||
--color-bg-primary: #1A1F2B;
|
||||
--color-bg-secondary: #232936;
|
||||
--color-bg-tertiary: #2D3544;
|
||||
--color-text-primary: #D4D4D4;
|
||||
--color-text-secondary: #A0AAB8;
|
||||
--color-text-tertiary: #6B7280;
|
||||
--color-accent: #D4B86A;
|
||||
--color-accent-hover: #E0C87A;
|
||||
--color-border: #3A4150;
|
||||
--color-code-bg: #1E2530;
|
||||
}
|
||||
}
|
||||
|
||||
/* Base Styles */
|
||||
@layer base {
|
||||
body {
|
||||
font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
background-color: var(--color-bg-primary);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Noto Serif SC', 'Source Serif 4', serif;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
/* Utility Classes */
|
||||
@layer utilities {
|
||||
.bg-primary { background-color: var(--color-bg-primary); }
|
||||
.bg-secondary { background-color: var(--color-bg-secondary); }
|
||||
.bg-tertiary { background-color: var(--color-bg-tertiary); }
|
||||
.text-primary { color: var(--color-text-primary); }
|
||||
.text-secondary { color: var(--color-text-secondary); }
|
||||
.text-tertiary { color: var(--color-text-tertiary); }
|
||||
.text-accent { color: var(--color-accent); }
|
||||
.hover\:text-accent:hover { color: var(--color-accent); }
|
||||
.border-border { border-color: var(--color-border); }
|
||||
}
|
||||
|
||||
/* Typography */
|
||||
.font-serif {
|
||||
font-family: 'Noto Serif SC', 'Source Serif 4', serif;
|
||||
}
|
||||
|
||||
.font-sans {
|
||||
font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
}
|
||||
|
||||
/* Article Content */
|
||||
.article-content {
|
||||
line-height: 1.8;
|
||||
font-size: 1.0625rem;
|
||||
}
|
||||
|
||||
.article-content h2 {
|
||||
font-size: 1.5rem;
|
||||
margin-top: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.article-content h3 {
|
||||
font-size: 1.25rem;
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 0.75rem;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.article-content p {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.article-content a {
|
||||
color: var(--color-accent);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: transparent;
|
||||
transition: text-decoration-color 0.2s;
|
||||
}
|
||||
|
||||
.article-content a:hover {
|
||||
text-decoration-color: var(--color-accent);
|
||||
}
|
||||
|
||||
.article-content ul,
|
||||
.article-content ol {
|
||||
margin-bottom: 1.25rem;
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
||||
.article-content li {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.article-content blockquote {
|
||||
border-left: 3px solid var(--color-accent);
|
||||
padding-left: 1rem;
|
||||
margin: 1.5rem 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.article-content code {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 0.875em;
|
||||
background-color: var(--color-code-bg);
|
||||
padding: 0.125rem 0.375rem;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.article-content pre {
|
||||
background-color: var(--color-code-bg);
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
overflow-x: auto;
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.article-content pre code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.article-content img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
/* Table of Contents */
|
||||
.toc {
|
||||
background-color: var(--color-bg-secondary);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 0.5rem;
|
||||
padding: 1rem 1.5rem;
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.toc-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.75rem;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.toc ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.toc li {
|
||||
margin: 0.375rem 0;
|
||||
}
|
||||
|
||||
.toc a {
|
||||
color: var(--color-text-secondary);
|
||||
text-decoration: none;
|
||||
font-size: 0.9375rem;
|
||||
}
|
||||
|
||||
.toc a:hover {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
/* Card Styles */
|
||||
.card {
|
||||
background-color: var(--color-bg-secondary);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 0.5rem;
|
||||
transition: box-shadow 0.2s, transform 0.2s;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
/* Tag Styles */
|
||||
.tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.25rem 0.75rem;
|
||||
background-color: var(--color-bg-tertiary);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.875rem;
|
||||
border-radius: 9999px;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
.tag:hover {
|
||||
background-color: var(--color-accent);
|
||||
color: var(--color-bg-primary);
|
||||
}
|
||||
|
||||
/* Search Results */
|
||||
.search-result {
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
|
||||
.search-result:hover {
|
||||
background-color: var(--color-bg-secondary);
|
||||
}
|
||||
|
||||
.search-result:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.search-result-title {
|
||||
font-weight: 500;
|
||||
color: var(--color-text-primary);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.search-result-summary {
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-secondary);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.search-highlight {
|
||||
background-color: rgba(201, 169, 97, 0.3);
|
||||
padding: 0.125rem 0.25rem;
|
||||
border-radius: 0.125rem;
|
||||
}
|
||||
|
||||
/* Pagination */
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.pagination a,
|
||||
.pagination span {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 0.375rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.pagination a {
|
||||
color: var(--color-text-secondary);
|
||||
border: 1px solid var(--color-border);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.pagination a:hover {
|
||||
border-color: var(--color-accent);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.pagination .current {
|
||||
background-color: var(--color-accent);
|
||||
color: var(--color-bg-primary);
|
||||
}
|
||||
|
||||
/* Mobile Menu Animation */
|
||||
#mobile-menu {
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
/* Scrollbar Styling */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--color-bg-secondary);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--color-border);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--color-text-tertiary);
|
||||
}
|
||||
|
||||
/* Selection */
|
||||
::selection {
|
||||
background-color: rgba(201, 169, 97, 0.3);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
187
assets/js/main.js
Normal file
187
assets/js/main.js
Normal file
@@ -0,0 +1,187 @@
|
||||
// Theme Toggle
|
||||
(function() {
|
||||
const toggle = document.getElementById('theme-toggle');
|
||||
const iconLight = document.getElementById('theme-icon-light');
|
||||
const iconDark = document.getElementById('theme-icon-dark');
|
||||
const html = document.documentElement;
|
||||
|
||||
// Get initial theme
|
||||
function getTheme() {
|
||||
const saved = localStorage.getItem('theme');
|
||||
if (saved) return saved;
|
||||
if (window.matchMedia('(prefers-color-scheme: dark)').matches) return 'dark';
|
||||
return 'light';
|
||||
}
|
||||
|
||||
// Apply theme
|
||||
function applyTheme(theme) {
|
||||
html.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('theme', theme);
|
||||
updateIcons(theme);
|
||||
}
|
||||
|
||||
// Update icons
|
||||
function updateIcons(theme) {
|
||||
if (theme === 'dark') {
|
||||
iconLight?.classList.remove('hidden');
|
||||
iconDark?.classList.add('hidden');
|
||||
} else {
|
||||
iconLight?.classList.add('hidden');
|
||||
iconDark?.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize
|
||||
applyTheme(getTheme());
|
||||
|
||||
// Toggle handler
|
||||
toggle?.addEventListener('click', () => {
|
||||
const current = html.getAttribute('data-theme');
|
||||
applyTheme(current === 'dark' ? 'light' : 'dark');
|
||||
});
|
||||
})();
|
||||
|
||||
// Mobile Menu
|
||||
(function() {
|
||||
const menuToggle = document.getElementById('mobile-menu-toggle');
|
||||
const mobileMenu = document.getElementById('mobile-menu');
|
||||
|
||||
menuToggle?.addEventListener('click', () => {
|
||||
mobileMenu?.classList.toggle('hidden');
|
||||
});
|
||||
})();
|
||||
|
||||
// Search
|
||||
(function() {
|
||||
const searchToggle = document.getElementById('search-toggle');
|
||||
const searchModal = document.getElementById('search-modal');
|
||||
const searchBackdrop = document.getElementById('search-backdrop');
|
||||
const searchInput = document.getElementById('search-input');
|
||||
const searchResults = document.getElementById('search-results');
|
||||
const searchCount = document.getElementById('search-count');
|
||||
|
||||
let fuse = null;
|
||||
let searchIndex = null;
|
||||
|
||||
// Load search index
|
||||
async function loadSearchIndex() {
|
||||
if (searchIndex) return searchIndex;
|
||||
|
||||
try {
|
||||
const response = await fetch('/index.json');
|
||||
searchIndex = await response.json();
|
||||
|
||||
fuse = new Fuse(searchIndex, {
|
||||
keys: ['title', 'content', 'tags'],
|
||||
threshold: 0.3,
|
||||
includeMatches: true,
|
||||
});
|
||||
|
||||
return searchIndex;
|
||||
} catch (err) {
|
||||
console.error('Failed to load search index:', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Open search
|
||||
function openSearch() {
|
||||
searchModal?.classList.remove('hidden');
|
||||
document.body.style.overflow = 'hidden';
|
||||
searchInput?.focus();
|
||||
loadSearchIndex();
|
||||
}
|
||||
|
||||
// Close search
|
||||
function closeSearch() {
|
||||
searchModal?.classList.add('hidden');
|
||||
document.body.style.overflow = '';
|
||||
if (searchInput) searchInput.value = '';
|
||||
searchResults!.innerHTML = '<div class="px-4 py-8 text-center text-secondary text-sm">输入关键词开始搜索...</div>';
|
||||
searchCount!.textContent = '0';
|
||||
}
|
||||
|
||||
// Perform search
|
||||
function performSearch(query) {
|
||||
if (!query || !fuse) {
|
||||
searchResults!.innerHTML = '<div class="px-4 py-8 text-center text-secondary text-sm">输入关键词开始搜索...</div>';
|
||||
searchCount!.textContent = '0';
|
||||
return;
|
||||
}
|
||||
|
||||
const results = fuse.search(query);
|
||||
searchCount!.textContent = results.length.toString();
|
||||
|
||||
if (results.length === 0) {
|
||||
searchResults!.innerHTML = '<div class="px-4 py-8 text-center text-secondary text-sm">未找到相关结果</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const html = results.map(result => {
|
||||
const item = result.item;
|
||||
const matches = result.matches || [];
|
||||
|
||||
// Highlight matches in title
|
||||
let title = item.title;
|
||||
matches.filter(m => m.key === 'title').forEach(m => {
|
||||
m.indices.forEach(([start, end]) => {
|
||||
const matched = title.slice(start, end + 1);
|
||||
title = title.slice(0, start) + `<mark class="search-highlight">${matched}</mark>` + title.slice(end + 1);
|
||||
});
|
||||
});
|
||||
|
||||
// Get summary with highlighted content
|
||||
let summary = item.summary || item.content?.slice(0, 150) + '...' || '';
|
||||
matches.filter(m => m.key === 'content').forEach(m => {
|
||||
if (m.indices[0]) {
|
||||
const [start, end] = m.indices[0];
|
||||
const contextStart = Math.max(0, start - 50);
|
||||
const contextEnd = Math.min(item.content.length, end + 50);
|
||||
summary = '...' + item.content.slice(contextStart, contextEnd) + '...';
|
||||
|
||||
m.indices.slice(0, 2).forEach(([s, e]) => {
|
||||
const relativeStart = s - contextStart + 3;
|
||||
const relativeEnd = e - contextStart + 3;
|
||||
if (relativeStart >= 0 && relativeEnd < summary.length) {
|
||||
const matched = summary.slice(relativeStart, relativeEnd + 1);
|
||||
summary = summary.slice(0, relativeStart) + `<mark class="search-highlight">${matched}</mark>` + summary.slice(relativeEnd + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return `
|
||||
<a href="${item.permalink}" class="search-result block">
|
||||
<div class="search-result-title">${title}</div>
|
||||
<div class="search-result-summary">${summary}</div>
|
||||
<div class="text-xs text-tertiary mt-1">${item.date} · ${item.category}</div>
|
||||
</a>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
searchResults!.innerHTML = html;
|
||||
}
|
||||
|
||||
// Event listeners
|
||||
searchToggle?.addEventListener('click', openSearch);
|
||||
searchBackdrop?.addEventListener('click', closeSearch);
|
||||
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
|
||||
e.preventDefault();
|
||||
openSearch();
|
||||
}
|
||||
if (e.key === 'Escape') {
|
||||
closeSearch();
|
||||
}
|
||||
});
|
||||
|
||||
// Debounced search input
|
||||
let debounceTimer;
|
||||
searchInput?.addEventListener('input', (e) => {
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = setTimeout(() => {
|
||||
performSearch(e.target.value.trim());
|
||||
}, 300);
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user