Skip to content

Commit

Permalink
run biome format
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwilliams committed Aug 21, 2024
1 parent b5405b4 commit c0a1321
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 53 deletions.
8 changes: 3 additions & 5 deletions astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from "node:fs";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import tailwind from "@astrojs/tailwind";
import { defineConfig } from "astro/config";
import expressiveCode from "astro-expressive-code";
import icon from "astro-icon";
import fs from "fs";
import { defineConfig } from "astro/config";
import rehypeExternalLinks from "rehype-external-links";
import remarkUnwrapImages from "remark-unwrap-images";

Expand All @@ -31,7 +31,7 @@ export default defineConfig({
[
rehypeExternalLinks,
{
rel: ["nofollow, noopener, noreferrer"],
rel: ["nofollow, noreferrer"],
target: "_blank",
},
],
Expand Down Expand Up @@ -60,9 +60,7 @@ function rawFonts(ext: string[]) {
name: "vite-plugin-raw-fonts",
// @ts-expect-error:next-line
transform(_, id) {
// eslint-disable-next-line
if (ext.some((e) => id.endsWith(e))) {
// eslint-disable-next-line
const buffer = fs.readFileSync(id);
return {
code: `export default ${JSON.stringify(buffer)}`,
Expand Down
4 changes: 1 addition & 3 deletions src/components/BaseHead.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
import type { SiteMeta } from "@/types";
import { siteConfig } from "@/site-config";
import type { SiteMeta } from "@/types";
import "../styles/global.css";
type Props = SiteMeta;
Expand Down
2 changes: 1 addition & 1 deletion src/components/SocialList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const socialLinks: {
<a
class="inline-block p-1 sm:hover:text-link"
href={link}
rel={`noopener noreferrer ${isWebmention ? "me authn" : ""}`}
rel={`noreferrer ${isWebmention ? "me authn" : ""}`}
target="_blank"
>
<Icon aria-hidden="true" class="h-6 w-6" focusable="false" name={name} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/ThemeProvider.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
function setTheme(newTheme) {
if (newTheme !== "light" && newTheme !== "dark") {
return console.warn(
`Invalid theme value '${newTheme}' received. Expected 'light' or 'dark'.`
`Invalid theme value '${newTheme}' received. Expected 'light' or 'dark'.`,
);
}

Expand Down
4 changes: 1 addition & 3 deletions src/components/blog/Hero.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
import type { CollectionEntry } from "astro:content";
import { Image } from "astro:assets";
import type { CollectionEntry } from "astro:content";
import FormattedDate from "../FormattedDate.astro";
interface Props {
Expand Down
4 changes: 1 addition & 3 deletions src/components/blog/PostPreview.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
import type { HTMLTag, Polymorphic } from "astro/types";
import type { CollectionEntry } from "astro:content";
import { getPostSortDate } from "@/data/post";
import type { HTMLTag, Polymorphic } from "astro/types";
import FormattedDate from "../FormattedDate.astro";
type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }> & {
Expand Down
2 changes: 0 additions & 2 deletions src/components/blog/TOC.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
import type { MarkdownHeading } from "astro";
import { generateToc } from "src/utils/generateToc";
import TOCHeading from "./TOCHeading.astro";
interface Props {
Expand Down
9 changes: 4 additions & 5 deletions src/components/blog/webmentions/Comments.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import type { WebmentionsChildren } from "@/types";
import { Image } from "astro:assets";
import type { WebmentionsChildren } from "@/types";
import { Icon } from "astro-icon/components";
interface Props {
Expand All @@ -13,7 +12,7 @@ const { mentions } = Astro.props;
const validComments = ["mention-of", "in-reply-to"];
const comments = mentions.filter(
(mention) => validComments.includes(mention["wm-property"]) && mention.content?.text,
(mention) => validComments.includes(mention["wm-property"]) && mention.content?.text
);
/**
Expand All @@ -36,7 +35,7 @@ const comments = mentions.filter(
<a
class="not-prose shrink-0 overflow-hidden rounded-full outline-none ring-2 ring-textColor hover:ring-4 hover:ring-link focus-visible:ring-4 focus-visible:ring-link"
href={mention.author.url}
rel="noopener noreferrer"
rel="noreferrer"
target="_blank"
title={mention.author.name}
>
Expand Down Expand Up @@ -65,7 +64,7 @@ const comments = mentions.filter(
aria-labelledby="cmt-source"
class="not-prose hover:text-link"
href={mention.url}
rel="noopener noreferrer"
rel="noreferrer"
target="_blank"
>
<span class="hidden" id="cmt-source">
Expand Down
7 changes: 3 additions & 4 deletions src/components/blog/webmentions/Likes.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import type { WebmentionsChildren } from "@/types";
import { Image } from "astro:assets";
import type { WebmentionsChildren } from "@/types";
interface Props {
mentions: WebmentionsChildren[];
Expand All @@ -10,7 +9,7 @@ interface Props {
const { mentions } = Astro.props;
const MAX_LIKES = 10;
const likes = mentions.filter((mention) => mention["wm-property"] == "like-of");
const likes = mentions.filter((mention) => mention["wm-property"] === "like-of");
const likesToShow = likes
.filter((like) => like.author?.photo && like.author.photo !== "")
.slice(0, MAX_LIKES);
Expand All @@ -30,7 +29,7 @@ const likesToShow = likes
<a
class="not-prose relative inline-block overflow-hidden rounded-full outline-none ring-2 ring-textColor hover:z-10 hover:ring-4 hover:ring-link focus-visible:z-10 focus-visible:ring-4 focus-visible:ring-link"
href={like.author?.url}
rel="noopener noreferrer"
rel="noreferrer"
target="_blank"
title={like.author?.name}
>
Expand Down
2 changes: 1 addition & 1 deletion src/data/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { siteConfig } from "@/site-config";
import { type CollectionEntry, getCollection } from "astro:content";
import { siteConfig } from "@/site-config";

/** filter out draft posts based on the environment */
export async function getAllPosts() {
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/Base.astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
import type { SiteMeta } from "@/types";
import BaseHead from "@/components/BaseHead.astro";
import SkipLink from "@/components/SkipLink.astro";
import ThemeProvider from "@/components/ThemeProvider.astro";
import Footer from "@/components/layout/Footer.astro";
import Header from "@/components/layout/Header.astro";
import { siteConfig } from "@/site-config";
import type { SiteMeta } from "@/types";
interface Props {
meta: SiteMeta;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { Image } from "astro:assets";
import aboutImg from "@/assets/about-astro.png";
import PageLayout from "@/layouts/Base.astro";
import { Image } from "astro:assets";
const meta = {
description: "Oops! It looks like this page is lost in space!",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/about.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { Image } from "astro:assets";
import aboutImg from "@/assets/about-astro.png";
import PageLayout from "@/layouts/Base.astro";
import { Image } from "astro:assets";
const meta = {
description: "I'm a starter theme for Astro.build",
Expand Down Expand Up @@ -39,7 +39,7 @@ const meta = {
aria-label="github repository"
class="cactus-link inline-block"
href="https://github.com/chrismwilliams/astro-cactus"
rel="noopener noreferrer"
rel="noreferrer"
target="_blank">repo</a
> if you like me!
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const cactusTech: { desc: string; href: string; title: string }[] = [
<div class="flex flex-col gap-2 sm:flex-row">
<dt>
<span class="flex">
<a class="cactus-link" href={href} rel="noopener noreferrer" target="_blank">
<a class="cactus-link" href={href} rel="noreferrer" target="_blank">
{title}
</a>
:
Expand Down
7 changes: 3 additions & 4 deletions src/pages/posts/[...page].astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
import type { GetStaticPaths, Page } from "astro";
import type { CollectionEntry } from "astro:content";
import Pagination from "@/components/Paginator.astro";
import PostPreview from "@/components/blog/PostPreview.astro";
import { getAllPosts, getUniqueTags, groupPostsByYear, sortMDByDate } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
import type { GetStaticPaths, Page } from "astro";
export const getStaticPaths = (async ({ paginate }) => {
const MAX_POSTS_PER_PAGE = 10;
Expand All @@ -30,13 +29,13 @@ const meta = {
const paginationProps = {
...(page.url.prev && {
prevUrl: {
text: `← Previous Page`,
text: "← Previous Page",
url: page.url.prev,
},
}),
...(page.url.next && {
nextUrl: {
text: `Next Page →`,
text: "Next Page →",
url: page.url.next,
},
}),
Expand Down
3 changes: 1 addition & 2 deletions src/pages/posts/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
import { getAllPosts } from "@/data/post";
import PostLayout from "@/layouts/BlogPost.astro";
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
export const getStaticPaths = (async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import rss from "@astrojs/rss";
import { siteConfig } from "@/site-config";
import { getAllPosts } from "@/data/post";
import { siteConfig } from "@/site-config";
import rss from "@astrojs/rss";

export const GET = async () => {
const posts = await getAllPosts();
Expand Down
7 changes: 3 additions & 4 deletions src/pages/tags/[tag]/[...page].astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
import type { GetStaticPaths, Page } from "astro";
import type { CollectionEntry } from "astro:content";
import Pagination from "@/components/Paginator.astro";
import PostPreview from "@/components/blog/PostPreview.astro";
import { getAllPosts, getUniqueTags, sortMDByDate } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
import type { GetStaticPaths, Page } from "astro";
export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
const allPosts = await getAllPosts();
Expand Down Expand Up @@ -36,13 +35,13 @@ const meta = {
const paginationProps = {
...(page.url.prev && {
prevUrl: {
text: `← Previous Tags`,
text: "← Previous Tags",
url: page.url.prev,
},
}),
...(page.url.next && {
nextUrl: {
text: `Next Tags →`,
text: "Next Tags →",
url: page.url.next,
},
}),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tags/index.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import PageLayout from "@/layouts/Base.astro";
import { getAllPosts, getUniqueTagsWithCount } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
const allPosts = await getAllPosts();
const allTags = getUniqueTagsWithCount(allPosts);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/remark-reading-time.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { toString as mdastToString } from "mdast-util-to-string";
import getReadingTime from "reading-time";
import { toString } from "mdast-util-to-string";

export function remarkReadingTime() {
// @ts-expect-error:next-line
return function (tree, { data }) {
const textOnPage = toString(tree);
return (tree, { data }) => {
const textOnPage = mdastToString(tree);
const readingTime = getReadingTime(textOnPage);
data.astro.frontmatter.minutesRead = readingTime.text;
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/webmentions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "node:fs";
import type { WebmentionsFeed, WebmentionsCache, WebmentionsChildren } from "@/types";
import type { WebmentionsCache, WebmentionsChildren, WebmentionsFeed } from "@/types";

const DOMAIN = import.meta.env.SITE;
const API_TOKEN = import.meta.env.WEBMENTION_API_KEY;
Expand Down
3 changes: 1 addition & 2 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Config } from "tailwindcss";

import { fontFamily } from "tailwindcss/defaultTheme";
import plugin from "tailwindcss/plugin";

Expand All @@ -24,7 +23,7 @@ export default {
plugins: [
require("@tailwindcss/typography"),
require("@tailwindcss/aspect-ratio"),
plugin(function ({ addComponents }) {
plugin(({ addComponents }) => {
addComponents({
".cactus-link": {
"&:hover": {
Expand Down

0 comments on commit c0a1321

Please sign in to comment.