fix: content -> frontmatter, content.headings -> headings (#4294)
This commit is contained in:
parent
b1bd52e9ea
commit
5fe46d946a
4 changed files with 17 additions and 18 deletions
|
@ -1,17 +1,17 @@
|
|||
---
|
||||
import { SITE, OPEN_GRAPH } from '../config';
|
||||
export interface Props {
|
||||
content: any;
|
||||
frontmatter: any;
|
||||
site: any;
|
||||
canonicalURL: URL | string;
|
||||
}
|
||||
|
||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||
const { content = {} } = Astro.props;
|
||||
const formattedContentTitle = content.title ? `${content.title} 🚀 ${SITE.title}` : SITE.title;
|
||||
const imageSrc = content?.image?.src ?? OPEN_GRAPH.image.src;
|
||||
const { frontmatter = {} } = Astro.props;
|
||||
const formattedContentTitle = frontmatter.title ? `${frontmatter.title} 🚀 ${SITE.title}` : SITE.title;
|
||||
const imageSrc = frontmatter?.image?.src ?? OPEN_GRAPH.image.src;
|
||||
const canonicalImageSrc = new URL(imageSrc, Astro.site);
|
||||
const imageAlt = content?.image?.alt ?? OPEN_GRAPH.image.alt;
|
||||
const imageAlt = frontmatter?.image?.alt ?? OPEN_GRAPH.image.alt;
|
||||
---
|
||||
|
||||
<!-- Page Metadata -->
|
||||
|
@ -21,13 +21,13 @@ const imageAlt = content?.image?.alt ?? OPEN_GRAPH.image.alt;
|
|||
<meta property="og:title" content={formattedContentTitle} />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content={canonicalURL} />
|
||||
<meta property="og:locale" content={content.ogLocale ?? SITE.defaultLanguage} />
|
||||
<meta property="og:locale" content={frontmatter.ogLocale ?? SITE.defaultLanguage} />
|
||||
<meta property="og:image" content={canonicalImageSrc} />
|
||||
<meta property="og:image:alt" content={imageAlt} />
|
||||
<meta
|
||||
name="description"
|
||||
property="og:description"
|
||||
content={content.description ? content.description : SITE.description}
|
||||
content={frontmatter.description ? frontmatter.description : SITE.description}
|
||||
/>
|
||||
<meta property="og:site_name" content={SITE.title} />
|
||||
|
||||
|
@ -37,7 +37,7 @@ const imageAlt = content?.image?.alt ?? OPEN_GRAPH.image.alt;
|
|||
<meta name="twitter:title" content={formattedContentTitle} />
|
||||
<meta
|
||||
name="twitter:description"
|
||||
content={content.description ? content.description : SITE.description}
|
||||
content={frontmatter.description ? frontmatter.description : SITE.description}
|
||||
/>
|
||||
<meta name="twitter:image" content={canonicalImageSrc} />
|
||||
<meta name="twitter:image:alt" content={imageAlt} />
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
import MoreMenu from '../RightSidebar/MoreMenu.astro';
|
||||
import TableOfContents from '../RightSidebar/TableOfContents';
|
||||
|
||||
const { content, headings, githubEditUrl } = Astro.props;
|
||||
const title = content.title;
|
||||
const { frontmatter, headings, githubEditUrl } = Astro.props;
|
||||
const title = frontmatter.title;
|
||||
---
|
||||
|
||||
<article id="article" class="content">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
import TableOfContents from './TableOfContents';
|
||||
import MoreMenu from './MoreMenu.astro';
|
||||
const { content, headings, githubEditUrl } = Astro.props;
|
||||
const { headings, githubEditUrl } = Astro.props;
|
||||
---
|
||||
|
||||
<nav class="sidebar-nav" aria-labelledby="grid-right">
|
||||
|
|
|
@ -2,24 +2,23 @@
|
|||
import HeadCommon from '../components/HeadCommon.astro';
|
||||
import HeadSEO from '../components/HeadSEO.astro';
|
||||
import Header from '../components/Header/Header.astro';
|
||||
import Footer from '../components/Footer/Footer.astro';
|
||||
import PageContent from '../components/PageContent/PageContent.astro';
|
||||
import LeftSidebar from '../components/LeftSidebar/LeftSidebar.astro';
|
||||
import RightSidebar from '../components/RightSidebar/RightSidebar.astro';
|
||||
import * as CONFIG from '../config';
|
||||
|
||||
const { content = {} } = Astro.props;
|
||||
const { frontmatter = {}, headings } = Astro.props;
|
||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||
const currentPage = Astro.url.pathname;
|
||||
const currentFile = `src/pages${currentPage.replace(/\/$/, '')}.md`;
|
||||
const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + currentFile;
|
||||
---
|
||||
|
||||
<html dir={content.dir ?? 'ltr'} lang={content.lang ?? 'en-us'} class="initial">
|
||||
<html dir={frontmatter.dir ?? 'ltr'} lang={frontmatter.lang ?? 'en-us'} class="initial">
|
||||
<head>
|
||||
<HeadCommon />
|
||||
<HeadSEO {content} canonicalURL={canonicalURL} />
|
||||
<title>{content.title ? `${content.title} 🚀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}</title>
|
||||
<HeadSEO {frontmatter} canonicalURL={canonicalURL} />
|
||||
<title>{frontmatter.title ? `${frontmatter.title} 🚀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}</title>
|
||||
<style>
|
||||
body {
|
||||
width: 100%;
|
||||
|
@ -111,12 +110,12 @@ const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + current
|
|||
<LeftSidebar {currentPage} />
|
||||
</aside>
|
||||
<div id="grid-main">
|
||||
<PageContent {content} {githubEditUrl}>
|
||||
<PageContent {frontmatter} {headings} {githubEditUrl}>
|
||||
<slot />
|
||||
</PageContent>
|
||||
</div>
|
||||
<aside id="grid-right" class="grid-sidebar" title="Table of Contents">
|
||||
<RightSidebar {content} {githubEditUrl} />
|
||||
<RightSidebar {headings} {githubEditUrl} />
|
||||
</aside>
|
||||
</main>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue