次のオプションのいずれかを試す前の注意事項
オプションを使用0
するとビルド時間が長くなり--incremental
、実際にはほとんどの1
場合オプションを使用する必要がありますが、CDNにアクセスできないクライアントを含むネットワークにデプロイする場合は、これと余分なスペースを使用することでコストに見合う価値があります。
両方のオプションはkramdown
、マークダウンインタープリターとしてのプライベートサーバーでテストされmathjax: true
、プロジェクトの_config.yml
ファイル内に設定されています。これらのビットのハウツーについては、Step of Soham Bhattacharyyaの回答とその序文、およびCaramdirの最初の2つのコードブロックまでを参照し2
てください。
オプション0
をダウンロードして、解凍したソースをにコピーしますproject-name
- ソースをダウンロード
cd ~
mkdir -p git/hub && cd git/hub
git clone --depth 1 https://github.com/mathjax/MathJax.git
- プロジェクトにディレクトリパスを作成し
MathJax/unpacked
、このパスからファイルをコピーします
cd ~
mkdir -p git/lan/project-name/assets/JS_3rd_Party/MathJax
cp -r git/hub/MathJax/unpacked/* git/lan/project-name/assets/JS_3rd_Party/MathJax/
git
ソースをトラッキングに追加します
cd git/lan/project-name/
git add assets/JS_3rd_Party/MathJax
git commit -m 'Added MathJax.js unpacked source to git tracking'
- インクルードファイルを書く
tee ./_includes/MathJax.html 1>/dev/null <<EOF
{%- if jekyll.environment == 'production' and site.mathjax == true -%}
<script type="text/javascript" src="{{'/assets/javascripts/JS_3rd_Party/latest.js?config=TeX-AMS-MML_HTMLorMML' | relative_url}}"></script>
{%- elsif jekyll.environment != 'production' and site.mathjax == true -%}
<script type="text/javascript" src="{{'/assets/javascripts/JS_3rd_Party/MathJax.js?config=TeX-AMS-MML_HTMLorMML' | relative_url}}"></script>
{%- endif -%}
EOF
プライベートサーバービルドはMathJax.js
、本番環境(GitHub)がlatest.js
上記のLiquid if
......ステートメントを使用して使用する場所を使用しelsif
ます。endif
- それをテストするために投稿を書く
tee ./_posts/$(date +'%Y-%d-%m')-math-tests.markdown 1>/dev/null <<EOF
---
layout: post
title: "Math Tests"
date: $(date +'%Y-%d-%m %H:%M:%S %z')
categories: math
---
{%- include MathJax.html -%}
<span>
for $x,y,z \in \{1, 2,\dots 9\}$
</span>
<span>
$$
\sum_{i=1}^n X_n
$$
</span>
EOF
cboettigの提案が完全にうまくいくよう<span>
に見えるので、私はsなしでそれを試していません。さらに、s内の余分な改行は間違いありませんが、レンダリングされた出力で問題が発生する場合はありません。span
- これらの最新ファイルを
git
トラッキングに追加します
git add _posts/$(date +'%Y-%d-')math-tests.markdown
git add _includes/MathJax.html
- ローカルでビルドするか、リモートサーバーでプッシュしてビルドします
bundle exec jekyll build --destination /tmp/www/project-name --config _config.yml --incremental
CDN(コンテンツ配信ネットワーク)を使用するためのオプション1
コピーlatest.js
Option 0
手順を参照してください1.
サードパーティのJavaScriptのディレクトリパスを作成し、MathJax/unpacked/latest.js
そこにコピーします
cd ~
mkdir -p git/lan/project-name/assets/JS_3rd_Party/MathJax
cp git/hub/MathJax/unpacked/latest.js git/lan/project-name/assets/JS_3rd_Party/MathJax/
- インクルードファイルを書く
cd git/lan/project-name
tee ./_includes/MathJax.html 1>/dev/null <<EOF
<script type="text/javascript" src="{{'/assets/javascripts/JS_3rd_Party/latest.js?config=TeX-AMS-MML_HTMLorMML' | relative_url}}"></script>
EOF
Option 0
ステップを参照してください5.
git
これらの3つのファイルを追跡に追加します
git add _includes/MathJax.html
git add _posts/$(date +'%Y-%d-')math-tests.markdown
git add assets/JS_3rd_Party/MathJax
git commit -m 'Added `MathJax.html`, `latest.js`, and a test post to git tracking'
- ローカルで構築するための
Option 0
手順を参照してください7.
どちらのオプションでも
プライベートサーバーにデプロイする場合、特にGitHubがプライベートサーバーで使用するURLスキームをエミュレートする場合は、baseurl
プロジェクトの_config.yml
ファイル内で定義する必要がある場合もあります。username.tld/project-name
プライベートサーバーとGitHubの両方にデプロイする場合は、別の構成ファイルを使用する方がよい場合があります--config _config.yml,_config_baseurl.yml
。
# Write the special config file
tee ./_config_baseurl.yml 1>/dev/null <<EOF
baseurl: "project-name"
EOF
# Build with extra config
bundle exec jekyll build --destination /tmp/www/project-name --config _config.yml,_config_baseurl.yml --incremental
インクルードを介してアセットをロードするのに役立つことを願っています。