-
Notifications
You must be signed in to change notification settings - Fork 230
Tom/blog update ai app builder #1791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,6 +185,22 @@ def page(document, route) -> rx.Component: | |
| toc = [(level, text) for level, text in toc if level <= 3] | ||
| page_url = f"{REFLEX_URL.strip('/')}{route}" | ||
|
|
||
| # Extract keywords from meta tags list if present. | ||
| keywords_list = None | ||
| for tag in meta.get("meta", []): | ||
| if tag.get("name") == "keywords": | ||
| keywords_list = [ | ||
| k.strip() for k in tag.get("content", "").split(",") if k.strip() | ||
| ] | ||
| break | ||
|
|
||
| # Compute word count from the document content. | ||
| word_count = ( | ||
| len(document.content.split()) | ||
| if hasattr(document, "content") and document.content | ||
| else None | ||
| ) | ||
|
|
||
| jsonld_script = blog_jsonld( | ||
| title=meta["title"], | ||
| description=meta["description"], | ||
|
|
@@ -195,6 +211,8 @@ def page(document, route) -> rx.Component: | |
| faq=meta.get("faq"), | ||
| author_bio=meta.get("author_bio"), | ||
| updated_at=str(meta["updated_at"]) if meta.get("updated_at") else None, | ||
| word_count=word_count, | ||
| keywords=keywords_list, | ||
| ) | ||
|
|
||
| return rx.el.section( | ||
|
|
@@ -234,7 +252,7 @@ def page(document, route) -> rx.Component: | |
| ), | ||
| rx.el.header( | ||
| rx.el.h1( | ||
| meta.get("title_tag") or meta["title"], | ||
| meta["title"], | ||
| class_name="lg:text-5xl text-3xl text-m-slate-12 dark:text-m-slate-3 font-[575] mb-6 text-center text-balance", | ||
|
Comment on lines
254
to
256
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The diff removes the fallback: - meta.get("title_tag") or meta["title"]
+ meta["title"]There are currently 20+ published blog posts (e.g. The comment in |
||
| ), | ||
| rx.el.h2( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.content.split()operates on the raw markdown source, so the resulting word count will include code fence contents, markdown syntax tokens (e.g.##,**,-), inline backtick spans, and full URLs. For posts with multiple code samples the inflated count could be substantial, and schema.org'swordCountis defined as "the number of words in the text of the Article."A lightweight improvement is to strip code blocks and markdown syntax before counting:
This wouldn't need to be perfect, but would give a much closer approximation to actual prose word count.