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';
|
import { SITE, OPEN_GRAPH } from '../config';
|
||||||
export interface Props {
|
export interface Props {
|
||||||
content: any;
|
frontmatter: any;
|
||||||
site: any;
|
site: any;
|
||||||
canonicalURL: URL | string;
|
canonicalURL: URL | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||||
const { content = {} } = Astro.props;
|
const { frontmatter = {} } = Astro.props;
|
||||||
const formattedContentTitle = content.title ? `${content.title} 🚀 ${SITE.title}` : SITE.title;
|
const formattedContentTitle = frontmatter.title ? `${frontmatter.title} 🚀 ${SITE.title}` : SITE.title;
|
||||||
const imageSrc = content?.image?.src ?? OPEN_GRAPH.image.src;
|
const imageSrc = frontmatter?.image?.src ?? OPEN_GRAPH.image.src;
|
||||||
const canonicalImageSrc = new URL(imageSrc, Astro.site);
|
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 -->
|
<!-- Page Metadata -->
|
||||||
|
@ -21,13 +21,13 @@ const imageAlt = content?.image?.alt ?? OPEN_GRAPH.image.alt;
|
||||||
<meta property="og:title" content={formattedContentTitle} />
|
<meta property="og:title" content={formattedContentTitle} />
|
||||||
<meta property="og:type" content="article" />
|
<meta property="og:type" content="article" />
|
||||||
<meta property="og:url" content={canonicalURL} />
|
<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" content={canonicalImageSrc} />
|
||||||
<meta property="og:image:alt" content={imageAlt} />
|
<meta property="og:image:alt" content={imageAlt} />
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
property="og: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} />
|
<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:title" content={formattedContentTitle} />
|
||||||
<meta
|
<meta
|
||||||
name="twitter:description"
|
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" content={canonicalImageSrc} />
|
||||||
<meta name="twitter:image:alt" content={imageAlt} />
|
<meta name="twitter:image:alt" content={imageAlt} />
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
import MoreMenu from '../RightSidebar/MoreMenu.astro';
|
import MoreMenu from '../RightSidebar/MoreMenu.astro';
|
||||||
import TableOfContents from '../RightSidebar/TableOfContents';
|
import TableOfContents from '../RightSidebar/TableOfContents';
|
||||||
|
|
||||||
const { content, headings, githubEditUrl } = Astro.props;
|
const { frontmatter, headings, githubEditUrl } = Astro.props;
|
||||||
const title = content.title;
|
const title = frontmatter.title;
|
||||||
---
|
---
|
||||||
|
|
||||||
<article id="article" class="content">
|
<article id="article" class="content">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
import TableOfContents from './TableOfContents';
|
import TableOfContents from './TableOfContents';
|
||||||
import MoreMenu from './MoreMenu.astro';
|
import MoreMenu from './MoreMenu.astro';
|
||||||
const { content, headings, githubEditUrl } = Astro.props;
|
const { headings, githubEditUrl } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<nav class="sidebar-nav" aria-labelledby="grid-right">
|
<nav class="sidebar-nav" aria-labelledby="grid-right">
|
||||||
|
|
|
@ -2,24 +2,23 @@
|
||||||
import HeadCommon from '../components/HeadCommon.astro';
|
import HeadCommon from '../components/HeadCommon.astro';
|
||||||
import HeadSEO from '../components/HeadSEO.astro';
|
import HeadSEO from '../components/HeadSEO.astro';
|
||||||
import Header from '../components/Header/Header.astro';
|
import Header from '../components/Header/Header.astro';
|
||||||
import Footer from '../components/Footer/Footer.astro';
|
|
||||||
import PageContent from '../components/PageContent/PageContent.astro';
|
import PageContent from '../components/PageContent/PageContent.astro';
|
||||||
import LeftSidebar from '../components/LeftSidebar/LeftSidebar.astro';
|
import LeftSidebar from '../components/LeftSidebar/LeftSidebar.astro';
|
||||||
import RightSidebar from '../components/RightSidebar/RightSidebar.astro';
|
import RightSidebar from '../components/RightSidebar/RightSidebar.astro';
|
||||||
import * as CONFIG from '../config';
|
import * as CONFIG from '../config';
|
||||||
|
|
||||||
const { content = {} } = Astro.props;
|
const { frontmatter = {}, headings } = Astro.props;
|
||||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||||
const currentPage = Astro.url.pathname;
|
const currentPage = Astro.url.pathname;
|
||||||
const currentFile = `src/pages${currentPage.replace(/\/$/, '')}.md`;
|
const currentFile = `src/pages${currentPage.replace(/\/$/, '')}.md`;
|
||||||
const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + currentFile;
|
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>
|
<head>
|
||||||
<HeadCommon />
|
<HeadCommon />
|
||||||
<HeadSEO {content} canonicalURL={canonicalURL} />
|
<HeadSEO {frontmatter} canonicalURL={canonicalURL} />
|
||||||
<title>{content.title ? `${content.title} 🚀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}</title>
|
<title>{frontmatter.title ? `${frontmatter.title} 🚀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -111,12 +110,12 @@ const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + current
|
||||||
<LeftSidebar {currentPage} />
|
<LeftSidebar {currentPage} />
|
||||||
</aside>
|
</aside>
|
||||||
<div id="grid-main">
|
<div id="grid-main">
|
||||||
<PageContent {content} {githubEditUrl}>
|
<PageContent {frontmatter} {headings} {githubEditUrl}>
|
||||||
<slot />
|
<slot />
|
||||||
</PageContent>
|
</PageContent>
|
||||||
</div>
|
</div>
|
||||||
<aside id="grid-right" class="grid-sidebar" title="Table of Contents">
|
<aside id="grid-right" class="grid-sidebar" title="Table of Contents">
|
||||||
<RightSidebar {content} {githubEditUrl} />
|
<RightSidebar {headings} {githubEditUrl} />
|
||||||
</aside>
|
</aside>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue