文件編輯指南

新增 Markdown 檔案

將 markdown 檔案新增至 contents/zh/ (中文文章) 或 contents/en/ (英文文章) 目錄,最多三層。更新 contents/zh/posts.ymlcontents/en/posts.yml 中的路徑和標題資訊。

Markdown 檔案名稱使用小寫。

使用 Prettier 自動格式化程式碼

在開始之前,我們建議安裝 prettier VSCode 外掛,它會在您儲存時自動格式化程式碼。

如果您覺得自動格式化破壞了您的程式碼區塊,您可以新增以下註解來防止 prettier 格式化區塊內的程式碼

<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->

如果您發現程式碼區塊未格式化,請先檢查程式碼中是否有語法錯誤。

內建變數

  • optionPath
  • mainSitePath
  • exampleViewPath
  • exampleEditorPath
  • lang

用法

${xxxxx}
[Get Apache ECharts](${lang}/basics/download)

取得 Apache ECharts

嵌入程式碼

基本用法

```js
option = {
    series: [{
        type: 'bar',
        data: [23, 24, 18, 25, 27, 28, 25]
    }]
};
\```
option = {
  series: [
    {
      type: 'bar',
      data: [23, 24, 18, 25, 27, 28, 25]
    }
  ]
};

為了讓工具協助我們格式化程式碼,我們應盡量避免在語法上有問題的寫作風格。

例如,註解 ...

option = {
  series: [
    {
      type: 'bar'
      // ...
    }
  ]
};

即時預覽和編輯

目前僅支援 Option 程式碼的預覽

\```js live
option = {
  xAxis: {
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {},
  series: [
    {
      type: 'bar',
      data: [23, 24, 18, 25, 27, 28, 25]
    }
  ]
};
\```
option = {
  xAxis: {
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {},
  series: [
    {
      type: 'bar',
      data: [23, 24, 18, 25, 27, 28, 25]
    }
  ]
};
live

更多預覽佈局

由左至右

<md-live lang="js" code="'b3B0aW9uID0gewogIC4uLgp9OwpcYGBg'" v-bind="{layout: 'lr'}" />

<!-- prettier-ignore-end -->

<md-live lang="js" code="'b3B0aW9uID0gewogIHhBeGlzOiB7CiAgICBkYXRhOiBbJ01vbicsICdUdWUnLCAnV2VkJywgJ1RodScsICdGcmknLCAnU2F0JywgJ1N1biddCiAgfSwKICB5QXhpczoge30sCiAgc2VyaWVzOiBbCiAgICB7CiAgICAgIHR5cGU6ICdiYXInLAogICAgICBkYXRhOiBbMjMsIDI0LCAxOCwgMjUsIDI3LCAyOCwgMjVdCiAgICB9CiAgXQp9Ow'" v-bind="{layout: 'lr'}" />

#### Right to left

<!-- prettier-ignore-start -->
markdown
option = {
  ...
};
\```
live

option = {
  xAxis: {
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {},
  series: [
    {
      type: 'bar',
      data: [23, 24, 18, 25, 27, 28, 25]
    }
  ]
};
live

由下至上

<md-live lang="js" code="'b3B0aW9uID0gewogIC4uLgp9OwpcYGBg'" v-bind="{layout: 'bt'}" />

<!-- prettier-ignore-end -->

<md-live lang="js" code="'b3B0aW9uID0gewogIHhBeGlzOiB7CiAgICBkYXRhOiBbJ01vbicsICdUdWUnLCAnV2VkJywgJ1RodScsICdGcmknLCAnU2F0JywgJ1N1biddCiAgfSwKICB5QXhpczoge30sCiAgc2VyaWVzOiBbCiAgICB7CiAgICAgIHR5cGU6ICdiYXInLAogICAgICBkYXRhOiBbMjMsIDI0LCAxOCwgMjUsIDI3LCAyOCwgMjVdCiAgICB9CiAgXQp9Ow'" v-bind="{layout: 'bt'}" />

### Highlighting Lines of Code and Adding Filenames

Use.

<!-- prettier-ignore-start -->
markdown

option = {
  series: [
    {
      type: 'bar',
      data: [23, 24, 18, 25, 27, 28, 25]
    }
  ]
};
\```

效果。

option = {
  series: [
    {
      type: 'bar',
      data: [23, 24, 18, 25, 27, 28, 25]
    }
  ]
};

嵌入圖片

原始圖片儲存在 static/images/ 下。

![image description](images/demo.png)

設定圖片高度和寬度

對於當前頁面的臨時樣式,您可以直接寫 html。

<img data-src="images/demo.png" style="width: 50px" />

新增範例 Iframe

srchttps://echarts.dev.org.tw/examples/en/editor.html?c=line-simple 位址中 ?c= 後面的字串

使用方式

<md-example src="doc-example/getting-started" width="100%" height="300"></md-example>

結果

使用方式

<md-option link="series-bar.itemStyle.color"></md-option>

結果: series-bar.itemStyle.color

更多元件用法

文件支援使用全域註冊的 markdown 元件。除了剛才描述的 md-example 元件之外,還有以下元件可用

md-alert

提示元件

<md-alert type="info">
This is an info alert.
</md-alert>

這是一個資訊提示。

<md-alert type="success">
This is a success alert.
</md-alert>

這是一個成功提示。

<md-alert type="warning">
This is a warning alert.
</md-alert>

這是一個警告提示。

<md-alert type="danger">
This is a danger alert.
</md-alert>

這是一個危險提示。

貢獻者 在 GitHub 上編輯此頁面

pissang pissangplainheart plainheart