Package: pyjan26
PyJan26PyJan26 is a static site generator written in Python. It allows you to generate static websites from templates and content files, with support for pagination, custom pages, custom filters, and custom collections.InstallationYou can install PyJan26 using pip:pipinstallpyjan26Directory StructurePyJan26 follows a specific directory structure:project_directory/
│
├──_templates/# Base and extendable templates│├──base.html
│└──custom_template.html
│
├──_content/# Content files (Markdown)│├──post1.md
│├──post2.md
│└──about.md
│
└──public/# Generated HTML files├──index.html
├──post1/index.html
├──post2/index.html
└──about/index.htmlUsageTemplates: Design your base and extendable templates in_templates.Content: Define content files in_content. Each file specifies the layout and content of a page.Generated Files: PyJan26 generates static HTML files in thepublicfolder based on templates and content files.PaginationTo configure pagination, add the following YAML front matter to your content files:layout:custom_template.html# Specify the layout templatetitle:Post 1# Set the title of the pagepaginated:# Configure paginationitems:tags# Specify the grouping criteria (e.g., tags)size:1# Set the number of items per pagealias:myitem# Set a custom alias for the paginated itemsPagination VariablesWhen pagination is enabled, PyJan26 provides built-in template variables that you can use to generate pagination links:{% if myitem %}
  {% for page in myitem %}<span><ahref="/post/{{ page.tag }}">{{ page.tag }}</a></span>{% endfor %}
{% endif %}

{% if pagination.prev_page %}<ahref="{{ pagination.prev_page }}">Previous</a>{% endif %}

{% for page_num in pagination.page_numbers %}<ahref="{{ page_num.url }}">{{ page_num.page_number }}</a>{% endfor %}

{% if pagination.next_page %}<ahref="{{ pagination.next_page }}">Next</a>{% endif %}In this example:myitem represents the paginated items.pagination.prev_page provides a link to the previous page.pagination.page_numbers generates links to each page.pagination.next_page provides a link to the next page.Copy Static FilesTo specify static files to be copied to the public directory, add them to the STATIC_PATHS variable in your configuration (settings.py):# Copy Static filesSTATIC_PATHS=["images",# whole directory"assets/robots.txt"# specific file]Adjust the paths as needed to include directories or specific files you want to copy.Custom CollectionsDefine custom collections incustom_collections.py:# custom_collections.pyfrompyjan26.registryimportregister_custom_collectionsdeftag_list(collections):"""Define a list of tags for the 'tags' collection."""return{'tags':[{'tag':'javascript'},{'tag':'python'}]}# Register custom collectionsregister_custom_collections([tag_list])Custom FiltersDefine custom filters in custom_filters.py:# custom_filters.pyfrompyjan26.registryimportregister_custom_filtersdefcapitalize_words(value):return' '.join(word.capitalize()forwordinvalue.split())# Register custom filtersregister_custom_filters([capitalize_words])To use the custom filter in your templates, follow this syntax:{{ content | capitalize_words }}Custom Page RenderingDefine custom page rendering in custom_page.py:# custom_page.pyfrompyjan26.registryimportregister_custom_pagefrompyjan26.coreimportrender_page,render_stringdefcustom_page1(*args,**kwargs):"""Custom page rendering function."""item,collection_name,collections,settings=argsout_dir=kwargs.get('out_dir')# render jinja variableifout_dir:out_dir=render_string(out_dir,item)page_data={'collection_name':collection_name,'collections':collections,'items':item,'out_dir':out_dir}render_page(page_data)register_custom_page('custom1',custom_page1)To apply custom page rendering to a content markdown file, add custom1: True to the YAML front matter:layout:custom_template.html# Specify the layout templatetitle:Post 1custom1:True# Apply custom page renderingThis instructs PyJan26 to use the custom_page1 function for rendering this specific content. Adjust metadata as needed.Global VariableTo create a global variable PAGE_SIZE in settings.py, simply define it at the top of the file like so:# settings.py#example onlyPAGE_SIZE=10This renders the template value of PAGE_SIZE defined in the settings.py module.{{ settings.PAGE_SIZE }}