refact update
This commit is contained in:
@@ -2,7 +2,9 @@ import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { marked, Renderer } from 'marked'
|
||||
import type { AppConfig, Profile, BlogPost, Networks } from '../src/types.ts'
|
||||
import { escapeHtml } from '../src/lib/utils.ts'
|
||||
import { escapeHtml, formatDate } from '../src/lib/utils.ts'
|
||||
import { LANG_ICON, BUILTIN_ICONS } from '../src/lib/icons.ts'
|
||||
import { MAX_SEARCH_LENGTH } from '../src/lib/constants.ts'
|
||||
|
||||
// Highlight.js for syntax highlighting (core + common languages only)
|
||||
let hljs: typeof import('highlight.js/lib/core').default
|
||||
@@ -70,15 +72,6 @@ function setupMarked() {
|
||||
})
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string): string {
|
||||
const date = new Date(dateStr)
|
||||
return date.toLocaleDateString('ja-JP', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
})
|
||||
}
|
||||
|
||||
// API functions
|
||||
async function resolveHandle(handle: string, bskyUrl: string): Promise<string> {
|
||||
const res = await fetch(`${bskyUrl}/xrpc/com.atproto.identity.resolveHandle?handle=${handle}`)
|
||||
@@ -396,12 +389,10 @@ function generateTabsHtml(activeTab: 'blog' | 'browser', handle: string): string
|
||||
}
|
||||
|
||||
function generateLangSelectorHtml(): string {
|
||||
const langIcon = `<svg viewBox="0 0 640 640" width="20" height="20" fill="currentColor"><path d="M192 64C209.7 64 224 78.3 224 96L224 128L352 128C369.7 128 384 142.3 384 160C384 177.7 369.7 192 352 192L342.4 192L334 215.1C317.6 260.3 292.9 301.6 261.8 337.1C276 345.9 290.8 353.7 306.2 360.6L356.6 383L418.8 243C423.9 231.4 435.4 224 448 224C460.6 224 472.1 231.4 477.2 243L605.2 531C612.4 547.2 605.1 566.1 589 573.2C572.9 580.3 553.9 573.1 546.8 557L526.8 512L369.3 512L349.3 557C342.1 573.2 323.2 580.4 307.1 573.2C291 566 283.7 547.1 290.9 531L330.7 441.5L280.3 419.1C257.3 408.9 235.3 396.7 214.5 382.7C193.2 399.9 169.9 414.9 145 427.4L110.3 444.6C94.5 452.5 75.3 446.1 67.4 430.3C59.5 414.5 65.9 395.3 81.7 387.4L116.2 370.1C132.5 361.9 148 352.4 162.6 341.8C148.8 329.1 135.8 315.4 123.7 300.9L113.6 288.7C102.3 275.1 104.1 254.9 117.7 243.6C131.3 232.3 151.5 234.1 162.8 247.7L173 259.9C184.5 273.8 197.1 286.7 210.4 298.6C237.9 268.2 259.6 232.5 273.9 193.2L274.4 192L64.1 192C46.3 192 32 177.7 32 160C32 142.3 46.3 128 64 128L160 128L160 96C160 78.3 174.3 64 192 64zM448 334.8L397.7 448L498.3 448L448 334.8z"/></svg>`
|
||||
|
||||
return `
|
||||
<div class="lang-selector" id="lang-selector">
|
||||
<button type="button" class="lang-btn" id="lang-btn" title="Language">
|
||||
${langIcon}
|
||||
${LANG_ICON}
|
||||
</button>
|
||||
<div class="lang-dropdown" id="lang-dropdown">
|
||||
<div class="lang-option" data-lang="ja">
|
||||
@@ -484,8 +475,6 @@ function generatePostDetailHtml(post: BlogPost, handle: string, collection: stri
|
||||
const postUrl = `${baseSiteUrl}/post/${rkey}/`
|
||||
const appUrl = getAppUrl(network)
|
||||
// Convert to search-friendly format (domain/post/rkey_prefix without https://)
|
||||
// Keep total length around 20 chars to avoid URL truncation in posts
|
||||
const MAX_SEARCH_LENGTH = 20
|
||||
const urlObj = new URL(postUrl)
|
||||
const pathParts = urlObj.pathname.split('/').filter(Boolean)
|
||||
const basePath = urlObj.host + '/' + (pathParts[0] || '') + '/'
|
||||
@@ -550,14 +539,6 @@ function loadLinks(): FooterLink[] {
|
||||
}
|
||||
}
|
||||
|
||||
// Built-in SVG icons for common services
|
||||
const BUILTIN_ICONS: Record<string, string> = {
|
||||
bluesky: `<svg viewBox="0 0 600 530" fill="currentColor"><path d="m135.72 44.03c66.496 49.921 138.02 151.14 164.28 205.46 26.262-54.316 97.782-155.54 164.28-205.46 47.98-36.021 125.72-63.892 125.72 24.795 0 17.712-10.155 148.79-16.111 170.07-20.703 73.984-96.144 92.854-163.25 81.433 117.3 19.964 147.14 86.092 82.697 152.22-122.39 125.59-175.91-31.511-189.63-71.766-2.514-7.3797-3.6904-10.832-3.7077-7.8964-0.0174-2.9357-1.1937 0.51669-3.7077 7.8964-13.72 40.255-67.24 197.36-189.63 71.766-64.444-66.128-34.605-132.26 82.697-152.22-67.108 11.421-142.55-7.4491-163.25-81.433-5.9562-21.282-16.111-152.36-16.111-170.07 0-88.687 77.742-60.816 125.72-24.795z"/></svg>`,
|
||||
github: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>`,
|
||||
ai: `<span class="icon-ai"></span>`,
|
||||
git: `<span class="icon-git"></span>`,
|
||||
}
|
||||
|
||||
function generateFooterLinksHtml(links: FooterLink[]): string {
|
||||
if (links.length === 0) return ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user