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.
- Host: GitHub
- URL: https://github.com/shintaro-abe/github-pages-pdf
- Owner: Shintaro-Abe
- Created: 2023-04-29T18:46:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-30T20:51:25.000Z (about 3 years ago)
- Last Synced: 2025-07-13T19:42:47.435Z (11 months ago)
- Topics: github-pages, md-to-pdf, pdf, shellscript
- Language: Shell
- Homepage: https://shintaro-abe.github.io/GitHub-Pages-PDF/
- Size: 1.71 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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_configsディレクトリ](pdf-configs)のconfig.jsとstyle.cssは、船場遼さんのZenn記事を参考
- [職務経歴書をGitHubで管理するノウハウ](https://zenn.dev/ryo_f/articles/2f925f621e6d99)