Skip to content

Commit

Permalink
Merge pull request #12 from nekoya/meta_on_entry
Browse files Browse the repository at this point in the history
Add meta info to an entry
  • Loading branch information
nekoya authored Jan 3, 2022
2 parents 00eda22 + cda4511 commit ecc72be
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
32 changes: 29 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { Box, createTheme, Paper, ThemeProvider } from "@mui/material";
import {
Box,
createTheme,
Divider,
Link,
Paper,
ThemeProvider,
Typography,
} from "@mui/material";
import { blue } from "@mui/material/colors";
import { useState } from "react";
import { Footer } from "./components/Footer";
import { Header } from "./components/Header";
import Example from "./example.mdx";
import Example, { meta } from "./example.mdx";

const theme = createTheme({
palette: {
Expand All @@ -17,6 +26,7 @@ const theme = createTheme({
});

export const App: React.VFC = () => {
const [open, setOpen] = useState(false);
return (
<ThemeProvider theme={theme}>
<Box
Expand All @@ -29,7 +39,23 @@ export const App: React.VFC = () => {
<Header />
<Box m={2} my={4}>
<Paper sx={{ px: 2, py: 0.5 }}>
<Example />
<Typography variant="body2">
{meta.published}
</Typography>
<Typography variant="h6">{meta.title}</Typography>
{open ? (
<Box mt={0.5}>
<Divider />
<Example />
<Link onClick={() => setOpen(false)}>
&raquo; close
</Link>
</Box>
) : (
<Link onClick={() => setOpen(true)}>
&raquo; read more
</Link>
)}
</Paper>
</Box>
<Footer />
Expand Down
5 changes: 4 additions & 1 deletion src/example.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Hello
export const meta = {
title: "Hello",
published: "2022-01-04",
};

## head

Expand Down
6 changes: 6 additions & 0 deletions src/mdx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module "*.mdx" {
export const meta: {
title: string;
published: string;
};
}

0 comments on commit ecc72be

Please sign in to comment.