diff --git a/astro.config.mjs b/astro.config.mjs
index 0c6ce25..9991a20 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -1,8 +1,3 @@
-import { defineConfig } from "astro/config";
-import { h } from "hastscript";
-import { toString } from "hast-util-to-string";
-import { escape } from "html-escaper";
-
/**
* Integrations
*/
@@ -24,6 +19,14 @@ import remarkSmartypants from "remark-smartypants";
import rehypeSlug from "rehype-slug";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
+/**
+ * Other required modules
+ */
+import { defineConfig } from "astro/config";
+import { h } from "hastscript";
+import { toString } from "hast-util-to-string";
+import { escape } from "html-escaper";
+
const createAnchorLabel = (heading) => {
const node = h("span.anchor-label", escape(heading));
node.properties["is:raw"] = true;
@@ -41,11 +44,14 @@ export default defineConfig({
locales: {
ru: "ru",
en: "en",
+ de: "de",
},
},
}),
image(),
- compress(),
+ compress({
+ img: false,
+ }),
mdx({
remarkPlugins: [remarkGfm, remarkSmartypants],
rehypePlugins: [
diff --git a/src/components/AlternateLangLink/AlternateLangLink.astro b/src/components/AlternateLangLink/AlternateLangLink.astro
new file mode 100644
index 0000000..9481056
--- /dev/null
+++ b/src/components/AlternateLangLink/AlternateLangLink.astro
@@ -0,0 +1,30 @@
+---
+/**
+ * This components is used in article layout to display links in alternative lanugages.
+ */
+import { DEFAULT_LANGUAGE } from "@root/config";
+import { getLanguageFromURL } from "@root/utils";
+
+export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {
+ lang: LanguageKeys;
+}
+
+const { pathname } = Astro.url;
+const siteLang = getLanguageFromURL(pathname);
+const { lang, ...attrs } = Astro.props as Props;
+let href: string;
+if (lang === DEFAULT_LANGUAGE) {
+ href = `/${pathname.split("/").slice(2).join("/")}`;
+} else {
+ href = `/${lang}/`;
+ if (siteLang !== DEFAULT_LANGUAGE) {
+ href += `${pathname.split("/").slice(2).join("/")}`;
+ } else {
+ href += `${pathname.split("/").slice(1).join("/")}`;
+ }
+}
+---
+
+
+
+
diff --git a/src/components/AlternateLangLink/index.ts b/src/components/AlternateLangLink/index.ts
new file mode 100644
index 0000000..49f0896
--- /dev/null
+++ b/src/components/AlternateLangLink/index.ts
@@ -0,0 +1 @@
+export { default } from "./AlternateLangLink.astro";
diff --git a/src/components/ArticleItem/ArticleItem.tsx b/src/components/ArticleItem/ArticleItem.tsx
index 0c0e074..4051a13 100644
--- a/src/components/ArticleItem/ArticleItem.tsx
+++ b/src/components/ArticleItem/ArticleItem.tsx
@@ -11,7 +11,7 @@ export type ArticleItemProps = {
export const ArticleItem: Component = (props) => {
const isNonDefaultLanguage = props.data.lang && props.data.lang !== props.lang;
- const hrefLangPrefix = props.data.lang && props.data.lang !== DEFAULT_LANGUAGE ? "/en" : "";
+ const hrefLangPrefix = props.data.lang && props.data.lang !== DEFAULT_LANGUAGE ? `/${props.data.lang}` : "";
return (