-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Load markdown files through markdown-with-front-matter-loader #1304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the PR! What does that JSON look like? |
Also, can you provide |
Regarding #!/bin/bash
set -eo pipefail
test_branch() {
branch="$1"
git checkout "$branch" >/dev/null 2>&1
rm -rf build
npm run create-react-app build >/dev/null 2>&1
ls build/node_modules > "$HOME/tmp/cra-$branch-modules.txt"
du -s build/node_modules/
}
MASTER_SIZE=$(test_branch master)
MARKDOWN_SIZE=$(test_branch load-markdown)
echo "node_modules size on master: $MASTER_SIZE"
echo "node_modules size on load-markdown: $MARKDOWN_SIZE"
echo
echo "Module diff:"
diff -u "$HOME/tmp/cra-master-modules.txt" "$HOME/tmp/cra-load-markdown-modules.txt" Results:
Size of new modules: $ cd build/node_modules/
$ du -csh markdown-with-front-matter-loader yaml-front-matter
24K markdown-with-front-matter-loader
592K yaml-front-matter
616K total |
Regarding JSON - given some Markdown: ---
title: Test markdown post
date: 2015-06-03
tags: Badger, Squirrel, Nihilist
---
# Content
Some content You get the following, except the {
"title": "Test markdown post",
"date": "2015-06-03T00:00:00.000Z",
"tags": "Badger, Squirrel, Nihilist",
"__content": "<h1 id=\"content\">Content</h1>\n<p>Some content</p>\n"
} |
7b46175
to
0910c25
Compare
What is the benefit of this structure, compared to regular Markdown -> HTML conversion? |
The first part can contain any fields you want, so you can use whatever metainfo conventions make sense for your Markdown documents. For example, a tags field (string or YAML array) for categorising a blog post, a field for a blog post's background image, author name, references, anything you like really. You could even pre-process the files at build time to extract the metadata and build some kind of index. That's all separate from the actual markdown content. |
So, I appreciate the PR but I think we'll hold off for now. If we add an exception for If there are more requests for this in the future, we can reconsider this. Sorry! |
This PR adds support for loading
*.md
files throughmarkdown-with-front-matter-loader
. This makes it simple to load and render Markdown through CRA.Testing
./tasks/cra.sh my-app-test
cd my-app-test
src/_posts/hello-world.md
src/App.js
to load the file