diff --git a/tildes/tildes/models/topic/topic.py b/tildes/tildes/models/topic/topic.py
index b069bb8..124135d 100644
--- a/tildes/tildes/models/topic/topic.py
+++ b/tildes/tildes/models/topic/topic.py
@@ -408,15 +408,16 @@ class Topic(DatabaseModel):
return False
- @property
- def content_type(self) -> TopicContentType:
+ @property # noqa
+ def content_type(self) -> Optional[TopicContentType]:
"""Return the content's type based on the topic's attributes."""
if self.is_text_type:
if self.has_tag("ask"):
return TopicContentType.ASK
return TopicContentType.TEXT
- else:
+
+ if self.is_link_type:
parsed_url = urlparse(self.link) # type: ignore
url_path = PurePosixPath(parsed_url.path)
@@ -435,7 +436,12 @@ class Topic(DatabaseModel):
except IndexError:
pass
- return TopicContentType.ARTICLE
+ # consider it an article if we picked up a word count of at least 200
+ word_count = self.get_content_metadata("word_count")
+ if word_count and word_count >= 200:
+ return TopicContentType.ARTICLE
+
+ return None
def get_content_metadata(self, key: str) -> Any:
"""Get a piece of content metadata "safely".
diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2
index 90cc985..6381dc6 100644
--- a/tildes/tildes/templates/macros/topics.jinja2
+++ b/tildes/tildes/templates/macros/topics.jinja2
@@ -46,7 +46,7 @@
{% endif %}
- {{ topic.content_type.display_name }}
+ {{ topic.content_type.display_name if topic.content_type else "Link" }}
{% if topic.content_metadata_for_display %}
: {{ topic.content_metadata_for_display }}