summaryrefslogtreecommitdiff
path: root/src/lib/utils
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-02-09 00:47:32 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-02-09 00:47:32 +0300
commit2f74411118c35f0c9d852966af25e04b45dd3f53 (patch)
treec4ab5c61475294020832cc24bc2931a368fb3d0d /src/lib/utils
parent169ab22e65874ecfd9c047d60934220b60a86f15 (diff)
formatting and more perf
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/posts.server.ts32
-rw-r--r--src/lib/utils/posts.ts6
2 files changed, 20 insertions, 18 deletions
diff --git a/src/lib/utils/posts.server.ts b/src/lib/utils/posts.server.ts
index a9b7bb9..9f34c1c 100644
--- a/src/lib/utils/posts.server.ts
+++ b/src/lib/utils/posts.server.ts
@@ -1,26 +1,28 @@
-import type { Post, PostMetadata } from './posts';
+import type { Post, PostMetadata } from "./posts";
-const postMetadataFiles = import.meta.glob<PostMetadata>('/src/posts/*.svx', {
- eager: true,
- import: 'metadata'
+const postMetadataFiles = import.meta.glob<PostMetadata>("/src/posts/*.svx", {
+ eager: true,
+ import: "metadata",
});
function getSlugFromPath(path: string): string {
- return path.split('/').pop()?.replace('.svx', '') ?? '';
+ return path.split("/").pop()?.replace(".svx", "") ?? "";
}
export function getPosts(): Post[] {
- const posts: Post[] = [];
+ const posts: Post[] = [];
- for (const path in postMetadataFiles) {
- const metadata = postMetadataFiles[path];
- const slug = getSlugFromPath(path);
+ for (const path in postMetadataFiles) {
+ const metadata = postMetadataFiles[path];
+ const slug = getSlugFromPath(path);
- posts.push({
- ...metadata,
- slug
- });
- }
+ posts.push({
+ ...metadata,
+ slug,
+ });
+ }
- return posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
+ return posts.sort(
+ (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(),
+ );
}
diff --git a/src/lib/utils/posts.ts b/src/lib/utils/posts.ts
index d0eca68..ae5cf84 100644
--- a/src/lib/utils/posts.ts
+++ b/src/lib/utils/posts.ts
@@ -1,4 +1,4 @@
-import type { Component } from 'svelte';
+import type { Component } from "svelte";
export interface PostMetadata {
title: string;
@@ -16,10 +16,10 @@ export interface PostModule {
metadata: PostMetadata;
}
-const postLoaders = import.meta.glob<PostModule>('/src/posts/*.svx');
+const postLoaders = import.meta.glob<PostModule>("/src/posts/*.svx");
function getSlugFromPath(path: string): string {
- return path.split('/').pop()?.replace('.svx', '') ?? '';
+ return path.split("/").pop()?.replace(".svx", "") ?? "";
}
export function getPostSlugs(): string[] {