Skip to content

Commit

Permalink
Build all pages instead of just pages that are linked to from the site
Browse files Browse the repository at this point in the history
  • Loading branch information
Siecje committed Jan 27, 2024
1 parent 3a9dc7e commit ad49399
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions htmd/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,12 @@ def post() -> Iterator[dict]: # noqa: F811
'year': post.meta.get('published').year,
'path': post.path,
}


@freezer.register_generator # type: ignore[no-redef]
def page() -> Iterator[str]: # noqa: F811
for page in (project_dir / 'pages').iterdir():
# Need to create for pages.page
# Since this route is in a different Blueprint
# URL works
yield f'/{page.stem}/'
25 changes: 25 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,28 @@ def test_build_feed_dot_atom() -> None:
current_directory = Path.cwd()
assert (Path(current_directory) / 'build' / 'feed.atom').is_file


def test_build_page_without_link() -> None:
page_lines = (
"{% extends '_layout.html' %}\n",
'\n',
'{% block title %}New{% endblock title %}\n',
'\n',
'{% block content %}\n',
' <article>\n',
' <h1>New</h1>\n',
' <p>Totally new</p>\n',
' </article>\n',
'{% endblock content %}\n',
)
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(start)
# Create page that is doesn't have a link in the site
with (Path('pages') / 'new.html').open('w') as page_file:
for line in page_lines:
page_file.write(line)
result = runner.invoke(build)
assert result.exit_code == 0
with (Path('build') / 'new' / 'index.html').open('r') as page_file:
assert 'Totally new' in page_file.read()

0 comments on commit ad49399

Please sign in to comment.