diff --git a/README.md b/README.md index 8795e95..de86a59 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Otherwise, you have to configure the following settings : Other useful settings : - Default metadata : `JFME_DEFAULT_METADATA_DICT` and `JFME_DEFAULT_METADATA_FILEPATH` allow to set default metadata for pages and posts. The first one is a python dictionary and the second one is a Path to a file having the same format as metadata section in pages. The order, from less to most priority is : `JFME_DEFAULT_METADATA_DICT` then `JFME_DEFAULT_METADATA_FILEPATH` then page matadata. -- Posts pagination : `JFME_NUMBER_OF_POSTS_BY_PAGE` give the maximum number of posts in a posts list page. If not set, all posts will be in the first page. +- Posts pagination : `JFME_NUMBER_OF_POSTS_BY_PAGE` give the maximum number of posts in a posts list page. If set to 0 or -1, all posts will be in the first page. ### `Dockerfile` : - In the `# Copy source dir` section, add `COPY / /` for each content directory in `JFME_CONTENT_DIRS` diff --git a/jssg/models.py b/jssg/models.py index db7b0a7..f110c08 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -341,7 +341,7 @@ def __init__(self, category = "", page = 1) -> None: else : nb_posts = len(list(filter(lambda p: p.metadata["category"] == self.category, Post.load_glob(all=True)))) - if hasattr(settings, "JFME_NUMBER_OF_POSTS_BY_PAGE") : + if settings.JFME_NUMBER_OF_POSTS_BY_PAGE > 0 : self.posts_by_page = settings.JFME_NUMBER_OF_POSTS_BY_PAGE else : self.posts_by_page = nb_posts diff --git a/jssg/settings.py b/jssg/settings.py index 8baf717..3650df7 100644 --- a/jssg/settings.py +++ b/jssg/settings.py @@ -54,7 +54,7 @@ JFME_STATIC_DIRS = [path / "static" for path in JFME_CONTENT_DIRS] JFME_DEFAULT_METADATA_DICT = {"slug": "index", } # The order of include is : JFME_DEFAULT_METADATA_DICT then JFME_DEFAULT_METADATA_FILEPATH then page metadata JFME_DEFAULT_METADATA_FILEPATH = BASE_DIR / "jssg" / "default_metadata.txt" # If a metadata is specified more than once, the last included is retained -JFME_NUMBER_OF_POSTS_BY_PAGE = 3 # no pagination of posts if not set +JFME_NUMBER_OF_POSTS_BY_PAGE = 3 # no pagination of posts if set to 0 or -1 JFME_CONTENT_REQUIRED_METADATA = ["title", "slug", "lang", "description"] JFME_SITEMAP_LASTMOD_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" # strftime format, see https://docs.python.org/fr/3.6/library/datetime.html#strftime-and-strptime-behavior, see https://www.sitemaps.org/protocol.html#lastmoddef for allowed datetime formats