Skip to content

Commit

Permalink
chore: update prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
StarHeartHunt committed Mar 29, 2024
1 parent e2a7cf4 commit 1d06ed2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 39 deletions.
9 changes: 1 addition & 8 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{
"overrides": [
{
"files": ["**/*.astro"],
"options": {
"parser": "astro"
}
}
],
"plugins": ["prettier-plugin-astro"],
"semi": true,
"singleQuote": false,
"tabWidth": 2,
Expand Down
12 changes: 6 additions & 6 deletions src/components/BaseHead.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import '../styles/global.css';
import "../styles/global.css";
export interface Props {
title: string;
Expand All @@ -9,7 +9,7 @@ export interface Props {
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const { title, description, image = '/placeholder-social.jpg' } = Astro.props;
const { title, description, image = "/placeholder-social.jpg" } = Astro.props;
---

<!-- Global Metadata -->
Expand Down Expand Up @@ -39,10 +39,10 @@ const { title, description, image = '/placeholder-social.jpg' } = Astro.props;
(function () {
const prefersDark =
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
const setting = localStorage.getItem('starheart-color-scheme') || 'auto';
if (setting === 'dark' || (prefersDark && setting !== 'light'))
document.documentElement.classList.toggle('dark', true);
window.matchMedia("(prefers-color-scheme: dark)").matches;
const setting = localStorage.getItem("starheart-color-scheme") || "auto";
if (setting === "dark" || (prefersDark && setting !== "light"))
document.documentElement.classList.toggle("dark", true);
})();
</script>

Expand Down
6 changes: 3 additions & 3 deletions src/components/FormattedDate.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const { date } = Astro.props;

<time datetime={date.toISOString()}>
{
date.toLocaleDateString('en-us', {
month: 'short',
day: 'numeric',
date.toLocaleDateString("en-us", {
month: "short",
day: "numeric",
})
}
</time>
2 changes: 1 addition & 1 deletion src/components/IconLinkGroup.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import IconLink from './IconLink.astro';
import IconLink from "./IconLink.astro";
export interface Link {
icon: (props: astroHTML.JSX.SVGAttributes) => astroHTML.JSX.Element;
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/BlogPost.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import FormattedDate from '../components/FormattedDate.astro';
import BaseLayout from './BaseLayout.astro';
import FormattedDate from "../components/FormattedDate.astro";
import BaseLayout from "./BaseLayout.astro";
const { title, description, pubDate, updatedDate, minutesRead } = Astro.props;
---
Expand All @@ -15,7 +15,7 @@ const { title, description, pubDate, updatedDate, minutesRead } = Astro.props;
</div>
)
}
{minutesRead ? ` · ${minutesRead}` : ''}
{minutesRead ? ` · ${minutesRead}` : ""}
<h1>{title}</h1>
<div class="slide-enter-content"><slot /></div>
</article>
Expand Down
28 changes: 14 additions & 14 deletions src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
---
import { getCollection, type CollectionEntry } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
import { getCollection, type CollectionEntry } from "astro:content";
import BlogPost from "../../layouts/BlogPost.astro";
export async function getStaticPaths() {
const posts = await getCollection('blog');
const posts = await getCollection("blog");
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
}
type Props = CollectionEntry<'blog'>;
type Props = CollectionEntry<"blog">;
const post = Astro.props;
const { Content, remarkPluginFrontmatter } = await post.render();
---

<script>
let copyButtonLabel = 'Copy';
let codeBlocks = Array.from(document.querySelectorAll('pre'));
let copyButtonLabel = "Copy";
let codeBlocks = Array.from(document.querySelectorAll("pre"));

for (let codeBlock of codeBlocks) {
let wrapper = document.createElement('div');
wrapper.style.position = 'relative';
let wrapper = document.createElement("div");
wrapper.style.position = "relative";

let copyButton = document.createElement('button');
copyButton.className = 'copy-code';
let copyButton = document.createElement("button");
copyButton.className = "copy-code";
copyButton.innerHTML = copyButtonLabel;

codeBlock.setAttribute('tabindex', '0');
codeBlock.setAttribute("tabindex", "0");
codeBlock.appendChild(copyButton);
// wrap codebock with relative parent element
codeBlock.parentNode?.insertBefore(wrapper, codeBlock);
wrapper.appendChild(codeBlock);

copyButton.addEventListener('click', async () => {
copyButton.addEventListener("click", async () => {
await copyCode(codeBlock, copyButton);
});
}

async function copyCode(block: HTMLPreElement, button: HTMLButtonElement) {
let code = block.querySelector('code');
let code = block.querySelector("code");
let text = code?.innerText;

await navigator.clipboard.writeText(text!);

// visual feedback that task is completed
button.innerText = 'Copied';
button.innerText = "Copied";

setTimeout(() => {
button.innerText = copyButtonLabel;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import { getEntry } from 'astro:content';
import { SITE_DESCRIPTION, SITE_TITLE } from '../consts';
import BlogPost from '../layouts/BlogPost.astro';
import { getEntry } from "astro:content";
import { SITE_DESCRIPTION, SITE_TITLE } from "../consts";
import BlogPost from "../layouts/BlogPost.astro";
const profile = await getEntry('blog', 'about');
const profile = await getEntry("blog", "about");
const { Content } = await profile.render();
---
Expand Down

0 comments on commit 1d06ed2

Please sign in to comment.