Skip to content

Commit

Permalink
style: lint codes
Browse files Browse the repository at this point in the history
  • Loading branch information
oriverk committed Mar 25, 2024
1 parent 5a06a0e commit 015ed2b
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/components/FeedCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export { title, link, dateMiliSeconds };
const timeString = `${getTimeFromNow(dateMiliSeconds)} ago`;
const isExternal = link.startsWith("http");
const url = isExternal ? link : "https://oriverk.dev";
const { hostname, origin } = new URL(url)
const { hostname, origin } = new URL(url);
</script>

<a href={link} target={isExternal ? "_blank" : ""} rel={isExternal ? "noopenner noreferrer" : ""}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchButton.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Icon from "./ui/Icon.svelte"
import Icon from "./ui/Icon.svelte";
---

<button type="button" id="search-button">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/ContentWrapper.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import clsx from "clsx";
export let className = "";
export let style = ""
export let style = "";
</script>

<div class={clsx('content-wrapper', className)} style={style}>
Expand Down
6 changes: 3 additions & 3 deletions src/components/ui/Dialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { HTMLDialogAttributes } from "svelte/elements";
interface $$Props extends Omit<HTMLDialogAttributes, "class"> {
className?: string;
dialog: HTMLDialogElement
dialog: HTMLDialogElement;
}
let { id , className, dialog } = $$props as $$Props;
export { dialog, id, className }
let { id, className, dialog } = $$props as $$Props;
export { dialog, id, className };
// const dispatch = createEventDispatcher();
// function onClose(){
// dispatch('closeDialog')
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Props {
const { origin, href, hostname } = Astro.url;
const { title, description, image, noindex } = Astro.props;
const siteName = hostname
const siteName = hostname;
const siteTitle = title ? `${title} | ${siteName}` : siteName;
---

Expand Down
2 changes: 1 addition & 1 deletion src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import Card from "../components/ui/Card.svelte";
import Layout from "../layouts/Layout.astro";
import Card from "../components/ui/Card.svelte"
---

<Layout title="Home">
Expand Down
4 changes: 2 additions & 2 deletions src/pages/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
import { getCollection } from "astro:content";
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
import ContentWrapper from "../components/ui/ContentWrapper.svelte";
import Markdown from "../components/ui/Markdown.svelte";
import Layout from "../layouts/Layout.astro";
import { getCollection } from "astro:content";
export const getStaticPaths = (async () => {
const posts = await getCollection("static")
const posts = await getCollection("static");
const result = posts.map((post) => {
return {
params: { slug: post.slug },
Expand Down
3 changes: 2 additions & 1 deletion src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ type Props = InferGetStaticPropsType<typeof getStaticPaths>;
const { post } = Astro.props as Props;
const { id, body, collection, render, data } = post;
const place = `${collection}/${id}`;
const { title, description, tags, create, update, image, published, noindex } = data;
const { title, description, tags, create, update, image, published, noindex } =
data;
const { Content, headings } = await render();
const toc = getTocHierarchy(headings);
---
Expand Down
17 changes: 11 additions & 6 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ import { getUserContent } from "../utils/github/getUserContent";
const userContent = getUserContent();
const feedItems = getFeedItems();
const blogItems = (await getBlog()).map((post) => {
const {slug, data} = post
const { slug, data } = post;
const { title, tags, create, update } = data;
const link = `/blog/${slug}`;
const isoDate = update ?? create;
const dateMiliSeconds = new Date(isoDate).getTime();
return {
title, contentSnipett: tags, link, isoDate, dateMiliSeconds
}
})
const items = [...feedItems, ...blogItems]
.sort((a , b) => b.dateMiliSeconds - a.dateMiliSeconds)
title,
contentSnipett: tags,
link,
isoDate,
dateMiliSeconds,
};
});
const items = [...feedItems, ...blogItems].sort(
(a, b) => b.dateMiliSeconds - a.dateMiliSeconds,
);
const { repositoryItems, contributionCalendar } = userContent;
const colors = ["#161b22", "#0e4429", "#006d32", "#26a641", "#39d353"];
---
Expand Down
18 changes: 9 additions & 9 deletions src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import rss from '@astrojs/rss';
import type { APIContext } from 'astro';
import { getBlog } from '../utils/getBlog';
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getBlog } from "../utils/getBlog";

export async function GET(context: APIContext) {
const blog = await getBlog();
const items = blog.map(({slug, data}) => {
const { title, description, create } = data
const items = blog.map(({ slug, data }) => {
const { title, description, create } = data;
const link = `/blog/${slug}`;
return {
title,
pubDate: new Date(create),
description: description ?? undefined,
link
}
})
link,
};
});
return rss({
title: 'oriverk.dev',
title: "oriverk.dev",
description: "",
site: context.site || "",
items,
Expand Down
5 changes: 4 additions & 1 deletion src/utils/getBlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export async function getBlog() {
});

const posts = collection.sort((a, b) => {
return new Date(b.data.update ?? b.data.create).getTime() - new Date(a.data.update ?? a.data.create).getTime()
return (
new Date(b.data.update ?? b.data.create).getTime() -
new Date(a.data.update ?? a.data.create).getTime()
);
});

return posts;
Expand Down

0 comments on commit 015ed2b

Please sign in to comment.