mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-12 07:12:52 +01:00
fix: fix errors and reformat code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { Icon } from 'astro-icon/components';
|
||||
import { Icon } from 'astro-icon/components'
|
||||
---
|
||||
|
||||
<!-- There can't be a filter on parent element, or it will break `fixed` -->
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
interface Props {
|
||||
badge?: string
|
||||
url?: string
|
||||
label?: string
|
||||
badge?: string
|
||||
url?: string
|
||||
label?: string
|
||||
}
|
||||
const { badge, url, label } = Astro.props
|
||||
---
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
interface Props {
|
||||
size?: string;
|
||||
dot?: boolean;
|
||||
href?: string;
|
||||
label?: string;
|
||||
size?: string
|
||||
dot?: boolean
|
||||
href?: string
|
||||
label?: string
|
||||
}
|
||||
const { size, dot, href, label }: Props = Astro.props;
|
||||
const { size, dot, href, label }: Props = Astro.props
|
||||
---
|
||||
<a href={href} aria-label={label} class="btn-regular h-8 text-sm px-3 rounded-lg">
|
||||
{dot && <div class="h-1 w-1 bg-[var(--btn-content)] dark:bg-[var(--card-bg)] transition rounded-md mr-2"></div>}
|
||||
|
||||
@@ -1,61 +1,53 @@
|
||||
---
|
||||
import type { Page } from "astro";
|
||||
import { Icon } from 'astro-icon/components';
|
||||
import {url} from "../../utils/url-utils";
|
||||
import type { Page } from 'astro'
|
||||
import { Icon } from 'astro-icon/components'
|
||||
import { url } from '../../utils/url-utils'
|
||||
interface Props {
|
||||
page: Page;
|
||||
class?: string;
|
||||
style?: string;
|
||||
page: Page
|
||||
class?: string
|
||||
style?: string
|
||||
}
|
||||
|
||||
const {page, style} = Astro.props;
|
||||
const { page, style } = Astro.props
|
||||
|
||||
const HIDDEN = -1;
|
||||
const HIDDEN = -1
|
||||
|
||||
const className = Astro.props.class;
|
||||
const className = Astro.props.class
|
||||
|
||||
const ADJ_DIST = 2;
|
||||
const VISIBLE = ADJ_DIST * 2 + 1;
|
||||
const ADJ_DIST = 2
|
||||
const VISIBLE = ADJ_DIST * 2 + 1
|
||||
|
||||
// for test
|
||||
let count = 1;
|
||||
let l = page.currentPage, r = page.currentPage;
|
||||
let count = 1
|
||||
let l = page.currentPage,
|
||||
r = page.currentPage
|
||||
while (0 < l - 1 && r + 1 <= page.lastPage && count + 2 <= VISIBLE) {
|
||||
count += 2;
|
||||
l--;
|
||||
r++;
|
||||
count += 2
|
||||
l--
|
||||
r++
|
||||
}
|
||||
while (0 < l - 1 && count < VISIBLE) {
|
||||
count++;
|
||||
l--;
|
||||
count++
|
||||
l--
|
||||
}
|
||||
while (r + 1 <= page.lastPage && count < VISIBLE) {
|
||||
count++;
|
||||
r++;
|
||||
count++
|
||||
r++
|
||||
}
|
||||
|
||||
let pages: number[] = [];
|
||||
if (l > 1)
|
||||
pages.push(1);
|
||||
if (l == 3)
|
||||
pages.push(2);
|
||||
if (l > 3)
|
||||
pages.push(HIDDEN);
|
||||
for (let i = l; i <= r; i++)
|
||||
pages.push(i);
|
||||
if (r < page.lastPage - 2)
|
||||
pages.push(HIDDEN);
|
||||
if (r == page.lastPage - 2)
|
||||
pages.push(page.lastPage - 1);
|
||||
if (r < page.lastPage)
|
||||
pages.push(page.lastPage);
|
||||
let pages: number[] = []
|
||||
if (l > 1) pages.push(1)
|
||||
if (l == 3) pages.push(2)
|
||||
if (l > 3) pages.push(HIDDEN)
|
||||
for (let i = l; i <= r; i++) pages.push(i)
|
||||
if (r < page.lastPage - 2) pages.push(HIDDEN)
|
||||
if (r == page.lastPage - 2) pages.push(page.lastPage - 1)
|
||||
if (r < page.lastPage) pages.push(page.lastPage)
|
||||
|
||||
const getPageUrl = (p: number) => {
|
||||
if (p == 1)
|
||||
return '/';
|
||||
return `/${p}/`;
|
||||
if (p == 1) return '/'
|
||||
return `/${p}/`
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<div class:list={[className, "flex flex-row gap-3 justify-center"]} style={style}>
|
||||
|
||||
Reference in New Issue
Block a user