Skip to content

Commit

Permalink
WIP: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dallyh committed Feb 19, 2024
1 parent 50af92d commit bf88315
Show file tree
Hide file tree
Showing 58 changed files with 1,260 additions and 222 deletions.
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/components/astro/blog/BlogPostPreview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import FormattedDate from "@components/astro/blog/FormattedDate.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getBlogPostUrl } from "@utils/getBlogPostUrl";
import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { getOgImageUrl } from "@utils/getOgImageUrl";
import { getBlogPostUrl, getCategoryTitleByLocale, getOgImageUrl } from "@utils";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import TagList from "./TagList.astro";
Expand Down
16 changes: 2 additions & 14 deletions src/components/astro/blog/Category.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getCategoryDescriptionByLocale, getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { getCategoryDescriptionByLocale, getCategoryTitleByLocale, getFilteredPostsCollection } from "@utils";
import { Icon } from "astro-icon/components";
import { getCollection, type CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
Expand All @@ -19,19 +19,7 @@ const title = await getCategoryTitleByLocale(locale, category.id);
const description = await getCategoryDescriptionByLocale(locale, category.id);
const url = getRelativeLocaleUrl(locale, `/blog/categories/${category.id}`);
const categoryPosts = await getCollection("posts", ({ data }) => {
return !data.hidden && data.language === locale && data.category?.id === category.id;
});
// Only last 3 recent
const filteredPosts =
categoryPosts === undefined
? undefined
: categoryPosts
.sort((a, b) => {
return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf();
})
.slice(0, 3);
const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, categoryId: category.id});
---

<li class="category">
Expand Down
14 changes: 2 additions & 12 deletions src/components/astro/blog/FeaturedPosts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getLocale } from "@i18n/utils";
import { getCollection } from "astro:content";
import Section from "../global/Section.astro";
import PostsGrid from "./PostsGrid.astro";
import { getFilteredPostsCollection } from "@utils";
interface Props {
postSize?: number;
Expand All @@ -19,18 +20,7 @@ const locale = getLocale(Astro.url);
await loadNamespaces(locale, ["blog"]);
//Blogs
const allPosts = await getCollection("posts", ({ data }) => {
return data.language === locale && !data.hidden && data.featured;
});
const filteredPosts =
allPosts === undefined
? undefined
: allPosts
.sort((a, b) => {
return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf();
})
.slice(0, postSize);
const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, featured: true, slice: postSize});
const sectionProps = {
id: "featuredPosts",
Expand Down
14 changes: 2 additions & 12 deletions src/components/astro/blog/RecentPosts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getCollection } from "astro:content";
import { BLOG } from "src/config/blog";
import Section from "../global/Section.astro";
import PostsGrid from "./PostsGrid.astro";
import { getFilteredPostsCollection } from "@utils";
interface Props {
postSize?: number;
Expand All @@ -19,18 +20,7 @@ const locale = getLocale(Astro.url);
await loadNamespaces(locale, ["blog"]);
//Blogs
const allPosts = await getCollection("posts", ({ data }) => {
return data.language === locale && !data.hidden && (filterFeatured ? !data.featured : true);
});
const filteredPosts =
allPosts === undefined
? undefined
: allPosts
.sort((a, b) => {
return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf();
})
.slice(0, postSize);
const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, featured: filterFeatured, slice: postSize});
const sectionProps = {
id: "recentPosts",
Expand Down
4 changes: 1 addition & 3 deletions src/components/astro/blog/SmallBlogPostPreview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import FormattedDate from "@components/astro/blog/FormattedDate.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getBlogPostUrl } from "@utils/getBlogPostUrl";
import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { getOgImageUrl } from "@utils/getOgImageUrl";
import { getBlogPostUrl, getCategoryTitleByLocale, getOgImageUrl } from "@utils";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
Expand Down
17 changes: 2 additions & 15 deletions src/components/astro/blog/Tag.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getTagByLocale } from "@utils/getTagByLocale";
import { getFilteredPostsCollection, getTagByLocale } from "@utils";
import { Icon } from "astro-icon/components";
import { getCollection, type CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
Expand All @@ -16,20 +16,7 @@ const locale = getLocale(Astro.url);
const title = await getTagByLocale(locale, tag.id);
const url = getRelativeLocaleUrl(locale, `/blog/tags/${tag.id}/`);
const tagPosts = await getCollection("posts", ({ data }) => {
return !data.hidden && data.language === locale && data.tags.find((tag) => tag.id === tag.id);
});
// Only last 3 recent
const filteredPosts =
tagPosts === undefined
? undefined
: tagPosts
.sort((a, b) => {
return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf();
})
.slice(0, 3);
const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, tagId: tag.id});
---

