pretty_urls: trailing_index:false# Set to false to remove trailing 'index.html' from permalinks trailing_html:false# Set to false to remove trailing '.html' from permalinks
# See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks exclude:"{{package_name}}|.all-contributorsrc" default_stages: [commit]
# download images if DOWNLOAD: for url in re.findall( r"https://cdn-ak.f.st-hatena.com/images/fotolife/m/\w+/\d{8}/\d{14}.(?:png|jpg)", content_new, )リダイレクトの設定を追加 # download image r = requests.get(url, timeout=10) if r.status_code == 200: dest.write_bytes(r.content) else: # do not replace url if download failed continue
# replace url # need "/" at the beginning to make it relative path content_new = content_new.replace( url, "/" + dest.relative_to(SOURCE_DIR).as_posix() )
# replace only if content is changed if content != content_new: path.write_text(content_new, encoding="utf-8")