Skip to content

Commit

Permalink
feat(*): add arm version of general quotes and homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
vre2h committed Jun 4, 2022
1 parent 6f65c7d commit f2a5aed
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 73 deletions.
10 changes: 4 additions & 6 deletions components/Bio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ExternalLink = ({ href, children }) => (
</a>
);

export default function Bio() {
export default function Bio({ description, social, socialDivider }) {
return (
<div className="mb-16 mt-4">
<div className="flex items-center">
Expand All @@ -26,15 +26,13 @@ export default function Bio() {
/>
</div>
<h2 className="ml-4 text-gray-600 dark:text-gray-400">
I’m a software engineer, lecturer, and rebel. Here I write about
education, management, and the art of non-conformity.
<br />
{description} <br />
<div className="hidden md:block mt-4">
Subscribe in{" "}
{social}{" "}
<ExternalLink href="https://t.me/oganisyancom">
Telegram
</ExternalLink>{" "}
or{" "}
{socialDivider}{" "}
<ExternalLink href="https://twitter.com/vre2h">
Twitter
</ExternalLink>
Expand Down
16 changes: 12 additions & 4 deletions components/BlogPost.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { format, parseISO } from "date-fns";
import Link from "next/link";
import formatNumber from "comma-number";
import { useRouter } from "next/router";
import useSWR from "swr";

import ColoredTag from "./ColoredTag";
import fetcher from "../lib/fetcher";
import { CommonTranslations } from "../constants/i18n/translations";
import { Locales } from "../helpers/locale.helpers";

const BlogPost = ({ title, summary, slug, date, tags }) => {
const { data } = useSWR(`/api/views?slug=${slug}`, fetcher);
Expand All @@ -21,13 +22,20 @@ const BlogPost = ({ title, summary, slug, date, tags }) => {
{title}
</h4>
<p className="text-gray-400 text-left text-sm sm:text-right hidden sm:block w-32 mb-4 sm:mb-0">
{views ? `${views > 300 ? "🔥" : ""} ${views}` : "–––"} views
{views ? `${views > 300 ? "🔥" : ""} ${views}` : "–––"}{" "}
{CommonTranslations[locale].views.toLowerCase()}
</p>
</div>
<p className="text-gray-600 dark:text-gray-400">{summary}</p>
<p className="text-gray-400 text-sm text-left mt-2 sm:mb-0">
<span className="text-left">
Published on {format(parseISO(date), "MMMM dd, yyyy")}{" "}
{CommonTranslations[locale].published}{" "}
{new Intl.DateTimeFormat(
locale === Locales.am ? "hy-AM" : locale,
{
dateStyle: "long",
}
).format(new Date(date))}
<div className="hidden sm:inline-block">
{tags && ` • `}{" "}
{tags &&
Expand All @@ -41,7 +49,7 @@ const BlogPost = ({ title, summary, slug, date, tags }) => {
{views && views > 2
? `${views > 300 ? "🔥" : ""} ${formatNumber(views)}`
: "–––"}{" "}
views
{CommonTranslations[locale].views.toLowerCase}
</span>
</p>
</div>
Expand Down
9 changes: 5 additions & 4 deletions components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from "next/link";
import { useRouter } from "next/router";
import { CommonTranslations } from "../constants/i18n/translations";

import BasicLink from "./BasicLink";

Expand All @@ -24,16 +25,16 @@ export default function Footer() {
<div className="w-full max-w-xl grid grid-cols-1 gap-4 pb-16 grid-cols-2 sm:grid-cols-3">
<div className="flex justify-start items-start transition flex-col space-y-4">
<Link locale={locale} href="/" passHref>
<BasicLink>Home</BasicLink>
<BasicLink>{CommonTranslations[locale].home}</BasicLink>
</Link>
<Link locale={locale} href="/about" passHref>
<BasicLink>About</BasicLink>
<BasicLink>{CommonTranslations[locale].about}</BasicLink>
</Link>
<Link locale={locale} href="/projects" passHref>
<BasicLink>Projects</BasicLink>
<BasicLink>{CommonTranslations[locale].projects}</BasicLink>
</Link>
<Link locale={locale} href="/uses" passHref>
<BasicLink>Uses</BasicLink>
<BasicLink>{CommonTranslations[locale].uses}</BasicLink>
</Link>
<Link locale={locale} href="/rss.xml" passHref>
<BasicLink>RSS</BasicLink>
Expand Down
56 changes: 40 additions & 16 deletions components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,28 @@ import useWindowSize from "../lib/useWindowSize";

import { Burger, Close, ExternalIcon } from "./Icons";
import Footer from "./Footer";
import { CommonTranslations } from "../constants/i18n/translations";

const links = [
const getLinks = (locale) => [
{
text: "Blog",
text: CommonTranslations[locale].blog,
href: "/",
},
{
text: "Projects",
text: CommonTranslations[locale].projects,
href: "/projects",
},
{
text: "Talks",
text: CommonTranslations[locale].talks,
href: "/talks",
},
{
text: "About",
text: CommonTranslations[locale].about,
href: "/about",
},
];

export default function Container({ children }) {
export default function Container({ children, pageUrl }) {
const [mounted, setMounted] = useState(false);
const [isMenuVisible, setMenuVisibility] = useState(false);
const { theme, setTheme } = useTheme();
Expand Down Expand Up @@ -76,10 +77,13 @@ export default function Container({ children }) {
// After mounting, we have access to the theme
useEffect(() => setMounted(true), []);

const hasTranslation =
pageUrl.includes("how-to-learn-js") || pageUrl.includes("home");

const Menu = ({ classNames }) => {
return (
<div className={cn(classNames, "overflow-visible")}>
{links.map(({ href, text }, idx) => {
{getLinks(locale).map(({ href, text }, idx) => {
const isActiveLink =
href === "/"
? history.pathname === href || history.pathname.includes("blog")
Expand Down Expand Up @@ -126,7 +130,7 @@ export default function Container({ children }) {
}
)}
>
Library
{CommonTranslations[locale].library}
</span>
{dropDown && (
<div className="sm:shadow-2xl sm:absolute right-0 mt-2 py-2 w-32 w-full sm:w-48 sm:bg-white dark:bg-gray-700 sm:rounded-md sm:shadow-xl z-20">
Expand All @@ -135,15 +139,15 @@ export default function Container({ children }) {
className="block px-4 py-2 dark:prose-dark text-sm capitalize text-gray-700
hover:bg-gray-500 dark:hover:bg-white dark:hover:text-black hover:text-white"
>
Slides
{CommonTranslations[locale].slides}
</a>
</Link>
<Link locale={locale} href="/library/books">
<a
className="block px-4 py-2 dark:prose-dark text-sm capitalize text-gray-700
hover:bg-gray-500 dark:hover:bg-white dark:hover:text-black hover:text-white"
>
Books
{CommonTranslations[locale].books}
</a>
</Link>
<a
Expand All @@ -153,7 +157,7 @@ export default function Container({ children }) {
className="flex justify-between px-4 dark:prose-dark py-2 text-sm capitalize text-gray-700
hover:bg-gray-500 dark:hover:bg-white dark:hover:text-black hover:text-white"
>
Movies
{CommonTranslations[locale].movies}
<ExternalIcon />
</a>
<a
Expand All @@ -163,7 +167,7 @@ export default function Container({ children }) {
className="flex justify-between px-4 dark:prose-dark py-2 text-sm capitalize text-gray-700
hover:bg-gray-500 dark:hover:bg-white dark:hover:text-black hover:text-white"
>
TV Shows
{CommonTranslations[locale].tvShows}
<ExternalIcon />
</a>
</div>
Expand All @@ -175,11 +179,19 @@ export default function Container({ children }) {

return (
<>
{locale === Locales.am && (
<ColoredBar>🇦🇲 Հայերեն թարգմանությունները դեռ պատրաստ չեն։</ColoredBar>
{locale === Locales.am && !hasTranslation && (
<ColoredBar>🇦🇲 Այս էջը դեռ թարգմանված չէ։</ColoredBar>
)}
<div className="bg-white dark:bg-black py-2 px-8">
<div className="flex justify-end items-center max-w-xl w-full mx-auto bg-white dark:bg-black">
<div
className={cn(
"flex justify-end items-center w-full mx-auto bg-white dark:bg-black",
{
"max-w-2xl": locale === Locales.am,
"max-w-xl": locale === Locales.en,
}
)}
>
<a
className={cn(
"p-1 duration-300 text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 cursor-pointer",
Expand All @@ -206,7 +218,15 @@ export default function Container({ children }) {
հայ
</a>
</div>
<nav className="flex justify-between items-center max-w-xl w-full py-4 pt-2 pb-8 my-0 mx-auto bg-white dark:bg-black bg-opacity-60">
<nav
className={cn(
"flex justify-between items-center w-full py-4 pt-2 pb-8 my-0 mx-auto bg-white dark:bg-black bg-opacity-60",
{
"max-w-2xl": locale === Locales.am,
"max-w-xl": locale === Locales.en,
}
)}
>
<Menu classNames={cn("hidden sm:block")} />

<div ref={mobileMenuRef}>
Expand Down Expand Up @@ -269,3 +289,7 @@ export default function Container({ children }) {
</>
);
}

Container.defaultProps = {
pageUrl: "",
};
4 changes: 2 additions & 2 deletions components/ViewCounter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useSWR from "swr";

import fetcher from "../lib/fetcher";

export default function ViewCounter({ slug }) {
export default function ViewCounter({ slug, postfix }) {
const { data } = useSWR(`/api/views?slug=${slug}`, fetcher);
const views = data?.total;

Expand All @@ -20,5 +20,5 @@ export default function ViewCounter({ slug }) {

return `${
views && views > 2 ? `${views > 300 ? "🔥" : ""} ${format(views)}` : "–––"
} views`;
} ${postfix.toLowerCase()}`;
}
57 changes: 57 additions & 0 deletions constants/i18n/translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export const CommonTranslations = {
"en-US": {
home: "Home",
articles: "Articles",
blog: "Blog",
talks: "Talks",
about: "About",
library: "Library",
slides: "Slides",
books: "Books",
movies: "Movies",
tvShows: "TV Shows",
views: "Views",
published: "Published on",
projects: "Projects",
uses: "Uses",
support: "Support Author",
otherArticles: "You might also like",
readingTime: "min read",

me: {
name: "Vrezh Oganisyan",
social: "Subscribe in",
socialDivider: "or",
title: "👋 Hey, I’m Vrezh",
description:
"I’m a software engineer, lecturer, and rebel. Here I write about education, management, and the art of non-conformity.",
},
},
am: {
home: "Գլխավոր",
articles: "Հոդվածներ",
blog: "Բլոգ",
talks: "Ելույթներ",
about: "Իմ մասին",
library: "Գրադարան",
slides: "Սլայդներ",
books: "Գրքեր",
movies: "Ֆիլմեր",
tvShows: "Սերիալներ",
views: "Դիտում",
published: "Հրապարակվել է",
projects: "Նախագծեր",
uses: "Իմ դեվայսները",
support: "Աջակցել հեղինակին",
otherArticles: "Ձեզ դուր կգան՝",
readingTime: "րոպե ընթերձել",
me: {
name: "Վրեժ Օգանիսյան",
social: "Բաժանորդագրվել",
socialDivider: "կամ",
title: "👋 Ողջույն",
description:
"I’m a software engineer, lecturer, and rebel. Here I write about education, management, and the art of non-conformity.",
},
},
};
Loading

0 comments on commit f2a5aed

Please sign in to comment.