mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 18:39:14 +03:00
fix href in ArticlItem component
This commit is contained in:
parent
c22d5db80c
commit
9b96539737
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable solid/reactivity */
|
/* eslint-disable solid/reactivity */
|
||||||
import type { Component } from "solid-js";
|
import { Component, createEffect } from "solid-js";
|
||||||
import { createDateFormatter } from "@utils/date";
|
import { createDateFormatter } from "@utils/date";
|
||||||
import "./ArticleItem.scss";
|
import "./ArticleItem.scss";
|
||||||
import { DEFAULT_LANGUAGE } from "@root/config";
|
import { DEFAULT_LANGUAGE } from "@root/config";
|
||||||
@ -12,13 +12,13 @@ export type ArticleItemProps = {
|
|||||||
export const ArticleItem: Component<ArticleItemProps> = (props) => {
|
export const ArticleItem: Component<ArticleItemProps> = (props) => {
|
||||||
const isNonDefaultLanguage = props.data.lang && props.data.lang !== props.lang;
|
const isNonDefaultLanguage = props.data.lang && props.data.lang !== props.lang;
|
||||||
const hrefLangPrefix = props.data.lang && props.data.lang !== DEFAULT_LANGUAGE ? `/${props.data.lang}` : "";
|
const hrefLangPrefix = props.data.lang && props.data.lang !== DEFAULT_LANGUAGE ? `/${props.data.lang}` : "";
|
||||||
|
const href = `${hrefLangPrefix}/blog/${new Date(props.data.published_at).toISOString().split("T")[0]}/${
|
||||||
|
props.data.slug
|
||||||
|
}/`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article itemprop="blogPosts" itemscope itemtype="http://schema.org/BlogPosting" class="article-item">
|
<article itemprop="blogPosts" itemscope itemtype="http://schema.org/BlogPosting" class="article-item">
|
||||||
<a
|
<a href={href}>
|
||||||
href={`${hrefLangPrefix}/blog/${new Date(props.data.published_at).toLocaleDateString("en-CA")}/${
|
|
||||||
props.data.slug
|
|
||||||
}/`}
|
|
||||||
>
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<h3 itemprop="headline">{props.data.title}</h3>
|
<h3 itemprop="headline">{props.data.title}</h3>
|
||||||
{isNonDefaultLanguage && <sup>{props.data.lang.toLocaleUpperCase()}</sup>}
|
{isNonDefaultLanguage && <sup>{props.data.lang.toLocaleUpperCase()}</sup>}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
import PageLayout from "@layouts/default.astro";
|
import PageLayout from "@layouts/default.astro";
|
||||||
import PageHeading from "@components/PageHeading";
|
import PageHeading from "@components/PageHeading";
|
||||||
import ArticlesList from "@components/ArticlesList";
|
import ArticlesList from "@components/ArticlesList";
|
||||||
import { transformArticles, formatToArticleBlocks } from "@utils/articles";
|
import * as utils from "@utils/articles";
|
||||||
import { getLanguageFromURL } from "@root/utils";
|
import { getLanguageFromURL } from "@root/utils";
|
||||||
import { useTranslation } from "@i18n/utils";
|
import { useTranslation } from "@i18n/utils";
|
||||||
import * as API from "@root/lib/api";
|
import * as API from "@root/lib/api";
|
||||||
@ -11,7 +11,7 @@ const t = useTranslation(Astro);
|
|||||||
const data = API.fetchTranslatedArticles(Astro);
|
const data = API.fetchTranslatedArticles(Astro);
|
||||||
const tags = new Set(data.map((article) => article.frontmatter.tags).flat());
|
const tags = new Set(data.map((article) => article.frontmatter.tags).flat());
|
||||||
const lang = getLanguageFromURL(Astro.url.pathname);
|
const lang = getLanguageFromURL(Astro.url.pathname);
|
||||||
const articles = transformArticles(data);
|
const articles = utils.transformArticles(data);
|
||||||
const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
|
const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
|
|||||||
"input.search": t("input.search"),
|
"input.search": t("input.search"),
|
||||||
"articles.empty": t("articles.empty"),
|
"articles.empty": t("articles.empty"),
|
||||||
}}
|
}}
|
||||||
data={{ articles: formatToArticleBlocks(articles), tags: [...tags] }}
|
data={{ articles: utils.formatToArticleBlocks(articles), tags: [...tags] }}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</PageLayout>
|
</PageLayout>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user