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 a72449b commit 50af92d
Show file tree
Hide file tree
Showing 76 changed files with 386 additions and 473 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"i18n-ally.review.gutters": false,
"i18n-ally.sortCompare": "locale",
"i18n-ally.sortKeys": true,
"i18n-ally.sortLocale": "en"
"i18n-ally.sortLocale": "en",
}
5 changes: 2 additions & 3 deletions scripts/generate-i18n-locale-types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// npx ts-node --esm file.ts

import { quicktype, InputData, jsonInputForTargetLanguage, TypeScriptTargetLanguage } from "quicktype-core";
import jsyaml from "js-yaml";
import fs from "node:fs";
import path from "node:path";
import { dirname } from "path";
import { InputData, TypeScriptTargetLanguage, jsonInputForTargetLanguage, quicktype } from "quicktype-core";
import { fileURLToPath } from "url";
import jsyaml from "js-yaml";
import { Console } from "node:console";

const __dirname = dirname(fileURLToPath(import.meta.url));

Expand Down
2 changes: 1 addition & 1 deletion scripts/yaml-convert.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// npx ts-node --esm file.ts

import yaml from "js-yaml";
import fs from "node:fs";
import path from "node:path";
import { dirname } from "path";
import { fileURLToPath } from "url";
import yaml from "js-yaml";

