Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

2.8 KB
Raw Blame
---
import Container from "@/components/container.astro";
import { getFormattedDate } from "@/utils/all";
import { getLocalizedPath, getSiteLocale, siteCopy } from "@/i18n";
import Layout from "./Layout.astro";

const { frontmatter, backHref, backLabel, schemaType = "BlogPosting" } = Astro.props;
const canonicalURL = new URL(Astro.url.pathname, Astro.site).toString();
const imageUrl = new URL(frontmatter.image.src, Astro.site).toString();
const locale = getSiteLocale(Astro.url.pathname);
const fallbackBackHref = getLocalizedPath(locale, "/blog");
const fallbackBackLabel = siteCopy[locale].nav.backToBlog;

const articleJsonLd = {
  "@context": "https://schema.org",
  "@type": schemaType,
  headline: frontmatter.title,
  description: frontmatter.snippet,
  image: imageUrl,
  datePublished: frontmatter.publishDate.toISOString(),
  dateModified: frontmatter.publishDate.toISOString(),
  author: {
    "@type": "Organization",
    name: frontmatter.author,
  },
  publisher: {
    "@type": "Organization",
    name: "EdgeEver",
    url: new URL("/", Astro.site).toString(),
  },
  mainEntityOfPage: {
    "@type": "WebPage",
    "@id": canonicalURL,
  },
};
---

<Layout
  title={frontmatter.title}
  description={frontmatter.snippet}
  image={frontmatter.image.src}
  imageAlt={frontmatter.image.alt}
  openGraphType="article"
  articlePublishedTime={frontmatter.publishDate.toISOString()}
  articleModifiedTime={frontmatter.publishDate.toISOString()}
  articleAuthor={frontmatter.author}
  articleSection={frontmatter.category}
  articleTags={frontmatter.tags}
  jsonLd={articleJsonLd}
>
  <Container>
    <div class="mx-auto max-w-[735px] mt-14">
      <span class="text-blue-400 uppercase tracking-wider text-sm font-medium">
        {frontmatter.category}
      </span>
      <h1
        class="text-4xl lg:text-5xl font-bold lg:tracking-tight mt-1 lg:leading-tight">
        {frontmatter.title}
      </h1>
      <div class="flex gap-2 mt-3 items-center flex-wrap md:flex-nowrap">
        <span class="text-gray-400">
          {frontmatter.author}
        </span>
        <span class="text-gray-400">•</span>
        <time class="text-gray-400" datetime={frontmatter.publishDate}>
          {getFormattedDate(frontmatter.publishDate)}
        </time>
        <span class="text-gray-400 hidden md:block">•</span>
        <div class="w-full md:w-auto flex flex-wrap gap-3">
          {
            frontmatter.tags.map((tag) => (
              <span class="text-sm text-gray-500">#{tag}</span>
            ))
          }
        </div>
      </div>
    </div>

    <div class="mx-auto prose prose-lg mt-6">
      <slot />
    </div>
    <div class="text-center mt-8">
      <a
        href={backHref ?? fallbackBackHref}
        class="bg-gray-100 px-5 py-3 rounded-md hover:bg-gray-200 transition"
        >{backLabel ?? fallbackBackLabel}</a
      >
    </div>
  </Container>
</Layout>