feat: enhance modal image handling and SEO improvements

- Optimized modal image dimensions for better responsiveness
- Ensured modal images maintain aspect ratio and scale appropriately
- Added eager loading for header images to improve initial load performance
- Corrected GitHub link title typo for SEO accuracy
- Enhanced post content handling by normalizing emoji styles and search link paths
- Improved cache key management for channel info requests to include type and ID
- Streamlined channel info fetching logic for efficiency
- Updated breadcrumb image handling to support static proxy and void file fallback
This commit is contained in:
ccbikai
2024-08-05 12:05:19 +08:00
parent 10fe7b3da3
commit bfb8974612
6 changed files with 47 additions and 13 deletions

View File

@@ -55,6 +55,10 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
$(content).find('a').each((_index, a) => {
$(a).attr('title', $(a).text())
})
$(content).find('a[href^="?q="]').each((_index, a) => {
$(a).attr('href', `/search/result${$(a).attr('href')}`)
})
$(content).find('.emoji').attr('style', '')
return {
id,
@@ -89,12 +93,12 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
const unnessaryHeaders = ['host', 'cookie', 'origin', 'referer']
export async function getChannelInfo(Astro, { before = '', after = '', q = '', id = '' } = {}) {
const cacheKey = JSON.stringify({ before, after, q, id })
export async function getChannelInfo(Astro, { before = '', after = '', q = '', type = 'list', id = '' } = {}) {
const cacheKey = JSON.stringify({ before, after, q, type, id })
const cachedResult = cache.get(cacheKey)
if (cachedResult) {
console.info('Macth Cache', { before, after, q, id })
console.info('Macth Cache', { before, after, q, type, id })
return JSON.parse(JSON.stringify(cachedResult))
}
@@ -112,7 +116,7 @@ export async function getChannelInfo(Astro, { before = '', after = '', q = '', i
}
})
console.info('Fetching', url, { before, after, q, id })
console.info('Fetching', url, { before, after, q, type, id })
const html = await $fetch(url, {
headers,
query: {