minor fixes

This commit is contained in:
haetae 2025-11-25 17:26:36 -05:00
parent ef688a21b7
commit bd2c535cee
5 changed files with 26 additions and 27 deletions

View File

@ -1,9 +1,13 @@
*, *::before, *::after { box-sizing: border-box; } *, *::before, *::after { box-sizing: border-box; }
* { margin: 0; } * { margin: 0; }
html, body { body {
height: 100vh;
width: 100vw; width: 100vw;
min-height: 100vh;
@supports (min-height: 100svh) {
min-height: 100svh;
}
} }
body { line-height: calc(1em + 0.5rem); } body { line-height: calc(1em + 0.5rem); }
@ -15,5 +19,5 @@ img, picture, video, canvas, svg {
input, button, textarea, select { font: inherit; } input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; } p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
p { text-wrap: pretty; } h1, h2, h3, h4, h5, h6 { text-wrap: balance; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; } p { text-wrap: pretty; }

View File

@ -40,7 +40,7 @@ const links = [
title={chapter.data.title} title={chapter.data.title}
ficTitle={fic[0].data.title} ficTitle={fic[0].data.title}
date={chapter.data.publishedAt} date={chapter.data.publishedAt}
{lastModified} {lastModified}
notes={chapter.data.notes} notes={chapter.data.notes}
> >
<Fragment slot="breadcrumbs"> <Fragment slot="breadcrumbs">
@ -53,19 +53,20 @@ const links = [
{chapters.length > 1 && ( {chapters.length > 1 && (
<nav id="chapter-pagination" slot="pagination"> <nav id="chapter-pagination" slot="pagination">
<div id="chapter-index"> <form id="chapter-index">
<label for="chapter-select">Chapters:</label> <label for="chapter-select">Chapters:</label>
<select name="chapter-select" id="chapter-select"> <select name="chapter-select" id="chapter-select">
{chapters.map(chapter => ( {chapters.map(chapter => (
<option <option
value={`/fics/${chapter.id}`} value={`/fics/${chapter.id}`}
selected={chapter.id.split("/")[1] === chapterId ? "selected" : undefined} selected={chapter.id.split("/")[1] === chapterId ? true : undefined}
> >
{chapter.data.title} {chapter.data.title}
</option> </option>
))} ))}
</select> </select>
</div> <button>Go to chapter</button>
</form>
{previous && <a id="previous" href={`/fics/${previous.id}`}>{previous.data.title}</a>} {previous && <a id="previous" href={`/fics/${previous.id}`}>{previous.data.title}</a>}
{next && <a id="next" href={`/fics/${next.id}`}>{next.data.title}</a>} {next && <a id="next" href={`/fics/${next.id}`}>{next.data.title}</a>}
</nav> </nav>
@ -104,7 +105,7 @@ const links = [
#chapter-index { #chapter-index {
grid-area: 1 / 1 / 1 / -1; grid-area: 1 / 1 / 1 / -1;
width: min-content; /* width: min-content; */
justify-self: center; justify-self: center;
} }
@ -130,10 +131,10 @@ const links = [
</style> </style>
<script> <script>
const form = document.forms.namedItem("chapter-index");
const select: HTMLSelectElement | null = document.querySelector("#chapter-select"); const select: HTMLSelectElement | null = document.querySelector("#chapter-select");
select?.addEventListener("change", (e) => { form?.addEventListener("submit", (e) => {
if (e.target instanceof HTMLSelectElement) { e.preventDefault();
window.location.href = e.target.value; window.location.href = select?.value!;
}
}); });
</script> </script>

View File

@ -24,7 +24,7 @@ const { Content } = await render(fic);
const parser = marked.use({ gfm: true, breaks: true }); const parser = marked.use({ gfm: true, breaks: true });
const summary = await parser.parse(fic.data.summary); const summary = await parser.parse(fic.data.summary);
const lastMod = fic.rendered && (fic.rendered.metadata!.frontmatter as any)['lastModified']; const lastModified = fic.rendered && (fic.rendered.metadata!.frontmatter as any)['lastModified'];
const notes = fic.rendered && await parser.parse((fic.rendered.metadata!.frontmatter as any)["notes"]); const notes = fic.rendered && await parser.parse((fic.rendered.metadata!.frontmatter as any)["notes"]);
--- ---
<Layout title={fic.data.title}> <Layout title={fic.data.title}>
@ -78,7 +78,7 @@ const notes = fic.rendered && await parser.parse((fic.rendered.metadata!.frontma
{fic.body && ( {fic.body && (
<section id="oneshot"> <section id="oneshot">
<ChapterContent lastModified={lastMod} notes={notes}> <ChapterContent lastModified={lastModified} notes={notes}>
<Content /> <Content />
</ChapterContent> </ChapterContent>
</section> </section>

View File

@ -18,7 +18,7 @@ export const GET: APIRoute = async (context) => {
for (const entry of chapters) { for (const entry of chapters) {
const { Content } = await render(entry); const { Content } = await render(entry);
const content = await container.renderToString(Content); const content = await container.renderToString(Content);
feed.push({ feed.push({
link: `/fics/${entry.id}`, link: `/fics/${entry.id}`,
title: entry.data.title, title: entry.data.title,

View File

@ -1,15 +1,9 @@
import { statSync } from "fs"; import { execSync } from "child_process";
export function modifiedTime() { export function modifiedTime() {
return function (_tree, file) { return function (_tree, { data, history }) {
const path = file.history[0]; const path = history[0];
const result = statSync(path); const result = execSync(`git log -1 --pretty="format:%cI" "${path}"`);
file.data.astro.frontmatter.lastModified = result.mtime; data.astro.frontmatter.lastModified = result.toString();
// try {
// const result = statSync(path);
// file.data.astro.frontmatter.lastModified = result.mtime;
// } catch (error) {
// return;
// }
} }
} }