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