An open API service indexing awesome lists of open source software.

https://github.com/shintaro-abe/github-pages-pdf

This script automates the creation of PDF and the replacement of URL links.
https://github.com/shintaro-abe/github-pages-pdf

github-pages md-to-pdf pdf shellscript

Last synced: 10 months ago
JSON representation

This script automates the creation of PDF and the replacement of URL links.

Awesome Lists containing this project

README

          

# GitHub-Pages-PDF
## 概要
- __[プロフィールリポジトリ](https://github.com/Shintaro-Abe)で使用するために作成したシェルスクリプト__
- docsディレクトリに格納されているREADME.mdをもとにGitHub Pagesを作成。
- 記事の更新後にPDFを生成し、ルートディレクトリに格納されているREADME.mdのバッジリンクを差し替え。


- __シェルスクリプトの実行__
- GitHub Pagesの修正後、以下コマンドの実行により、PDF生成、プロフィールREADME.mdのリンク差し替え、リポジトリへのコミットとプッシュを実施。
```
bash gitpdf.sh
```
## スクリプトについて
コードは
[gitpdf.sh](gitpdf.sh)
を参照。

- __`md-to-pdf`コマンド__
- Node.jsとyarnがインストールされている環境を構築。
- 以下のコマンドでライブラリをインストール。
```
yarn add -D md-to-pdf
```

- __`gsed`コマンド__
- mac環境で使用しているため、置換コマンドは`gsed -i`を使用。
- 環境によっては`sed`コマンドで実行。
- 置換したいコードにalt属性を付与し、キーワードとして使用。具体的なコマンドは以下。
- 環境変数を使用する場合は、キーワード〜置き換えの行までをダブルクォーテーションで囲む。

```
gsed -i "/キーワード/c 置換後の行" 対象ファイルのパス
```
- __コミットIDの取得__
- ` git show --format='%H' --no-patch `コマンドで最新のコミットIDを取得。

## テスト用バッジ
- __GitHubのパーマリンク__
```
https://github.com/ユーザー名/リポジトリ名/オブジェクトの種類/コミットID/path/README.pdf
```
- __各バッジのPDF取得方法__
- View : PDFのページへ遷移。オブジェクトの種類は`blob`。パーマリンクではなく、相対パスを指定しても問題ない。
- Download : PDFデータをローカルへダウンロード。オブジェクトの種類は`raw`。



PDF

## 参考資料

- [pdf_configsディレクトリ](pdf-configs)のconfig.jsとstyle.cssは、船場遼さんのZenn記事を参考

- [職務経歴書をGitHubで管理するノウハウ](https://zenn.dev/ryo_f/articles/2f925f621e6d99)