<li class="tag">
Expand Down
2 changes: 1 addition & 1 deletion src/components/astro/blog/TagList.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { getLocale } from "@i18n/utils";
import { getTagByLocale } from "@utils/getTagByLocale";
import { getTagByLocale } from "@utils";
import { type CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
Expand Down
3 changes: 1 addition & 2 deletions src/components/astro/global/HeadHrefLangs.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
import { defaultLocale, locales } from "@config/i18n";
import { getPathFromUrl } from "@i18n/utils";
import { getAbsoluteBlogPostUrl } from "@utils/getAbsoluteBlogPostUrl";
import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale";
import { getAbsoluteBlogPostUrl, getBlogPostByIdAndLocale } from "@utils";
import type { CollectionEntry } from "astro:content";
import { getAbsoluteLocaleUrl } from "astro:i18n";
Expand Down
3 changes: 1 addition & 2 deletions src/components/astro/global/LanguageSelector.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import { locales } from "@config/i18n";
import { loadNamespaces } from "@i18n/i18n";
import { getLocale, getPathFromUrl } from "@i18n/utils";
import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale";
import { getBlogPostUrl } from "@utils/getBlogPostUrl";
import { getBlogPostByIdAndLocale, getBlogPostUrl } from "@utils";
import { Icon } from "astro-icon/components";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
Expand Down
2 changes: 1 addition & 1 deletion src/components/astro/projects/ProjectCard.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { extractFileNameAndExtension } from "@utils/extractFilenameAndExtension";
import { extractFileNameAndExtension } from "@utils";
import type { ImageMetadata } from "astro";
import { Image } from "astro:assets";
import type { CollectionEntry } from "astro:content";
Expand Down
2 changes: 1 addition & 1 deletion src/content/categories/guides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ id: guides
languages:
cs:
title: Návody
description: Návody různých témat..
description: Různé návody pro různá témata.
en:
title: Guides
description: Various guides about various topics.
8 changes: 8 additions & 0 deletions src/content/categories/lifestyle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id: lifestyle
languages:
cs:
title: Život
description: Témata o životě.
en:
title: Lifestyle
description: Lifestyle topics
8 changes: 8 additions & 0 deletions src/content/categories/software.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id: software
languages:
cs:
title: Software
description: Vše kolem software.
en:
title: Software
description: Topics about software.
10 changes: 7 additions & 3 deletions src/content/posts/cs/2023-01-01-typography-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
title: "Příklad typografie"
postId: "post-1"
language: "cs"
featured: false
featured: true
pubDateTime: 2022-07-01
modDatetime: 2022-07-01
description: "Tento příspěvěk slouží pro testování typografie."
author: "Dalibor Hon"
description: "This is the first post of my new Astro blog."
author: "Astro Learner"
image:
url: "https://docs.astro.build/assets/full-logo-light.png"
alt: "The full Astro logo."
tags:
- astro
- community
hidden: false
---

Expand Down
14 changes: 14 additions & 0 deletions src/content/posts/cs/2023-12-29-localized-slug-title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Lokalizovaná část URL
postId: 0636fd5a-2786-4501-b1bb-634844ff32f1
description: Lokalizovaná část URL
author: Dalibor Hon
tags:
- successes
language: cs
hidden: false
featured: true
pubDateTime: 2023-12-29T23:20:35.541
---

Lokalizovaná část URL
15 changes: 15 additions & 0 deletions src/content/posts/cs/2024-01-02-test-post-from-identity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Test post from identity
postId: 943b9bc5-49e8-4849-95f3-f982f4d51c24
description: Test post from identity
author: Dalibor Hon
tags:
- astro
language: cs
hidden: true
featured: false
pubDateTime: 2024-01-02T13:34:43+01:00
modDatetime: 2024-01-02T13:34:44+01:00
---

Test post from identity
17 changes: 17 additions & 0 deletions src/content/posts/cs/2024-01-07-test-post-from-cms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Testovací post z CMS
postId: ec0b8590-3327-44e1-b8a6-e44388b55ec6
description: Testovací post z CMS
author: Dalibor Hon
tags:
- successes
category: software
language: cs
hidden: false
featured: false
ogImage: /assets/uploads/img/astro.jpg
pubDateTime: 2024-01-07T21:37:39+01:00
modDatetime: 2024-01-10T21:37:39+01:00
---

Testovací post z CMS
17 changes: 17 additions & 0 deletions src/content/posts/cs/2024-01-13-test-post-with-external-image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Test externího obrázku
postId: 66db8404-5409-4ff0-8d07-1003b3619fbe
description: Test externího obrázku
author: Dalibor Hon
tags:
- community
category: software
language: cs
hidden: false
featured: false
ogImage: https://astro.build/og/astro.jpg
pubDateTime: 2024-01-13T22:09:12+01:00
modDatetime: ""
---

Test externího obrázku
Loading

0 comments on commit bf88315

Please sign in to comment.