From e4019fba593bf49d10a6f1d41e596243321f2908 Mon Sep 17 00:00:00 2001 From: khalilcodes Date: Fri, 15 Apr 2022 13:52:13 +0300 Subject: [PATCH 1/5] frontmatter setup --- site/contentlayer.config.ts | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/site/contentlayer.config.ts b/site/contentlayer.config.ts index 81ec9b6..15e0d31 100644 --- a/site/contentlayer.config.ts +++ b/site/contentlayer.config.ts @@ -1,19 +1,44 @@ -import { defineDocumentType, makeSource } from 'contentlayer/source-files' +import { defineDocumentType, defineNestedType, makeSource } from 'contentlayer/source-files' // import readingTime from 'reading-time' -import remarkGfm from 'remark-gfm'; +import remarkGfm from 'remark-gfm' import rehypeSlug from 'rehype-slug' import rehypeAutolinkHeadings from 'rehype-autolink-headings' import wikiLinkPlugin from "remark-wiki-link-plus" +const ObsidianAliases = defineNestedType(() => ({ + name: 'Obsidian', + filePathPattern: '**/*.md*', + fields: { + title: { type: 'string', required: true } + } +})) + const OtherPage = defineDocumentType(() => ({ name: 'OtherPage', filePathPattern: '**/*.md*', contentType: 'mdx', fields: { - title: { type: 'string', required: false }, - date: { type: 'string', required: false }, - authors: { type: 'string', required: false }, - description: { type: 'string', required: false }, + title: { type: 'string' }, + date: { type: "date", description: "This will be the publication date" }, + image: { type: "string" }, + description: { type: 'string' }, + youtube: { type: "string" }, + podcast: { type: "string" }, + featured: { type: "boolean", default: false }, + created: { type: "date", description: "The date this page was created (For internal use)" }, + aliases: { type: 'reference', of: ObsidianAliases } + }, + computedFields: { + date: { + type: "date", + resolve: (doc) => new Date(doc.date).toLocaleDateString('en-US', { + weekday: "long", year: "numeric", month: "long", day: "numeric" + }) + }, + created: { + type: "date", + resolve: (doc) => new Date(doc.created).toLocaleDateString('en-US') + }, } })); From f49bcb9e1eac935d159848b2a5b70047ce1ad137 Mon Sep 17 00:00:00 2001 From: khalilcodes Date: Fri, 15 Apr 2022 13:54:06 +0300 Subject: [PATCH 2/5] add site url --- site/config/siteConfig.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site/config/siteConfig.js b/site/config/siteConfig.js index 52dcba9..e82ddf8 100644 --- a/site/config/siteConfig.js +++ b/site/config/siteConfig.js @@ -2,9 +2,10 @@ import Logo from "../public/img/life-itself-logo.svg" const siteConfig = { title: "Making Sense of Crypto and Web3", + url: "https://web3.lifeitself.us", tagline: "", description: - "Introductions to key concepts and ideas in crypto and web3. Plus in-depth evaluation of its potential impact.", + "Introductions to key concepts and ideas in crypto and web3. Plus in-depth evaluation of its potential impact.", author: "Life Itself and collaborators", // logo image authorLogo: "/img//life-itself-logo.svg", From 1e90dc44b12bd6556895decd9c3c7d948501e594 Mon Sep 17 00:00:00 2001 From: khalilcodes Date: Fri, 15 Apr 2022 13:56:05 +0300 Subject: [PATCH 3/5] display frontmatter fields on page and add seo --- site/components/MDX.js | 58 +++++++++++++++++++++++++++++++++++++---- site/pages/[...slug].js | 34 +++++++++++++++++++----- 2 files changed, 80 insertions(+), 12 deletions(-) diff --git a/site/components/MDX.js b/site/components/MDX.js index 5096e26..a6ec2d0 100644 --- a/site/components/MDX.js +++ b/site/components/MDX.js @@ -1,4 +1,5 @@ import Head from 'next/head' +import ReactPlayer from 'react-player/lazy' import { Paragraph } from './Link' const components = { @@ -8,20 +9,67 @@ const components = { export default function MdxPage({ children }) { const { Component, frontmatter } = children + + let podcastEmbed + + if (frontmatter.podcast && frontmatter.podcast.includes("life-itself")) { + const url = frontmatter.podcast + podcastEmbed = ([ + url.slice(0, "https://anchor.fm/life-itself".length), + "/embed", + url.slice("https://anchor.fm/life-itself".length) + ].join("")) + } return (
-

{frontmatter.title}

+ {frontmatter.title &&

{frontmatter.title}

} {frontmatter.authors && ( -

{frontmatter.authors}

+
+

{frontmatter.authors}

+
)} {frontmatter.date && ( -

{frontmatter.date}

+

+ on {frontmatter.date} +

)} {frontmatter.description && ( -

frontmatter.description}

+

{frontmatter.description}

+ )} + {frontmatter.youtube && ( +
+ +
+ )} + {frontmatter.podcast && ( +
+ + {podcastEmbed && ( +
+