Compare commits
2 Commits
e573a9c5a5
...
e442ccc926
| Author | SHA1 | Date | |
|---|---|---|---|
|
e442ccc926
|
|||
|
3b2c7435f3
|
@@ -4,6 +4,5 @@
|
|||||||
"collection": "ai.syui.log.post",
|
"collection": "ai.syui.log.post",
|
||||||
"network": "bsky.social",
|
"network": "bsky.social",
|
||||||
"color": "#EF454A",
|
"color": "#EF454A",
|
||||||
"siteUrl": "https://syui.github.io",
|
"siteUrl": "https://syui.github.io"
|
||||||
"oauth": false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
import { isLoggedIn, getLoggedInHandle } from '../lib/auth'
|
import { isLoggedIn, getLoggedInHandle } from '../lib/auth'
|
||||||
|
|
||||||
export function renderHeader(currentHandle: string, oauth: boolean = true): string {
|
export function renderHeader(currentHandle: string): string {
|
||||||
const loggedIn = isLoggedIn()
|
const loggedIn = isLoggedIn()
|
||||||
const handle = getLoggedInHandle()
|
const handle = getLoggedInHandle()
|
||||||
|
|
||||||
let loginBtn = ''
|
const loginBtn = loggedIn
|
||||||
if (oauth) {
|
|
||||||
loginBtn = loggedIn
|
|
||||||
? `<button type="button" class="header-btn user-btn" id="logout-btn" title="Logout">${handle || 'logout'}</button>`
|
? `<button type="button" class="header-btn user-btn" id="logout-btn" title="Logout">${handle || 'logout'}</button>`
|
||||||
: `<button type="button" class="header-btn login-btn" id="login-btn" title="Login"><img src="/icon/user.svg" alt="Login" class="login-icon"></button>`
|
: `<button type="button" class="header-btn login-btn" id="login-btn" title="Login"><img src="/icon/user.svg" alt="Login" class="login-icon"></button>`
|
||||||
}
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<header id="header">
|
<header id="header">
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ async function render(route: Route): Promise<void> {
|
|||||||
document.title = config.title
|
document.title = config.title
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check OAuth enabled
|
|
||||||
const oauthEnabled = config.oauth !== false
|
|
||||||
|
|
||||||
// Handle OAuth callback if present (check both ? and #)
|
// Handle OAuth callback if present (check both ? and #)
|
||||||
const searchParams = new URLSearchParams(window.location.search)
|
const searchParams = new URLSearchParams(window.location.search)
|
||||||
const hashParams = window.location.hash ? new URLSearchParams(window.location.hash.slice(1)) : null
|
const hashParams = window.location.hash ? new URLSearchParams(window.location.hash.slice(1)) : null
|
||||||
@@ -111,7 +108,7 @@ async function render(route: Route): Promise<void> {
|
|||||||
|
|
||||||
if (!did) {
|
if (!did) {
|
||||||
app.innerHTML = `
|
app.innerHTML = `
|
||||||
${renderHeader(handle, oauthEnabled)}
|
${renderHeader(handle)}
|
||||||
<div class="error">Could not resolve handle: ${handle}</div>
|
<div class="error">Could not resolve handle: ${handle}</div>
|
||||||
${renderFooter(handle)}
|
${renderFooter(handle)}
|
||||||
`
|
`
|
||||||
@@ -142,7 +139,7 @@ async function render(route: Route): Promise<void> {
|
|||||||
const langList = Array.from(availableLangs)
|
const langList = Array.from(availableLangs)
|
||||||
|
|
||||||
// Build page
|
// Build page
|
||||||
let html = renderHeader(handle, oauthEnabled)
|
let html = renderHeader(handle)
|
||||||
|
|
||||||
// Mode tabs (Blog/Browser/Post/PDS)
|
// Mode tabs (Blog/Browser/Post/PDS)
|
||||||
const activeTab = route.type === 'postpage' ? 'post' :
|
const activeTab = route.type === 'postpage' ? 'post' :
|
||||||
@@ -267,7 +264,7 @@ async function render(route: Route): Promise<void> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Render error:', error)
|
console.error('Render error:', error)
|
||||||
app.innerHTML = `
|
app.innerHTML = `
|
||||||
${renderHeader(currentHandle, false)}
|
${renderHeader(currentHandle)}
|
||||||
<div class="error">Error: ${error}</div>
|
<div class="error">Error: ${error}</div>
|
||||||
${renderFooter(currentHandle)}
|
${renderFooter(currentHandle)}
|
||||||
`
|
`
|
||||||
|
|||||||
Reference in New Issue
Block a user