mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
refactor(v2): blog data revamp (#1450)
* refactor(v2): blog data revamp * fix(v2): fix incorrect blog total count * misc: remove console.log * feat(v2): export frontMatter as an object within MDX file (#1451) * refactor. Don't confuse metadata & frontmatter * export frontMatter in content itself * nits * nits name * dont truncate first four lines in blog
This commit is contained in:
parent
070723697f
commit
23b50f17a1
18 changed files with 258 additions and 119 deletions
|
@ -10,6 +10,8 @@ const mdx = require('@mdx-js/mdx');
|
|||
const rehypePrism = require('@mapbox/rehype-prism');
|
||||
const emoji = require('remark-emoji');
|
||||
const slug = require('rehype-slug');
|
||||
const matter = require('gray-matter');
|
||||
const stringifyObject = require('stringify-object');
|
||||
const linkHeadings = require('./linkHeadings');
|
||||
const rightToc = require('./rightToc');
|
||||
|
||||
|
@ -19,9 +21,10 @@ const DEFAULT_OPTIONS = {
|
|||
prismTheme: 'prism-themes/themes/prism-atom-dark.css',
|
||||
};
|
||||
|
||||
module.exports = async function(content) {
|
||||
module.exports = async function(fileString) {
|
||||
const callback = this.async();
|
||||
|
||||
const {data, content} = matter(fileString);
|
||||
const options = Object.assign(DEFAULT_OPTIONS, getOptions(this), {
|
||||
filepath: this.resourcePath,
|
||||
});
|
||||
|
@ -43,6 +46,7 @@ module.exports = async function(content) {
|
|||
import React from 'react';
|
||||
import { mdx } from '@mdx-js/react';
|
||||
${importStr}
|
||||
export const frontMatter = ${stringifyObject(data)};
|
||||
${result}
|
||||
`;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue