Skip to content

Commit

Permalink
Allow markdown content (#35)
Browse files Browse the repository at this point in the history
* Add django-jinja-markdown extension

* Add examples for markdown in page1

---------

Co-authored-by: Clément <[email protected]>
  • Loading branch information
ClmntBcqt and Clément authored Jul 24, 2024
1 parent 1b67b84 commit bd113f9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
25 changes: 24 additions & 1 deletion content/pages/a_page.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@ template_engine jinja2
}

---
{% from "widgets/page_header.html" import page_header %}


<h2>Page 1</h2>

<p>Go to <a href="{{ url_for_slug('page2') }}">page 2</a> </p>
<p>Go to <a href="{{ url('page', args=['page2']) }}">page 2</a> </p>


<article>
{% markdown %}
```
This is markdown :
```
test
**test**
`test`
{% endmarkdown %}
</article>


{{ page_header(
markdown('
test
**test**
`test`
')
) }}
3 changes: 2 additions & 1 deletion jssg/jinja2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.templatetags.static import static
from django.urls import reverse

from django_jinja_markdown.templatetags.md import markdown
from jinja2 import Environment

from jssg.templatetags.filter_opengraph_metadata import filter_opengraph_metadata
Expand Down Expand Up @@ -91,6 +91,7 @@ def environment(**options):
{
"static": static,
"url": reverse,
"markdown": markdown,
"url_for_slug": url_for_slug,
"url_for_slug_path" : url_for_slug_path
}
Expand Down
4 changes: 3 additions & 1 deletion jssg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

INSTALLED_APPS = [
"jssg",
"django_jinja_markdown",
"django.contrib.contenttypes",
"whitenoise.runserver_nostatic",
"django.contrib.staticfiles",
Expand All @@ -80,7 +81,8 @@
"DIRS": [path / "jinja2" for path in JFME_TEMPLATES_DIRS],
"APP_DIRS": True,
"OPTIONS": {
"environment": "jssg.jinja2.environment"
"environment": "jssg.jinja2.environment",
"extensions": ["django_jinja_markdown.extensions.MarkdownExtension"]
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Django==5.0.6
Django==4.2.9
django-distill
django_vite_plugin==3.0.0
markdown2[all]==2.4.13
whitenoise==6.7.0
Jinja2==3.1.4
django-jinja-markdown
25 changes: 24 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,30 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"paths": {
"@/*": [
"./*"
],
"@s:django_jinja_markdown/*": [
"./env/lib/python3.9/site-packages/django_jinja_markdown/static/django_jinja_markdown/*"
],
"@t:django_jinja_markdown/*": [
"./env/lib/python3.9/site-packages/django_jinja_markdown/templates/django_jinja_markdown/*"
],
"@s:django_distill/*": [
"./env/lib/python3.9/site-packages/django_distill/static/django_distill/*"
],
"@t:django_distill/*": [
"./env/lib/python3.9/site-packages/django_distill/templates/django_distill/*"
],
"@s:jssg/*": [
"./jssg/static/jssg/*"
],
"@t:jssg/*": [
"./jssg/templates/jssg/*"
]
}
},
"include": [
"content/front/"
Expand Down

0 comments on commit bd113f9

Please sign in to comment.