Skip to content

Commit

Permalink
chore: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Vulwsztyn committed Jan 21, 2025
1 parent 8287e42 commit 41e4333
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/components/PostCard.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import path from 'path'
import path from 'node:path'
import PostMetadata from './PostMeta.astro'
import ImageWrapper from './misc/ImageWrapper.astro'
import { Icon } from 'astro-icon/components'
Expand All @@ -9,6 +9,7 @@ import { getDir } from '../utils/url-utils'
interface Props {
class?: string
// biome-ignore lint/suspicious/noExplicitAny: no idea what type it will be
entry: any
title: string
url: string
Expand Down
12 changes: 6 additions & 6 deletions src/components/control/Pagination.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const VISIBLE = ADJ_DIST * 2 + 1
// for test
let count = 1
let l = page.currentPage,
r = page.currentPage
let l = page.currentPage
let r = page.currentPage
while (0 < l - 1 && r + 1 <= page.lastPage && count + 2 <= VISIBLE) {
count += 2
l--
Expand All @@ -37,15 +37,15 @@ while (r + 1 <= page.lastPage && count < VISIBLE) {
let pages: number[] = []
if (l > 1) pages.push(1)
if (l == 3) pages.push(2)
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 - 2) pages.push(page.lastPage - 1)
if (r < page.lastPage) pages.push(page.lastPage)
const getPageUrl = (p: number) => {
if (p == 1) return '/'
if (p === 1) return '/'
return `/${p}/`
}
---
Expand Down Expand Up @@ -80,4 +80,4 @@ const getPageUrl = (p: number) => {
>
<Icon name="material-symbols:chevron-right-rounded" class="text-[1.75rem]"></Icon>
</a>
</div>
</div>
5 changes: 2 additions & 3 deletions src/components/misc/ImageWrapper.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import path from 'path'
import path from 'node:path'
interface Props {
id?: string
src: string
Expand All @@ -24,7 +24,7 @@ const isPublic = src.startsWith('/')
// TODO temporary workaround for images dynamic import
// https://github.com/withastro/astro/issues/3373
let img
let img = null
if (isLocal) {
const files = import.meta.glob<ImageMetadata>('../../**', {
import: 'default',
Expand All @@ -47,4 +47,3 @@ const imageStyle = `object-position: ${position}`
{isLocal && img && <Image src={img} alt={alt || ""} class={imageClass} style={imageStyle}/>}
{!isLocal && <img src={isPublic ? url(src) : src} alt={alt || ""} class={imageClass} style={imageStyle}/>}
</div>

16 changes: 8 additions & 8 deletions src/components/widget/TOC.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ for (const heading of headings) {
const className = Astro.props.class
const removeTailingHash = (text: string) => {
let lastIndexOfHash = text.lastIndexOf('#');
if (lastIndexOfHash != text.length - 1) {
return text;
}
const lastIndexOfHash = text.lastIndexOf('#')
if (lastIndexOfHash !== text.length - 1) {
return text
}
return text.substring(0, lastIndexOfHash);
return text.substring(0, lastIndexOfHash);
}
let heading1Count = 1;
Expand Down Expand Up @@ -119,7 +119,7 @@ class TableOfContents extends HTMLElement {

scrollToActiveHeading = () => {
// If the TOC widget can accommodate both the topmost
// and bottommost items, scroll to the topmost item.
// and bottommost items, scroll to the topmost item.
// Otherwise, scroll to the bottommost one.

if (this.anchorNavTarget || !this.tocEl) return;
Expand Down Expand Up @@ -163,7 +163,7 @@ class TableOfContents extends HTMLElement {

if (this.isInRange(offsetTop, 0, window.innerHeight)
|| this.isInRange(offsetBottom, 0, window.innerHeight)
|| (offsetTop < 0 && offsetBottom > window.innerHeight)) {
|| (offsetTop < 0 && offsetBottom > window.innerHeight)) {
this.markActiveHeading(i);
}
else if (offsetTop > window.innerHeight) break;
Expand Down Expand Up @@ -258,4 +258,4 @@ class TableOfContents extends HTMLElement {

customElements.define("table-of-contents", TableOfContents);

</script>
</script>
21 changes: 12 additions & 9 deletions src/plugins/rehype-component-admonition.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ export function AdmonitionComponent(properties, children, type) {
'Invalid admonition directive. (Admonition directives must be of block type ":::note{name="name"} <content> :::")',
)

let label = null
if (properties && properties['has-directive-label']) {
label = children[0] // The first child is the label
children = children.slice(1)
label.tagName = 'div' // Change the tag <p> to <div>
}
const { label, childrenToReturn } = properties?.['has-directive-label']
? {
label: { ...children[0], tagName: 'div' },
childrenToReturn: children.slice(1),
}
: {
label: null,
childrenToReturn: children,
}

return h(`blockquote`, { class: `admonition bdm-${type}` }, [
h('span', { class: `bdm-title` }, label ? label : type.toUpperCase()),
...children,
return h('blockquote', { class: `admonition bdm-${type}` }, [
h('span', { class: 'bdm-title' }, label ? label : type.toUpperCase()),
...childrenToReturn,
])
}
2 changes: 1 addition & 1 deletion src/plugins/rehype-component-github-card.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function GithubCardComponent(properties, children) {
'Waiting...',
)

const nTitle = h(`div`, { class: 'gc-titlebar' }, [
const nTitle = h('div', { class: 'gc-titlebar' }, [
h('div', { class: 'gc-titlebar-left' }, [
h('div', { class: 'gc-owner' }, [
nAvatar,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/remark-directive-rehype.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
import { h } from 'hastscript'
import { visit } from 'unist-util-visit'

Expand All @@ -10,7 +9,8 @@ export function parseDirectiveNode() {
node.type === 'leafDirective' ||
node.type === 'textDirective'
) {
const data = node.data || (node.data = {})
node.data = node.data || {}
const data = node.data
node.attributes = node.attributes || {}
if (
node.children.length > 0 &&
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/remark-excerpt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toString } from 'mdast-util-to-string'
import { toString as mdastToString } from 'mdast-util-to-string'

/* Use the post's first paragraph as the excerpt */
export function remarkExcerpt() {
Expand All @@ -8,7 +8,7 @@ export function remarkExcerpt() {
if (node.type !== 'paragraph') {
continue
}
excerpt = toString(node)
excerpt = mdastToString(node)
break
}
data.astro.frontmatter.excerpt = excerpt
Expand Down

0 comments on commit 41e4333

Please sign in to comment.