Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason0729 committed Dec 29, 2024
2 parents 560a2bb + a655207 commit 056334c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
7 changes: 2 additions & 5 deletions components/novel/NovelList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Partial } from "$fresh/runtime.ts";
import { Article, State as ArticleState } from "../../entity/article.ts";
import StartButton from "../../islands/StartButton.tsx";
import ScrollView from "../../islands/ScrollView.tsx";

function extractNumber(str: string): number[] {
const digitPattern = /[-0-9]+/g;
Expand Down Expand Up @@ -78,7 +77,7 @@ function longestIncreasingSubsequence(sec: number[]): number[] {
}

export default function NovelList(
{ articles, focus }: { articles: Article[]; focus?: boolean },
{ articles }: { articles: Article[] },
) {
articles.sort((a, b) => (a.index as number) - (b.index as number));

Expand All @@ -88,7 +87,7 @@ export default function NovelList(
const addIndex = longestIncreasingSubsequence(numberSeq).length * 1.5 <
Math.max(numberSeq.length, articles.length);

const list = articles.map((article, sec) => {
const list = articles.map((article) => {
let state;
switch (article.state as ArticleState) {
case "unfetch":
Expand All @@ -108,7 +107,6 @@ export default function NovelList(
key={`frag-novel-list-${index}`}
class="block p-3 rounded-lg bg-blue-500 hover:bg-blue-600 dark:bg-slate-200 text-white dark:text-black shadow transition duration-300"
>
{(sec === 0 && focus) && <ScrollView />}
<div class="flex justify-between items-center tracking-tight text-2xl px-2 overflow-hidden">
<a
href={"/article/" + article.id}
Expand All @@ -134,4 +132,3 @@ export default function NovelList(
</ul>
);
}
// flex justify-between items-center font-semibold tracking-tight text-2xl mb-2
15 changes: 12 additions & 3 deletions components/novel/NovelLoad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ export default function NovelLoad({ page, novelId }: {
return (
<Partial name="novel-load">
<div class="mt-6 text-center">
<a
<noscript>
<a
href={`/novel/${novelId}/${page + 1}`}
f-partial={`/partial/novel/${novelId}/${page + 1}`}
class="text-xl px-12 py-3 bg-blue-500 hover:bg-blue-600 dark:bg-slate-200 disabled:hidden text-white dark:text-black font-semibold rounded-lg shadow transition duration-300"
>
Load More
</a>
</noscript>
<button
href={`/novel/${novelId}/${page + 1}`}
f-partial={`/partial/novel/${novelId}/${page + 1}`}
class="text-xl px-12 py-3 bg-blue-500 hover:bg-blue-600 dark:bg-slate-200 disabled:hidden text-white dark:text-black font-semibold rounded-lg shadow transition duration-300"
class="jsonly text-xl px-12 py-3 bg-blue-500 hover:bg-blue-600 dark:bg-slate-200 disabled:hidden text-white dark:text-black font-semibold rounded-lg shadow transition duration-300"
>
Load More
</a>
</button>
</div>
</Partial>
);
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --unstable-ffi --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
"build": "deno run -A --unstable-ffi dev.ts build",
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update .",
"test": "deno test -A"
Expand Down
2 changes: 0 additions & 2 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as $novel_id_page_ from "./routes/novel/[id]/[[page]].tsx";
import * as $partial_novel_id_page_ from "./routes/partial/novel/[id]/[page].tsx";
import * as $unsupported from "./routes/unsupported.tsx";
import * as $HistoryEntry from "./islands/HistoryEntry.tsx";
import * as $ScrollView from "./islands/ScrollView.tsx";
import * as $StartButton from "./islands/StartButton.tsx";
import type { Manifest } from "$fresh/server.ts";

Expand All @@ -32,7 +31,6 @@ const manifest = {
},
islands: {
"./islands/HistoryEntry.tsx": $HistoryEntry,
"./islands/ScrollView.tsx": $ScrollView,
"./islands/StartButton.tsx": $StartButton,
},
baseUrl: import.meta.url,
Expand Down
13 changes: 0 additions & 13 deletions islands/ScrollView.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion routes/partial/novel/[id]/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function NovelPage(_: Request, ctx: RouteContext) {

return (
<>
<NovelList articles={articles} focus />
<NovelList articles={articles} />
{(articles.length < pageSize)
? <Partial name="novel-load" />
: <NovelLoad novelId={novelId} page={pageNumber} />}
Expand Down

0 comments on commit 056334c

Please sign in to comment.