Skip to content

Commit

Permalink
feat: resolve links and embeds in news body (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
niccofyren authored Oct 8, 2024
1 parent 4c47945 commit 1f2ba79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aktuelt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from aktuelt.constants import ContributionTypes
from aktuelt.serializers import (
ContributorsSerializer,
NewsBodySerializer,
NewsImageSerializer,
NewsPageGallerySerializer,
NewsPageTagsSerializer,
Expand Down Expand Up @@ -99,7 +100,7 @@ def schedule(self):

api_fields = [
APIField("intro"),
APIField("body"),
APIField("body", serializer=NewsBodySerializer()),
# TODO: Replace with prettier (main model based?) serializer pattern?
APIField("contributors", serializer=ContributorsSerializer(source="news_page_contributors")),
APIField("tags", serializer=NewsPageTagsSerializer()),
Expand Down
6 changes: 6 additions & 0 deletions aktuelt/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from rest_framework.fields import Field
from wagtail.images.api.fields import ImageRenditionField
from wagtail.rich_text import expand_db_html


class NewsBodySerializer(Field):
def to_representation(self, value):
return expand_db_html(value)


class NewsImageSerializer(Field):
Expand Down

0 comments on commit 1f2ba79

Please sign in to comment.