blog: support MDX truncate marker

This commit is contained in:
sebastienlorber 2023-01-06 16:36:00 +01:00
parent 9c9d17d6aa
commit 792ee8ac4c
16 changed files with 52 additions and 25 deletions

View file

@ -1,5 +1,5 @@
---
title: Full Blog Sample
title: MDX Blog Post
date: 2021-03-05
---
@ -7,7 +7,9 @@ date: 2021-03-05
<h2>HTML Heading 2</h2>
<p>HTML Paragraph</p>
import Typography from '../../component/Typography'
{/* truncate */}
import Typography from '../../component/Typography';
<Typography>Import DOM</Typography>
@ -25,12 +27,10 @@ import Typography from '../../component/Typography'
- list2
- list3
* list1
* list2
* list3
Normal Text *Italics Text* **Bold Text**
Normal Text _Italics Text_ **Bold Text**
[link](https://v2.docusaurus.io/)
![image](https://v2.docusaurus.io/)
[link](https://v2.docusaurus.io/) ![image](https://v2.docusaurus.io/)

File diff suppressed because one or more lines are too long

View file

@ -175,6 +175,33 @@ describe('blog plugin', () => {
unlisted: false,
});
expect(getByTitle(blogPosts, 'MDX Blog Post').metadata).toEqual({
authors: [],
date: new Date('2021-03-05T00:00:00.000Z'),
description: 'HTML Heading 1',
editUrl: 'https://baseEditUrl.com/edit/blog/mdx-blog-post.mdx',
formattedDate: 'March 5, 2021',
frontMatter: {
date: new Date('2021-03-05T00:00:00.000Z'),
title: 'MDX Blog Post',
},
hasTruncateMarker: true,
nextItem: {
permalink: '/blog/hey/my super path/héllô',
title: 'Complex Slug',
},
permalink: '/blog/mdx-blog-post',
prevItem: {
permalink: '/blog/mdx-require-blog-post',
title: 'MDX Blog Sample with require calls',
},
readingTime: 0.26,
source: '@site/blog/mdx-blog-post.mdx',
tags: [],
title: 'MDX Blog Post',
unlisted: false,
});
expect(
getByTitle(blogPosts, 'Happy 1st Birthday Slash! (translated)').metadata,
).toEqual({

View file

@ -26,7 +26,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
beforeDefaultRehypePlugins: [],
beforeDefaultRemarkPlugins: [],
admonitions: true,
truncateMarker: /<!--\s*truncate\s*-->/,
truncateMarker: /<!--\s*truncate\s*-->|\{\/\*\s*truncate\s*\*\/\}/,
rehypePlugins: [],
remarkPlugins: [],
showReadingTime: true,

View file

@ -15,7 +15,7 @@ We created [Docusaurus](https://docusaurus.io) for the following reasons:
1. To make it easy to push updates, new features, and bug fixes to everyone all at once.
1. And, finally, to provide a consistent look and feel across all of our open source projects.
<!--truncate-->
{/* truncate */}
Docusaurus is a tool designed to make it easy for teams to publish documentation websites without having to worry about the infrastructure and design details. At its core, all a user has to provide are documentation files written in Markdown, customization of a provided home page written in React, and a few configuration modifications. Docusaurus handles the rest by providing default styles, site formatting, and simple document navigation. Getting started is easy, as users can [install](https://v1.docusaurus.io/docs/en/installation.html) it using `npm` or `yarn` via a simple initialization script that [creates a working example website out of the box](https://v1.docusaurus.io/docs/en/site-preparation.html).

View file

@ -15,7 +15,7 @@ This is the story of the rather short journey it took to create the [Profilo](ht
Profilo, an Android library for collecting performance traces from production, [was announced](https://code.fb.com/android/profilo-understanding-app-performance-in-the-wild/) earlier this year. The project was [published on GitHub](https://github.com/facebookincubator/profilo/tree/802042f90f990998a272387e371b893af52465b8) with a less than [a handful or Markdown files](https://github.com/facebookincubator/profilo/tree/802042f90f990998a272387e371b893af52465b8/docs) to describe its functionality and no website to showcase any branding and highlight the logo. The task at hand was to turn these existing docs and logo into a website.
<!--truncate-->
{/* truncate */}
In general, when creating a website with Docusaurus you do the following:

View file

@ -12,7 +12,7 @@ Docusaurus was [officially announced](https://v1.docusaurus.io/blog/2017/12/14/i
There is a saying that the very best software is constantly evolving, and the very worst is not. In case you are not aware, we have been planning and working on the next version of Docusaurus 🎉.
<!--truncate-->
{/* truncate */}
## Introduction

View file

@ -10,7 +10,7 @@ tags: [birth]
Docusaurus [went live](https://v1.docusaurus.io/blog/2017/12/14/introducing-docusaurus) on December 14, 2017. At the time, we had [8 early adopters](https://v1.docusaurus.io/blog/2017/12/14/introducing-docusaurus#acknowledgements).
<!--truncate-->
{/* truncate */}
We now have nearly [60 known users of Docusaurus](https://v1.docusaurus.io/en/users), and probably more that we don't know about. We have [9K GitHub stars](https://github.com/facebook/docusaurus) and an active community, particularly [Yangshun Tay](https://twitter.com/yangshunz) and [Endilie Yacop Sucipto](https://twitter.com/endiliey), both of whom are the lead maintainers helping keep this project [moving forward](https://docusaurus.io/blog/2018/09/11/Towards-Docusaurus-2).

View file

@ -6,7 +6,7 @@ tags: [recap]
2019 was a great year for Docusaurus - we've made tremendous progress on [Docusaurus 2](https://docusaurus.io/). Current Docusaurus 1 users who aren't using the translations feature can feel free to check it out and [migrate](https://docusaurus.io/docs/migration) to it! Otherwise we will work with you to make that happen in 2020 :)
<!--truncate-->
{/* truncate */}
## Docusaurus 2 (D2)

View file

@ -6,7 +6,7 @@ tags: [endi, tribute]
It is with great sadness to announce that our primary external Docusaurus contributor, [Endilie Yacop Sucipto](https://github.com/endiliey) (Endi to those who knew him), [passed away](https://give.asia/campaign/help_endi_beat_cancer#/updates) over the weekend after an illness associated with his bout with cancer.
<!--truncate-->
{/* truncate */}
It is impossible to overstate Endi's impact on this project:

View file

@ -15,7 +15,7 @@ We are **still in alpha**, but expect **some good news very soon**!
![Three Docusaurus plushies laid side-by-side on the table](/img/blog/2020-recap/docusaurus-plushie-banner.jpeg)
<!--truncate-->
{/* truncate */}
## Docusaurus 2 highlights

View file

@ -15,7 +15,7 @@ In this post, we will present you the **translation workflow**, explain some **d
We also **dogfood** the i18n support on the **Docusaurus 2 site itself**, and this post is already available in [English](https://docusaurus.io/blog/2021/03/09/releasing-docusaurus-i18n) and [French](https://docusaurus.io/fr/blog/2021/03/09/releasing-docusaurus-i18n)!
<!--truncate-->
{/* truncate */}
## Translate your site

View file

@ -17,7 +17,7 @@ With the announcement of this beta, the team is even more confident that Docusau
![](./img/image_cropped.png)
<!--truncate-->
{/* truncate */}
## Docusaurus adoption

View file

@ -16,7 +16,7 @@ image: ./img/social-card.png
Docusaurus site owners should upgrade their configuration with [their new credentials](#im-using-docusaurus-and-docsearch-can-i-migrate) **by February 1, 2022**, existing search indexes will be frozen and become read-only after this date.
<!--truncate-->
{/* truncate */}
## Upgrading your Docusaurus site

View file

@ -13,7 +13,7 @@ The **official v2 release** is just around the corner! Follow the [roadmap issue
![](./img/thumbnail.png)
<!--truncate-->
{/* truncate */}
## Highlights

View file

@ -12,7 +12,7 @@ The upgrade should be easy: as explained in our [release process documentation](
![Docusaurus 2.1 social card](./img/social-card.png)
<!--truncate-->
{/* truncate */}
## Highlights