Skip to content

Commit

Permalink
built to output dir, add ignore file
Browse files Browse the repository at this point in the history
  • Loading branch information
HengHuH committed Jun 4, 2024
1 parent 5a11e78 commit f69cf06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
path: './build'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/build
5 changes: 3 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


root = os.path.dirname(os.path.abspath(__file__))
outdir = os.path.join(root, 'build')
root_url = "https://henghuh.github.io"


Expand Down Expand Up @@ -79,7 +80,7 @@ def __init__(self, site) -> None:
def build(self):
alllinks = []
for post in sorted(self._site.posts, key=lambda x: (x.year, x.month, x.day), reverse=True):
abspath = os.path.join(root, post.addr)
abspath = os.path.join(outdir, post.addr)
dirname = os.path.dirname(abspath)
os.makedirs(dirname, exist_ok=True)

Expand All @@ -91,7 +92,7 @@ def build(self):
print(f"build post: {post.addr} --- DONE")
alllinks.append(f"<a href=\"{post.addr}\">{post.title}</a>")

with open(os.path.join(root, 'index.html'), 'w', encoding='utf-8') as f:
with open(os.path.join(outdir, 'index.html'), 'w', encoding='utf-8') as f:
content = self.index_page.replace("{{allposts}}", "<br>\n".join(alllinks))
content = content.replace("{{date}}", str(date.today()))
f.write(bs(content, 'html.parser').prettify())
Expand Down

0 comments on commit f69cf06

Please sign in to comment.