const __dirname = dirname(fileURLToPath(import.meta.url));
const folderName = path.resolve(__dirname, "./src/content/categories/");
Expand Down
15 changes: 2 additions & 13 deletions src/components/astro/blog/AllPostsUrl.astro
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
---
import { getCollection, type CollectionEntry } from "astro:content";
import { getRoutingLocale, getLocale } from "@i18n/utils";
import PageLayout from "@layouts/PageLayout.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import Section from "@components/astro/global/Section.astro";
import SmallBlogPostPreview from "@components/astro/blog/SmallBlogPostPreview.astro";
import BreadCrumbs from "@components/astro/blog/BreadCrumbs.astro";
import BreadCrumbsItem from "@components/astro/blog/BreadCrumbsItem.astro";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getTagByLocale } from "@utils/getTagByLocale";
import { locales } from "@config/i18n";
import type { Page } from "astro";
import { getLocale } from "@i18n/utils";
import { Icon } from "astro-icon/components";
import { getRelativeLocaleUrl } from "astro:i18n";
interface Props {
url: string;
Expand All @@ -22,7 +12,6 @@ const { url, urlDescription } = Astro.props;
// i18next
const locale = getLocale(Astro.url);
---

<div class="arrow-link">
Expand Down
9 changes: 4 additions & 5 deletions src/components/astro/blog/BlogPostPreview.astro
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
import type { CollectionEntry } from "astro:content";
import FormattedDate from "@components/astro/blog/FormattedDate.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import TagList from "./TagList.astro";
import { getOgImageUrl } from "@utils/getOgImageUrl";
import { getBlogPostUrl } from "@utils/getBlogPostUrl";
import { getPostImgTransitionName } from "@utils/getPostImgTransitionName";
import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { getOgImageUrl } from "@utils/getOgImageUrl";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import { loadNamespaces, t } from "@i18n/i18n";
import TagList from "./TagList.astro";
interface Props {
post: CollectionEntry<"posts">;
Expand Down
8 changes: 3 additions & 5 deletions src/components/astro/blog/Category.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
import { getCollection, type CollectionEntry } from "astro:content";
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getCategoryDescriptionByLocale, getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { Icon } from "astro-icon/components";
import SmallBlogPostPreview from "./SmallBlogPostPreview.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import { getCollection, type CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import PostsList from "./PostsList.astro";
import { getLocaleRelativeUrl } from "astro/virtual-modules/i18n.js";
interface Props {
category: CollectionEntry<"categories">;
Expand Down
7 changes: 2 additions & 5 deletions src/components/astro/blog/FeaturedPosts.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
import { getLocale } from "@i18n/utils";
import { getCollection } from "astro:content";
import BlogPostPreview from "@components/astro/blog/BlogPostPreview.astro";
import { BLOG } from "@config/blog";
import { getRelativeLocaleUrl } from "astro:i18n";
import { loadNamespaces, t } from "@i18n/i18n";
import { Icon } from "astro-icon/components";
import { getLocale } from "@i18n/utils";
import { getCollection } from "astro:content";
import Section from "../global/Section.astro";
import PostsGrid from "./PostsGrid.astro";
Expand Down
24 changes: 2 additions & 22 deletions src/components/astro/blog/PostsGrid.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
import { getLocale } from "@i18n/utils";
import { getCollection, type CollectionEntry } from "astro:content";
import BlogPostPreview from "@components/astro/blog/BlogPostPreview.astro";
import { getRelativeLocaleUrl } from "astro:i18n";
import { loadNamespaces, t } from "@i18n/i18n";
import { Icon } from "astro-icon/components";
import { getLocale } from "@i18n/utils";
import type { Page } from "astro";
import { type CollectionEntry } from "astro:content";
import AllPostsUrl from "./AllPostsUrl.astro";
interface Props {
Expand Down Expand Up @@ -61,21 +58,4 @@ function isPage<T>(value: any): value is Page<T> {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
}

.arrow-link {
font-size: 1.1rem;
text-align: center;

a {
display: inline-flex;
gap: 0.5rem;
}

svg {
margin-top: 0.15rem;
width: 1rem;
height: 1rem;
color: var(--body-color);
}
}
</style>
30 changes: 2 additions & 28 deletions src/components/astro/blog/PostsList.astro
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
---
import { getCollection, type CollectionEntry } from "astro:content";
import { getRoutingLocale, getLocale } from "@i18n/utils";
import PageLayout from "@layouts/PageLayout.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import Section from "@components/astro/global/Section.astro";
import SmallBlogPostPreview from "@components/astro/blog/SmallBlogPostPreview.astro";
import BreadCrumbs from "@components/astro/blog/BreadCrumbs.astro";
import BreadCrumbsItem from "@components/astro/blog/BreadCrumbsItem.astro";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getTagByLocale } from "@utils/getTagByLocale";
import { locales } from "@config/i18n";
import { getLocale } from "@i18n/utils";
import type { Page } from "astro";
import { Icon } from "astro-icon/components";
import { type CollectionEntry } from "astro:content";
import AllPostsUrl from "./AllPostsUrl.astro";
interface Props {
Expand Down Expand Up @@ -62,21 +53,4 @@ function isPage<T>(value: any): value is Page<T> {
grid-template-columns: 1fr;
}
}

.arrow-link {
font-size: 1.1rem;
text-align: center;

a {
display: inline-flex;
gap: 0.5rem;
}

svg {
margin-top: 0.15rem;
width: 1rem;
height: 1rem;
color: var(--body-color);
}
}
</style>
5 changes: 1 addition & 4 deletions src/components/astro/blog/RecentPosts.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getCollection } from "astro:content";
import BlogPostPreview from "@components/astro/blog/BlogPostPreview.astro";
import { BLOG } from "src/config/blog";
import { getRelativeLocaleUrl } from "astro:i18n";
import { loadNamespaces, t } from "@i18n/i18n";
import { Icon } from "astro-icon/components";
import Section from "../global/Section.astro";
import PostsGrid from "./PostsGrid.astro";
Expand Down
11 changes: 5 additions & 6 deletions src/components/astro/blog/SmallBlogPostPreview.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
import type { CollectionEntry } from "astro:content";
import FormattedDate from "@components/astro/blog/FormattedDate.astro";
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getOgImageUrl } from "@utils/getOgImageUrl";
import { getBlogPostUrl } from "@utils/getBlogPostUrl";
import { getPostImgTransitionName } from "@utils/getPostImgTransitionName";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { loadNamespaces, t } from "@i18n/i18n";
import { getOgImageUrl } from "@utils/getOgImageUrl";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
interface Props {
post: CollectionEntry<"posts">;
Expand All @@ -23,7 +22,7 @@ await loadNamespaces(locale, ["blog"]);
---

<div class="post-preview">
<img src={ogUrl} alt={post.data.title}/>
<img src={ogUrl} alt={post.data.title} />
<div class="post-description">
<a href={postUrl} class="post-title">{post.data.title}</a>
{
Expand Down
27 changes: 19 additions & 8 deletions src/components/astro/blog/Tag.astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
import { getCollection, type CollectionEntry } from "astro:content";
import { t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getCategoryDescriptionByLocale, getCategoryTitleByLocale } from "@utils/getCategoryByLocale";
import { Icon } from "astro-icon/components";
import SmallBlogPostPreview from "./SmallBlogPostPreview.astro";
import { getTagByLocale } from "@utils/getTagByLocale";
import { t } from "@i18n/i18n";
import { Icon } from "astro-icon/components";
import { getCollection, type CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import PostsList from "./PostsList.astro";
interface Props {
Expand Down Expand Up @@ -43,8 +41,21 @@ const filteredPosts =
{title}
</a>
</h2>
{!filteredPosts && <p class="category-post-list">{t("blog.no_tagged_posts")} {title}</p>}
{filteredPosts && filteredPosts.length === 0 && <p class="category-post-list">{t("blog.no_tagged_posts")}{title}</p>}
{
!filteredPosts && (
<p class="category-post-list">
{t("blog.no_tagged_posts")} {title}
</p>
)
}
{
filteredPosts && filteredPosts.length === 0 && (
<p class="category-post-list">
{t("blog.no_tagged_posts")}
{title}
</p>
)
}
{
filteredPosts && filteredPosts.length !== 0 && (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/components/astro/blog/TagList.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import { getEntry, type CollectionEntry } from "astro:content";
import { getLocale } from "@i18n/utils";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getTagByLocale } from "@utils/getTagByLocale";
import { type CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
interface Props {
post?: CollectionEntry<"posts">;
Expand Down
4 changes: 2 additions & 2 deletions src/components/astro/global/Contact.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import ContactForm from "@components/react/ContactForm/ContactForm";
import i18n, { loadNamespaces } from "@i18n/i18n";
import type { ContactRes, CommonRes } from "@i18n/locales/types";
import type { CommonRes, ContactRes } from "@i18n/locales/types";
import { getLocale } from "@i18n/utils";
import ContactForm from "@components/react/ContactForm/ContactForm";
// i18next
const locale = getLocale(Astro.url);
Expand Down
2 changes: 0 additions & 2 deletions src/components/astro/global/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
import { Image } from "astro:assets";
import { getLocale } from "@i18n/utils";
import { loadNamespaces, t } from "@i18n/i18n";
// Images
import astroSvg from "@assets/img/astro/simple-full-logo-light.svg";
import { Icon } from "astro-icon/components";
// i18next
Expand Down
2 changes: 1 addition & 1 deletion src/components/astro/global/HeadHrefLangs.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import { defaultLocale, locales } from "@config/i18n";
import { getPathFromUrl } from "@i18n/utils";
import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale";
import { getAbsoluteBlogPostUrl } from "@utils/getAbsoluteBlogPostUrl";
import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale";
import type { CollectionEntry } from "astro:content";
import { getAbsoluteLocaleUrl } from "astro:i18n";
Expand Down
10 changes: 5 additions & 5 deletions src/components/astro/global/LanguageSelector.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Credits: https://github.com/yassinedoghri/astro-i18next/blob/beta/src/components/LanguageSelector.astro
// Edited for this project needs.
import { getLocale, getPathFromUrl } from "@i18n/utils";
import ISO6991 from "iso-639-1";
import { locales } from "@config/i18n";
import { getRelativeLocaleUrl } from "astro:i18n";
import type { CollectionEntry } from "astro:content";
import { loadNamespaces } from "@i18n/i18n";
import { getLocale, getPathFromUrl } from "@i18n/utils";
import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale";
import { getBlogPostUrl } from "@utils/getBlogPostUrl";
import { loadNamespaces, t } from "@i18n/i18n";
import { Icon } from "astro-icon/components";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import ISO6991 from "iso-639-1";
interface Props {
post?: CollectionEntry<"posts">;
Expand Down
8 changes: 4 additions & 4 deletions src/components/astro/global/Navigation.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
import { getLocale } from "@i18n/utils";
import { loadNamespaces, t } from "@i18n/i18n";
import LanguageSelector from "./LanguageSelector.astro";
import { getRelativeLocaleUrl } from "astro:i18n";
import { getLocale } from "@i18n/utils";
import { Icon } from "astro-icon/components";
import type { CollectionEntry } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import LanguageSelector from "./LanguageSelector.astro";
import Search from "./Search.astro";
import { Icon } from "astro-icon/components";
import ThemeSelect from "./ThemeSelect.astro";
interface Props {
Expand Down
4 changes: 2 additions & 2 deletions src/components/astro/global/Search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ if (locale === "cs") {
<site-search data-translations={JSON.stringify(translations)}>
<button data-open-modal disabled>
<div class="inner">
<i class="search-icon"><Icon name="bi:search" size={18} title={t("common.search")} /></i>
<i class="slash-icon"><Icon name="forward-slash" size={18} title={t("common.search_label")}/></i>
<i class="search-icon"><Icon name="bi:search" size={18} title={t("common.search")} /></i>
<i class="slash-icon"><Icon name="forward-slash" size={18} title={t("common.search_label")} /></i>
</div>
</button>

Expand Down
5 changes: 2 additions & 3 deletions src/components/astro/home/Intro.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import { getLocale } from "@i18n/utils";
import avatar from "@assets/img/profile/avatar-casual.svg";
import { loadNamespaces, t } from "@i18n/i18n";
import { getLocale } from "@i18n/utils";
import { Icon } from "astro-icon/components";
import avatar from "@assets/img/profile/avatar-casual.svg";
import { Image } from "astro:assets";
// i18next
Expand Down Expand Up @@ -62,7 +62,6 @@ await loadNamespaces(locale, ["common", "landing"]);
img {
max-height: 240px;
}

}

.shake {
Expand Down
Loading

0 comments on commit 50af92d

Please sign in to comment.