Skip to content

Commit c2479a7

Browse files
committed
add support for GH_TOC_TOKEN env variable
1 parent 0d36e74 commit c2479a7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gh-md-toc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ gh_toc_load() {
5252
gh_toc_md2html() {
5353
local gh_file_md=$1
5454
URL=https://api.github.com/markdown/raw
55-
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
55+
if [ -z "$GH_TOC_TOKEN" ]; then
56+
TOKEN=$GH_TOC_TOKEN
57+
else
58+
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
59+
fi
5660
if [ -f "$TOKEN" ]; then
5761
URL="$URL?access_token=$(cat $TOKEN)"
5862
fi
63+
# echo $URL 1>&2
5964
OUTPUT="$(curl -s --user-agent "$gh_user_agent" \
6065
--data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
6166
$URL)"

0 commit comments

Comments
 (0)