meeb / django-distill

Minimal configuration static site generator for Django
MIT License
441 stars 35 forks source link

the files out without extension #54

Closed obedmacallums closed 2 years ago

obedmacallums commented 2 years ago

from django.urls import path from . import views from blog.models import Post, Category from django_distill import distill_path from django.template.defaultfilters import slugify

def get_index(): return None

def get_all_blogposts():

This function needs to return an iterable of dictionaries. Dictionaries

# are required as the URL this distill function is for has named parameters.
# You can just export a small subset of values here if you wish to
# limit what pages will be generated.
for post in Post.objects.all():

    yield {'pk': post.id, 'slug': slugify(post.title)}

urlpatterns = [ distill_path('post//', views.PostDetailView.as_view(), name='post', distill_func=get_all_blogposts, ),

distill_path('',
             views.home,
             name='home',
             # Note that for paths which have no paramters
             # distill_func is optional
             distill_func=get_index,
             # / is not a valid file name! override it to index.html
             distill_file='index.html'),

# path('', views.home, name="home"),

path('author/', views.author, name="author"),
# path('post/<int:pk>/<slug:slug>/', views.PostDetailView.as_view(), name="post"),
]
meeb commented 2 years ago

What specifically is the issue you're having?

obedmacallums commented 2 years ago

the only thing missing was to add .html to the string url path. Everything si ok, maybe it was just missing a bit of documentation too. Thanks for the proyect