test ai-blog

This commit is contained in:
2025-07-15 17:32:20 +09:00
parent 75f108e7b8
commit 0110773592
73 changed files with 9000 additions and 30 deletions

View File

@@ -0,0 +1,33 @@
import { useState, useEffect } from 'react'
export function usePageContext() {
const [pageContext, setPageContext] = useState({
isTopPage: true,
rkey: null,
url: null
})
useEffect(() => {
const pathname = window.location.pathname
const url = window.location.href
// Extract rkey from URL pattern: /posts/xxx or /posts/xxx.html
const match = pathname.match(/\/posts\/([^/]+)\/?$/)
if (match) {
const rkey = match[1].replace(/\.html$/, '')
setPageContext({
isTopPage: false,
rkey,
url
})
} else {
setPageContext({
isTopPage: true,
rkey: null,
url
})
}
}, [])
return pageContext
}