Don't prepend images with the blog base URL if they are already full URLs
This commit is contained in:
parent
bf714a30bc
commit
43897cc961
1 changed files with 18 additions and 9 deletions
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
import re
|
||||
from typing import Optional
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from flask import (
|
||||
jsonify,
|
||||
|
@ -167,15 +169,22 @@ def rss_route():
|
|||
base_link=config.link,
|
||||
title=page.get("title", "[No Title]"),
|
||||
link=page.get("uri", ""),
|
||||
published=page["published"].strftime(
|
||||
"%a, %d %b %Y %H:%M:%S GMT"
|
||||
)
|
||||
published=(
|
||||
page["published"].strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||
if "published" in page
|
||||
else "",
|
||||
content=page.get("description", "")
|
||||
else ""
|
||||
),
|
||||
content=(
|
||||
page.get("description", "")
|
||||
if short_description
|
||||
else page.get("content", ""),
|
||||
image=page.get("image", ""),
|
||||
else page.get("content", "")
|
||||
),
|
||||
image=(
|
||||
urljoin(config.link, page["image"])
|
||||
if page.get("image")
|
||||
and not re.search(r"^https?://", page["image"])
|
||||
else page.get("image", "")
|
||||
),
|
||||
)
|
||||
for _, page in pages
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue