---
title: Truncation Example
---
All these will be part of the blog post summary.
Even this.
<!--truncate-->
But anything from here on down will not be.
Blog Header 2/2
作者資訊或是封面圖片等也都可以在header中做設定
---
authors:
name: Joel Marcey
title: Co-creator of Docusaurus 1
url: https://github.com/JoelMarcey
image_url: https://github.com/JoelMarcey.png
---
Show Estimated Reading Time
會根據文章內的字數來大概推測出閱讀所需的時間
// docusaurus.config.jsmodule.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
blog: {
showReadingTime: true, // When set to false, the "x min read" won't be shownreadingTime: ({content, frontMatter, defaultReadingTime}) =>
defaultReadingTime({content, options: {wordsPerMinute: 300}}),
},
},
],
],
};
Blog Only Mode
不一定要用docusaurus來寫doc,也有不少人會把他當網誌使用
// docusaurus.config.jsmodule.exports = {
// ...presets: [
[
'@docusaurus/preset-classic',
{
docs: false, // Optional: disable the docs pluginblog: {
routeBasePath: '/', // Serve the blog at the site's root
},
},
],
],
};
Close Blog
如果不會用到blog的功能,可以到docusaurus.config.js設定檔去關掉它
module.exports = {
// ...presets: [
'@docusaurus/preset-classic',
{
docs: {
routeBasePath: '/', // Serve the docs at the site's root/* other docs plugin options */
},
blog: false, // Optional: disable the blog plugin// ...
},
],
};
You write a link like this: [Download this document](/files/note.docx)
Docusaurus changes that to: <ahref={require('static/files/note.docx')}>Download this document</a>
// xxx.mdximport Tabs from'@theme/Tabs';
import TabItem from'@theme/TabItem';
<Tabs><TabItemvalue="apple"label="Apple"default>
This is an apple </TabItem><TabItemvalue="orange"label="Orange">
This is an orange </TabItem><TabItemvalue="banana"label="Banana">
This is a banana </TabItem></Tabs>
// docusaurus.config.jsmodule.exports = {
plugins: ['@docusaurus/theme-live-codeblock'],
themeConfig: {
liveCodeBlock: {
/**
* The position of the live playground, above or under the editor
* Possible values: "top" | "bottom"
*/playgroundPosition: 'bottom',
},
},
};
Example for Live Code Blocks
簡單寫一個會顯示現在時間的範例
```jsx live
function Clock(props) {
const [date, setDate] = useState(new Date());
useEffect(() => { var timerID = setInterval(() => tick(), 1000);
return function cleanup() {
clearInterval(timerID);
};
});
function tick() {
setDate(new Date());
}
return (
<div>
<h2>It is {date.toLocaleTimeString()}.</h2>
</div>
);
}
Add custom component to live code blocks
要透過swizzle去找live code blocks的原始碼來修改 npm run swizzle @docusaurus/theme-live-codeblock ReactLiveScope