mirror of
https://github.com/MaggieAppleton/digital-gardeners.git
synced 2024-11-22 01:19:45 +01:00
switched to mdx
This commit is contained in:
parent
1d7be78e38
commit
67b393a1f0
|
@ -6,7 +6,7 @@ import Container from "../components/Container";
|
||||||
import Layout from "../components/Layout";
|
import Layout from "../components/Layout";
|
||||||
import Sidemenu from "../components/Sidemenu";
|
import Sidemenu from "../components/Sidemenu";
|
||||||
import Card from "../components/Card";
|
import Card from "../components/Card";
|
||||||
import { gardensFilePath, GARDENS_PATH } from "../utils/mdUtils";
|
import { gardenFilePath, GARDENS_PATH } from "../utils/mdxUtils";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
export default function Index({ posts }) {
|
export default function Index({ posts }) {
|
||||||
|
@ -65,7 +65,7 @@ export default function Index({ posts }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStaticProps() {
|
export function getStaticProps() {
|
||||||
const posts = gardensFilePath.map((filePath) => {
|
const posts = gardenFilePath.map((filePath) => {
|
||||||
const source = fs.readFileSync(path.join(GARDENS_PATH, filePath));
|
const source = fs.readFileSync(path.join(GARDENS_PATH, filePath));
|
||||||
const { content, data } = matter(source);
|
const { content, data } = matter(source);
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,21 @@ import { serialize } from "next-mdx-remote/serialize";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import Image from "next/image";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import Layout from "../../components/Layout";
|
import Layout from "../../components/Layout";
|
||||||
import { gardensFilePath, GARDENS_PATH } from "../../utils/mdUtils";
|
import { gardenFilePath, GARDENS_PATH } from "../../utils/mdxUtils";
|
||||||
|
|
||||||
// Custom components/renderers to pass to MDX.
|
// Custom components/renderers to pass to MDX.
|
||||||
// Since the MDX files aren't loaded by webpack, they have no knowledge of how
|
// Since the MDX files aren't loaded by webpack, they have no knowledge of how
|
||||||
// to handle import statements. Instead, you must include components in scope
|
// to handle import statements. Instead, you must include components in scope
|
||||||
// here.
|
// here.
|
||||||
const components = {
|
const components = {
|
||||||
|
img: (props) => <Image {...props} layout="fill" loading="lazy" />,
|
||||||
// It also works with dynamically-imported components, which is especially
|
// It also works with dynamically-imported components, which is especially
|
||||||
// useful for conditionally loading components for certain routes.
|
// useful for conditionally loading components for certain routes.
|
||||||
// See the notes in README.md for more details.
|
// See the notes in README.md for more details.
|
||||||
|
// TestComponent: dynamic(() => import("../../components/TestComponent")),
|
||||||
Head,
|
Head,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ export default function GardenPage({ source, frontMatter }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStaticProps = async ({ params }) => {
|
export const getStaticProps = async ({ params }) => {
|
||||||
const gardenFilePath = path.join(GARDENS_PATH, `${params.slug}.md`);
|
const gardenFilePath = path.join(GARDENS_PATH, `${params.slug}.mdx`);
|
||||||
const source = fs.readFileSync(gardenFilePath);
|
const source = fs.readFileSync(gardenFilePath);
|
||||||
|
|
||||||
const { content, data } = matter(source);
|
const { content, data } = matter(source);
|
||||||
|
@ -65,9 +68,9 @@ export const getStaticProps = async ({ params }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getStaticPaths = async () => {
|
export const getStaticPaths = async () => {
|
||||||
const paths = gardensFilePath
|
const paths = gardenFilePath
|
||||||
// Remove file extensions for page paths
|
// Remove file extensions for page paths
|
||||||
.map((path) => path.replace(/\.md?$/, ""))
|
.map((path) => path.replace(/\.mdx?$/, ""))
|
||||||
// Map the path into the static paths object required by Next.js
|
// Map the path into the static paths object required by Next.js
|
||||||
.map((slug) => ({ params: { slug } }));
|
.map((slug) => ({ params: { slug } }));
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,12 @@ title: Andy Matuschak
|
||||||
description: Algorithms that make themselves known
|
description: Algorithms that make themselves known
|
||||||
topics: ['evergreen notes', 'education', 'tools for thought']
|
topics: ['evergreen notes', 'education', 'tools for thought']
|
||||||
url: https://notes.andymatuschak.org/
|
url: https://notes.andymatuschak.org/
|
||||||
image: https://via.placeholder.com/200x250
|
image: /public/andy1.jpg
|
||||||
tools: ['mystery system']
|
tools: ['mystery system']
|
||||||
---
|
---
|
||||||
|
|
||||||
|
![Andy Matuschak's website](/public/andy1.jpg)
|
||||||
|
|
||||||
|
![Andy Matuschak's website](/public/andy2.jpg)
|
||||||
|
|
||||||
|
![Andy Matuschak's website](/public/andy3.jpg)
|
BIN
public/andy1.jpg
Normal file
BIN
public/andy1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 281 KiB |
BIN
public/andy2.jpg
Normal file
BIN
public/andy2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
BIN
public/andy3.jpg
Normal file
BIN
public/andy3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 224 KiB |
|
@ -6,7 +6,7 @@ export const GARDENS_PATH = path.join(process.cwd(), "posts", "gardens");
|
||||||
export const TOOLS_PATH = path.join(process.cwd(), "posts", "tools");
|
export const TOOLS_PATH = path.join(process.cwd(), "posts", "tools");
|
||||||
|
|
||||||
// patternFilePath is the list of all mdx files inside the POSTS_PATH directory
|
// patternFilePath is the list of all mdx files inside the POSTS_PATH directory
|
||||||
export const gardensFilePath = fs
|
export const gardenFilePath = fs
|
||||||
.readdirSync(GARDENS_PATH)
|
.readdirSync(GARDENS_PATH)
|
||||||
// Only include md(x) files
|
// Only include md(x) files
|
||||||
.filter((path) => /\.md?$/.test(path));
|
.filter((path) => /\.mdx?$/.test(path));
|
Loading…
Reference in a new issue