f/basic-mdx-components #9

Merged
Skydust merged 7 commits from f/basic-mdx-components into dev 2023-09-09 23:01:32 +00:00
7 changed files with 81 additions and 5 deletions
Showing only changes of commit 412ab0810d - Show all commits

View File

@@ -6,6 +6,7 @@ import type { Template, TinaTemplate } from "tinacms";
import { PageBlocksCarousel, PageBlocksContent } from "../../tina/__generated__/types"; import { PageBlocksCarousel, PageBlocksContent } from "../../tina/__generated__/types";
import { tinaField } from "tinacms/dist/react"; import { tinaField } from "tinacms/dist/react";
import { PageBlockFunction } from "../blocks-renderer"; import { PageBlockFunction } from "../blocks-renderer";
import { components } from "../posts/post";
export const Content: PageBlockFunction<PageBlocksContent> = ({ data }) => { export const Content: PageBlockFunction<PageBlocksContent> = ({ data }) => {
return ( return (
@@ -18,7 +19,7 @@ export const Content: PageBlockFunction<PageBlocksContent> = ({ data }) => {
size="large" size="large"
width="medium" width="medium"
> >
<TinaMarkdown content={ data.body } /> <TinaMarkdown components={ components } content={ data.body } />
</Container> </Container>
</Section> </Section>
); );
@@ -35,9 +36,74 @@ export const contentBlockSchema: Template = {
}, },
fields: [ fields: [
{ {
type: "rich-text", type: "rich-text",
label: "Body", label: "Body",
name: "body" name: "body",
templates: [
{
name: "DateTime",
label: "Date & Time",
inline: true,
fields: [
{
name: "format",
label: "Format",
type: "string",
options: ["utc", "iso", "local"]
}
]
},
{
name: "BlockQuote",
label: "Block Quote",
fields: [
{
name: "children",
label: "Quote",
type: "rich-text"
},
{
name: "authorName",
label: "Author",
type: "string"
}
]
},
{
name: "NewsletterSignup",
label: "Newsletter Sign Up",
fields: [
{
name: "children",
label: "CTA",
type: "rich-text"
},
{
name: "placeholder",
label: "Placeholder",
type: "string"
},
{
name: "buttonText",
label: "Button Text",
type: "string"
},
{
name: "disclaimer",
label: "Disclaimer",
type: "rich-text"
}
],
ui: {
defaultItem: {
placeholder: "Enter your email",
buttonText: "Notify Me"
}
}
}
],
isBody: true
}, },
{ {
type: "string", type: "string",

View File

@@ -21,7 +21,7 @@ import type { TinaMarkdownContent, Components } from "tinacms/dist/rich-text";
import { PostType } from "../../pages/posts/[filename]"; import { PostType } from "../../pages/posts/[filename]";
import { tinaField } from "tinacms/dist/react"; import { tinaField } from "tinacms/dist/react";
const components: Components<{ export const components: Components<{
BlockQuote: { BlockQuote: {
children: TinaMarkdownContent; children: TinaMarkdownContent;
authorName: string; authorName: string;

View File

@@ -9,6 +9,9 @@ blocks:
text: Découvrez-en plus ! text: Découvrez-en plus !
linkTo: main-page linkTo: main-page
_template: carousel _template: carousel
- body: |
aezaeaezae<DateTime format="iso" />dzds
_template: content
- headline: Welcome to the Tina Starter - headline: Welcome to the Tina Starter
text: > text: >
This project is set up to show you the basics of working with Tina. You're This project is set up to show you the basics of working with Tina. You're
@@ -78,4 +81,10 @@ blocks:

View File

@@ -19,7 +19,7 @@ export default function HomePage(
export const getStaticProps = async ({ params }) => { export const getStaticProps = async ({ params }) => {
const tinaProps = await client.queries.contentQuery({ const tinaProps = await client.queries.contentQuery({
relativePath: `${ params.filename }.md` relativePath: `${ params.filename }.mdx`
}); });
const props = { const props = {
...tinaProps, ...tinaProps,

View File

@@ -183,6 +183,7 @@ const config = defineConfig({
label: "Pages", label: "Pages",
name: "page", name: "page",
path: "content/pages", path: "content/pages",
format: "mdx",
ui: { ui: {
router: ({ document }) => { router: ({ document }) => {
if (document._sys.filename === "home") { if (document._sys.filename === "home") {

File diff suppressed because one or more lines are too long