mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-12 07:12:52 +01:00
format all code (#386)
This commit is contained in:
committed by
GitHub
parent
7ea2f7f40f
commit
286b050fa8
@@ -1,53 +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
|
||||
let r = page.currentPage
|
||||
let count = 1;
|
||||
let l = page.currentPage;
|
||||
let 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