-
+
@@ -27,14 +28,18 @@ const date = new Date();
footer {
font-weight: 500;
margin-top: 5rem;
- color: var(--color-gray-200);
+ color: var(--color-gray-400);
font-size: var(--font-size-sm);
& .container {
- padding: 15px 0 15px 0;
+ padding-top: 15px;
+ padding-bottom: 15px;
border-top: 1px solid var(--border-color);
display: flex;
align-items: center;
justify-content: space-between;
+ flex-wrap: wrap;
+ column-gap: 20px;
+ row-gap: 5px;
& div:last-child {
display: flex;
align-items: center;
diff --git a/src/components/RecentArticles.astro b/src/components/RecentArticles.astro
index ea980f6..fb81519 100644
--- a/src/components/RecentArticles.astro
+++ b/src/components/RecentArticles.astro
@@ -1,35 +1,35 @@
---
import type { CollectionEntry } from "astro:content";
import siteconfig from "siteconfig.json";
+import { getLanguageFromURL } from "@i18n/utils";
+import * as utils from "@utils/index";
import ArticleItem from "@components/ArticleItem.astro";
import EmptyList from "@components/EmptyList.astro";
import UIString from "@components/UIString.astro";
import TranslatedLink from "@components/TranslatedLink.astro";
+
export interface Props {
articles: CollectionEntry<"blog">[];
length?: number | undefined;
}
const { articles, length = siteconfig.articles.recentLimit } = Astro.props as Props;
+const pageLang = getLanguageFromURL(Astro.url.pathname);
+const filtered = utils.removeDuplicates(articles.slice(0, length), pageLang);
const isEmpty = articles.length === 0;
---
-
+
+
+
-
- {
- !isEmpty ? (
- articles.slice(0, length).map((article) =>
)
- ) : (
-
- )
- }
+ {!isEmpty ? filtered.map((article) =>
) :
}
diff --git a/src/content/blog/en/управление-и-подключение-сдвигового-регистра-74hc595-к-микрокотнороллеру.md b/src/content/blog/en/управление-и-подключение-сдвигового-регистра-74hc595-к-микрокотнороллеру.md
deleted file mode 100644
index 25f1aaa..0000000
--- a/src/content/blog/en/управление-и-подключение-сдвигового-регистра-74hc595-к-микрокотнороллеру.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-coverImage: null
-draft: false
-author: Sergey Yarkov
-title: 74HC595 shift register control by microcontroller
-description: This tutorial shows how to control the shift register of the
- 74HC595 in conjunction with the AVR microcontroller.
-tags:
- - AVR
- - Digital Electronics
- - Tutorial
-pubDate: 2023-02-14T19:23:55.622Z
-updatedDate: 2023-02-14T19:23:55.646Z
----
-
-...
diff --git a/src/i18n/en/ui.ts b/src/i18n/en/ui.ts
index 67dfdd8..37bd267 100644
--- a/src/i18n/en/ui.ts
+++ b/src/i18n/en/ui.ts
@@ -53,6 +53,7 @@ export default {
"form.contactError": "An error occurred while sending. Please try again later.",
/* Error messages */
"error.invalidEmail": "Fill in the field in the e-mail format.",
- /* Other */
- "rss.feed": "RSS Feed",
+ /* Footer */
+ "footer.rssFeed": "RSS Feed",
+ "footer.developed": "Developed",
};
diff --git a/src/i18n/ru/ui.ts b/src/i18n/ru/ui.ts
index 88a8750..08464fa 100644
--- a/src/i18n/ru/ui.ts
+++ b/src/i18n/ru/ui.ts
@@ -54,6 +54,7 @@ export default {
"form.contactError": "При отправке произошла ошибка. Повторите запрос позже.",
/* Error messages */
"error.invalidEmail": "Заполните поле в формате e-mail.",
- /* Other */
- "rss.feed": "RSS Лента",
+ /* Footer */
+ "footer.rssFeed": "RSS Лента",
+ "footer.developed": "Разработка",
};
diff --git a/src/utils/article.ts b/src/utils/article.ts
new file mode 100644
index 0000000..6d12819
--- /dev/null
+++ b/src/utils/article.ts
@@ -0,0 +1,33 @@
+import type { CollectionEntry } from "astro:content";
+import { findDuplicates } from "./string";
+import { removeLanguageCodeFromPath } from "./url";
+
+/**
+ * If there is a translation of an article in the current language of the page,
+ * the remaining articles with other translations should be removed.
+ *
+ * @param entries Array of articles
+ * @param pageLang Current language on page
+ * @returns
+ */
+export function removeDuplicates(
+ entries: CollectionEntry<"blog">[],
+ pageLang: LanguageKeys
+): CollectionEntry<"blog">[] {
+ const ids = entries.map((a) => a.id) as string[];
+ const duplicates = findDuplicates(ids.map((id) => removeLanguageCodeFromPath(id)));
+
+ duplicates.forEach((id) => {
+ const toDeleteIdxs: number[] = [];
+ if (ids.indexOf(`${pageLang}/${id}`) !== -1) {
+ entries.forEach((a, i) => {
+ if (a.id !== `${pageLang}/${id}` && a.id.includes(id)) {
+ toDeleteIdxs.push(i);
+ }
+ });
+ }
+ toDeleteIdxs.forEach((i) => entries.splice(i, 1));
+ });
+
+ return entries;
+}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index b91354b..d2e7e78 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,3 +1,5 @@
export * from "./date";
export * from "./history";
export * from "./url";
+export * from "./string";
+export * from "./article";
diff --git a/src/utils/string.ts b/src/utils/string.ts
index 026d02a..375d569 100644
--- a/src/utils/string.ts
+++ b/src/utils/string.ts
@@ -7,7 +7,11 @@ export function isEmail(email: string): boolean {
}
export function isURL(url: string): boolean {
- return new RegExp(/(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\\/~+#-]*[\w@?^=%&\\/~+#-])/).test(
- url
- );
+ return new RegExp(
+ /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\\/~+#-]*[\w@?^=%&\\/~+#-])/
+ ).test(url);
+}
+
+export function findDuplicates(array: string[]): string[] {
+ return array.filter((item, i) => array.indexOf(item) !== i);
}
diff --git a/src/utils/url.ts b/src/utils/url.ts
index 3b7f4ac..aa806fa 100644
--- a/src/utils/url.ts
+++ b/src/utils/url.ts
@@ -3,3 +3,7 @@ export const encode = (data: object) => {
.map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(data[key]))
.join("&");
};
+
+export function removeLanguageCodeFromPath(path: string) {
+ return path.replace(/^[a-zA-Z-]+\/+/, "");
+}