AI: address issue #483
このコミットが含まれているのは:
@@ -0,0 +1,7 @@
|
||||
:root { color-scheme: light dark; }
|
||||
body { max-width: 65rem; margin: auto; padding: 1rem; font: 1rem/1.6 sans-serif; }
|
||||
header { border-bottom: 1px solid; padding-bottom: 1rem; }
|
||||
nav { display: flex; flex-wrap: wrap; gap: 1rem; }
|
||||
a, p, li { overflow-wrap: anywhere; }
|
||||
li { margin-block: .4rem; }
|
||||
input, button { font: inherit; }
|
||||
@@ -0,0 +1,61 @@
|
||||
(() => {
|
||||
const root = new URL ('../', document.currentScript.src)
|
||||
const origin = window.archiveConfig?.origin
|
||||
if (typeof origin === 'string')
|
||||
{
|
||||
try
|
||||
{
|
||||
const url = new URL (origin)
|
||||
if (['http:', 'https:'].includes (url.protocol) && !url.username && !url.password)
|
||||
{
|
||||
url.search = ''
|
||||
url.hash = ''
|
||||
document.querySelectorAll ('[data-original]').forEach (link => {
|
||||
link.href = url.href.replace (/\/+$/, '') + link.dataset.original
|
||||
})
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Each HTML retains its original link when configuration is absent or invalid.
|
||||
}
|
||||
}
|
||||
const form = document.getElementById ('archive-search')
|
||||
const results = document.getElementById ('search-results')
|
||||
if (!form || !results) return
|
||||
form.addEventListener ('submit', async event => {
|
||||
event.preventDefault ()
|
||||
results.replaceChildren ()
|
||||
const query = (new FormData (form).get ('q') ?? '').toString ().toLocaleLowerCase ()
|
||||
if (!query.trim ()) return
|
||||
try
|
||||
{
|
||||
const response = await fetch (new URL ('search-index.json', root))
|
||||
if (!response.ok) throw new Error ('Search index unavailable')
|
||||
const entries = await response.json ()
|
||||
for (const entry of entries)
|
||||
{
|
||||
const text = [entry.title, ...(entry.names ?? [])].join (' ').toLocaleLowerCase ()
|
||||
if (!text.includes (query)) continue
|
||||
const url = new URL (entry.path, root)
|
||||
if (url.origin !== root.origin || !url.pathname.startsWith (root.pathname)) continue
|
||||
const item = document.createElement ('li')
|
||||
const link = document.createElement ('a')
|
||||
link.setAttribute ('href', entry.path)
|
||||
link.textContent = entry.title
|
||||
item.append (link)
|
||||
results.append (item)
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Lists remain available if the index cannot be loaded.
|
||||
for (const link of document.querySelectorAll ('nav a:not([data-original])'))
|
||||
{
|
||||
const item = document.createElement ('li')
|
||||
item.append (link.cloneNode (true))
|
||||
results.append (item)
|
||||
}
|
||||
}
|
||||
})
|
||||
})()
|
||||
@@ -0,0 +1,28 @@
|
||||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<meta http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; form-action 'none'; base-uri 'none'">
|
||||
<title><%= h(@title) %></title>
|
||||
<link rel="stylesheet" href="<%= h(relative('assets/archive.css')) %>">
|
||||
<script defer src="<%= h(relative('archive-config.js')) %>"></script>
|
||||
<script defer src="<%= h(relative('assets/archive.js')) %>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<p>静的保存版 — データ基準時点: <time><%= h(data_at) %></time></p>
|
||||
<nav>
|
||||
<a href="<%= h(relative('index.html')) %>">Static Mirror 生成機能</a>
|
||||
<a href="<%= h(relative("#{ @locale.code }/posts/index.html")) %>">Post</a>
|
||||
<a href="<%= h(relative("#{ @locale.code }/tags/index.html")) %>">Tag</a>
|
||||
<a href="<%= h(@origin + @original_path) %>" data-original="<%= h(@original_path) %>"
|
||||
target="_blank" rel="noopener noreferrer">本家へのリンク</a>
|
||||
</nav>
|
||||
</header>
|
||||
<main><h1><%= h(@title) %></h1><%= linked_content %></main>
|
||||
</body>
|
||||
</html>
|
||||
新しいイシューから参照
ユーザーをブロックする