更换到Astro #9
No files matched your search
+2
-1
@@ -4,9 +4,10 @@ import { unified } from '@astrojs/markdown-remark';
|
|||||||
import rehypeMathjax from 'rehype-mathjax';
|
import rehypeMathjax from 'rehype-mathjax';
|
||||||
import remarkMath from 'remark-math';
|
import remarkMath from 'remark-math';
|
||||||
import remarkHexoLinkCards from './src/lib/remarkHexoLinkCards.mjs';
|
import remarkHexoLinkCards from './src/lib/remarkHexoLinkCards.mjs';
|
||||||
|
import { siteConfig } from './site.config.mjs';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: 'https://blog.biss.click',
|
site: siteConfig.site.url,
|
||||||
output: 'static',
|
output: 'static',
|
||||||
integrations: [sitemap()],
|
integrations: [sitemap()],
|
||||||
markdown: {
|
markdown: {
|
||||||
|
|||||||
@@ -4,28 +4,11 @@
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
// 配置区域 - 请根据实际情况修改
|
// 配置区域 - 请根据实际情况修改
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
const CONFIG = {
|
const CONFIG = window.SITE_CONFIG?.search;
|
||||||
apiKey: "2uxQzk7eD2GBCljdSmIiuU3ause7UK9n", // ⚠️ 建议使用 Search-Only API Key
|
if (!CONFIG) {
|
||||||
server: {
|
console.warn('Typesense 搜索配置未加载');
|
||||||
host: "typesense.biss.click",
|
return;
|
||||||
port: "443",
|
}
|
||||||
protocol: "https"
|
|
||||||
},
|
|
||||||
indexName: "blogs",
|
|
||||||
searchParams: {
|
|
||||||
query_by: "title,content",
|
|
||||||
highlight_full_fields: "title,content",
|
|
||||||
per_page: 8,
|
|
||||||
num_typos: 1,
|
|
||||||
typo_tokens_threshold: 1,
|
|
||||||
prefix: true
|
|
||||||
},
|
|
||||||
ui: {
|
|
||||||
maxRetries: 10,
|
|
||||||
retryDelay: 100,
|
|
||||||
animationDuration: 300
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// 状态管理
|
// 状态管理
|
||||||
@@ -34,7 +17,7 @@
|
|||||||
let isInitialized = false;
|
let isInitialized = false;
|
||||||
let isSearchOpen = false;
|
let isSearchOpen = false;
|
||||||
let initRetryCount = 0;
|
let initRetryCount = 0;
|
||||||
const MAX_INIT_RETRIES = 30; // 最多重试30次 (3秒)
|
const MAX_INIT_RETRIES = CONFIG.ui.maxInitRetries || 30; // 最多重试30次 (3秒)
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// 错误提示函数
|
// 错误提示函数
|
||||||
@@ -326,7 +309,7 @@
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
mask.style.display = 'none';
|
mask.style.display = 'none';
|
||||||
document.body.style.overflow = '';
|
document.body.style.overflow = '';
|
||||||
}, CONFIG.ui.animationDuration);
|
}, CONFIG.ui.animationDuration || 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusSearchInput(retryCount) {
|
function focusSearchInput(retryCount) {
|
||||||
@@ -335,10 +318,10 @@
|
|||||||
if (input) {
|
if (input) {
|
||||||
input.focus();
|
input.focus();
|
||||||
input.select();
|
input.select();
|
||||||
} else if (retryCount < CONFIG.ui.maxRetries) {
|
} else if (retryCount < (CONFIG.ui.maxRetries || 10)) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
focusSearchInput(retryCount + 1);
|
focusSearchInput(retryCount + 1);
|
||||||
}, CONFIG.ui.retryDelay);
|
}, CONFIG.ui.retryDelay || 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +426,7 @@
|
|||||||
searchInstance.addWidgets([
|
searchInstance.addWidgets([
|
||||||
instantsearch.widgets.searchBox({
|
instantsearch.widgets.searchBox({
|
||||||
container: '#searchbox',
|
container: '#searchbox',
|
||||||
placeholder: '输入关键词寻找故事...',
|
placeholder: CONFIG.ui.placeholder || '输入关键词寻找故事...',
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
showReset: true,
|
showReset: true,
|
||||||
showSubmit: false,
|
showSubmit: false,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
function renderTalks() {
|
function renderTalks() {
|
||||||
const talkContainer = document.querySelector('#talk');
|
const talkContainer = document.querySelector('#talk');
|
||||||
if (!talkContainer) return;
|
if (!talkContainer) return;
|
||||||
|
const config = window.SITE_CONFIG?.talks || {};
|
||||||
talkContainer.innerHTML = '';
|
talkContainer.innerHTML = '';
|
||||||
const generateIconSVG = () => {
|
const generateIconSVG = () => {
|
||||||
return `<svg viewBox="0 0 512 512"xmlns="http://www.w3.org/2000/svg"class="is-badge icon"><path d="m512 268c0 17.9-4.3 34.5-12.9 49.7s-20.1 27.1-34.6 35.4c.4 2.7.6 6.9.6 12.6 0 27.1-9.1 50.1-27.1 69.1-18.1 19.1-39.9 28.6-65.4 28.6-11.4 0-22.3-2.1-32.6-6.3-8 16.4-19.5 29.6-34.6 39.7-15 10.2-31.5 15.2-49.4 15.2-18.3 0-34.9-4.9-49.7-14.9-14.9-9.9-26.3-23.2-34.3-40-10.3 4.2-21.1 6.3-32.6 6.3-25.5 0-47.4-9.5-65.7-28.6-18.3-19-27.4-42.1-27.4-69.1 0-3 .4-7.2 1.1-12.6-14.5-8.4-26-20.2-34.6-35.4-8.5-15.2-12.8-31.8-12.8-49.7 0-19 4.8-36.5 14.3-52.3s22.3-27.5 38.3-35.1c-4.2-11.4-6.3-22.9-6.3-34.3 0-27 9.1-50.1 27.4-69.1s40.2-28.6 65.7-28.6c11.4 0 22.3 2.1 32.6 6.3 8-16.4 19.5-29.6 34.6-39.7 15-10.1 31.5-15.2 49.4-15.2s34.4 5.1 49.4 15.1c15 10.1 26.6 23.3 34.6 39.7 10.3-4.2 21.1-6.3 32.6-6.3 25.5 0 47.3 9.5 65.4 28.6s27.1 42.1 27.1 69.1c0 12.6-1.9 24-5.7 34.3 16 7.6 28.8 19.3 38.3 35.1 9.5 15.9 14.3 33.4 14.3 52.4zm-266.9 77.1 105.7-158.3c2.7-4.2 3.5-8.8 2.6-13.7-1-4.9-3.5-8.8-7.7-11.4-4.2-2.7-8.8-3.6-13.7-2.9-5 .8-9 3.2-12 7.4l-93.1 140-42.9-42.8c-3.8-3.8-8.2-5.6-13.1-5.4-5 .2-9.3 2-13.1 5.4-3.4 3.4-5.1 7.7-5.1 12.9 0 5.1 1.7 9.4 5.1 12.9l58.9 58.9 2.9 2.3c3.4 2.3 6.9 3.4 10.3 3.4 6.7-.1 11.8-2.9 15.2-8.7z"fill="#1da1f2"></path></svg>`;
|
return `<svg viewBox="0 0 512 512"xmlns="http://www.w3.org/2000/svg"class="is-badge icon"><path d="m512 268c0 17.9-4.3 34.5-12.9 49.7s-20.1 27.1-34.6 35.4c.4 2.7.6 6.9.6 12.6 0 27.1-9.1 50.1-27.1 69.1-18.1 19.1-39.9 28.6-65.4 28.6-11.4 0-22.3-2.1-32.6-6.3-8 16.4-19.5 29.6-34.6 39.7-15 10.2-31.5 15.2-49.4 15.2-18.3 0-34.9-4.9-49.7-14.9-14.9-9.9-26.3-23.2-34.3-40-10.3 4.2-21.1 6.3-32.6 6.3-25.5 0-47.4-9.5-65.7-28.6-18.3-19-27.4-42.1-27.4-69.1 0-3 .4-7.2 1.1-12.6-14.5-8.4-26-20.2-34.6-35.4-8.5-15.2-12.8-31.8-12.8-49.7 0-19 4.8-36.5 14.3-52.3s22.3-27.5 38.3-35.1c-4.2-11.4-6.3-22.9-6.3-34.3 0-27 9.1-50.1 27.4-69.1s40.2-28.6 65.7-28.6c11.4 0 22.3 2.1 32.6 6.3 8-16.4 19.5-29.6 34.6-39.7 15-10.1 31.5-15.2 49.4-15.2s34.4 5.1 49.4 15.1c15 10.1 26.6 23.3 34.6 39.7 10.3-4.2 21.1-6.3 32.6-6.3 25.5 0 47.3 9.5 65.4 28.6s27.1 42.1 27.1 69.1c0 12.6-1.9 24-5.7 34.3 16 7.6 28.8 19.3 38.3 35.1 9.5 15.9 14.3 33.4 14.3 52.4zm-266.9 77.1 105.7-158.3c2.7-4.2 3.5-8.8 2.6-13.7-1-4.9-3.5-8.8-7.7-11.4-4.2-2.7-8.8-3.6-13.7-2.9-5 .8-9 3.2-12 7.4l-93.1 140-42.9-42.8c-3.8-3.8-8.2-5.6-13.1-5.4-5 .2-9.3 2-13.1 5.4-3.4 3.4-5.1 7.7-5.1 12.9 0 5.1 1.7 9.4 5.1 12.9l58.9 58.9 2.9 2.3c3.4 2.3 6.9 3.4 10.3 3.4 6.7-.1 11.8-2.9 15.2-8.7z"fill="#1da1f2"></path></svg>`;
|
||||||
@@ -76,10 +77,11 @@ function renderTalks() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchAndRenderTalks = () => {
|
const fetchAndRenderTalks = () => {
|
||||||
const url = 'https://mm.biss.click/api/echo/page';
|
const url = config.apiUrl;
|
||||||
const cacheKey = 'talksCache';
|
if (!url) return;
|
||||||
const cacheTimeKey = 'talksCacheTime';
|
const cacheKey = config.cacheKey || 'talksCache';
|
||||||
const cacheDuration = 30 * 60 * 1000;
|
const cacheTimeKey = config.cacheTimeKey || 'talksCacheTime';
|
||||||
|
const cacheDuration = config.cacheDurationMs || 30 * 60 * 1000;
|
||||||
const cachedData = localStorage.getItem(cacheKey);
|
const cachedData = localStorage.getItem(cacheKey);
|
||||||
const cachedTime = localStorage.getItem(cacheTimeKey);
|
const cachedTime = localStorage.getItem(cacheTimeKey);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@@ -90,7 +92,7 @@ function renderTalks() {
|
|||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ page: 1, pageSize: 30 })
|
body: JSON.stringify({ page: 1, pageSize: config.pageSize || 30 })
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -263,7 +265,7 @@ function renderTalks() {
|
|||||||
return {
|
return {
|
||||||
content,
|
content,
|
||||||
user: item.username || '匿名',
|
user: item.username || '匿名',
|
||||||
avatar: 'https://free.picui.cn/free/2025/08/10/689845496a283.png',
|
avatar: config.fallbackAvatar || window.SITE_CONFIG?.author?.avatar || '',
|
||||||
date,
|
date,
|
||||||
location: '',
|
location: '',
|
||||||
tags: Array.isArray(item.tags) && item.tags.length ? item.tags.map(t => t.name) : ['无标签'],
|
tags: Array.isArray(item.tags) && item.tags.length ? item.tags.map(t => t.name) : ['无标签'],
|
||||||
|
|||||||
Loaded 3 of 23 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user