Skip to content

Commit f93a4f8

Browse files
committed
feat: support industries_taxonomy, partners_taxonomy and capabilities in metadata
1 parent 5e2ef39 commit f93a4f8

File tree

3 files changed

+127
-21
lines changed

3 files changed

+127
-21
lines changed

README.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,28 @@ A skaffold frontmatter blog is created, and you can start writing in the index.m
9191
## frontmatter properties
9292
You can set the following properties in the frontmatter:
9393

94-
| Name | description |
95-
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
96-
| title | of the blog |
97-
| subtitle | of the blog, used in the og.image |
98-
| focus-keywords | the SEO focus keywords
99-
| excerpt | excerpt of the blog |
100-
| author | display name of the author in Wordpress |
101-
| email | email address of the author, used to lookup profile picture on gravatar.com |
102-
| author-id | Wordpress author slug: used to select the appropriate user if multiple users with the same name exists in WP and we cannot read the email address |
103-
| categories | list of wordpress categories for this blog |
104-
| slug | slug of the blog |
105-
| date | on which the blog should be published ISO timestamp format |
106-
| status | draft or publish. if publish, the blog will be published on the `date` |
107-
| canonical | url of the blog, to be used in cross posts |
108-
| image | the banner image of the blog |
109-
| og.image | the open graph image of the blog, used in links from social media |
110-
| og.description | the open graph description of the blog, used in links from social media |
111-
| guid | the physical URL of the blog. Written by wp-md on upload and download |
112-
| brand | xebia.com or xebia.com. defaults to xebia.com |
113-
94+
| Name | description |
95+
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
96+
| title | of the blog |
97+
| subtitle | of the blog, used in the og.image |
98+
| focus-keywords | the SEO focus keywords
99+
| excerpt | excerpt of the blog |
100+
| author | display name of the author in Wordpress |
101+
| email | email address of the author, used to lookup profile picture on gravatar.com |
102+
| author-id | Wordpress author slug: used to select the appropriate user if multiple users with the same name exists in WP and we cannot read the email address |
103+
| categories | list of wordpress categories for this blog |
104+
| slug | slug of the blog |
105+
| date | on which the blog should be published ISO timestamp format |
106+
| status | draft or publish. if publish, the blog will be published on the `date` |
107+
| canonical | url of the blog, to be used in cross posts |
108+
| image | the banner image of the blog |
109+
| og.image | the open graph image of the blog, used in links from social media |
110+
| og.description | the open graph description of the blog, used in links from social media |
111+
| guid | the physical URL of the blog. Written by wp-md on upload and download |
112+
| brand | xebia.com or xebia.com. defaults to xebia.com |
113+
| industry_taxonomy | zero or more of banking-and-financial-services, energy-utilities, healthcare-life-sciences, insurance, isv-tech, non-profit, private-equity, public-sector, retail-and-consumer-goods, telecom-media |
114+
| partners_taxonomy | zero or more of modernization-experience-based-acceleration-modax, genai-on-google-cloud, monday, cloud-workplace-solutions, cloud-workplace, google-workplace-tools, workplace-security, workplace-optimization, microsoft-library, developer-productivity-with-github-copilot |
115+
| capabilities | zero or more of agile-transformation, applied-and-genai, cloud, data-analytics, devops-sre, digital-product-management, intelligent-automation, it-strategy, platform-engineering, product-platform-development |
114116

115117
## adding images
116118
To add an image to your blog, add the images in the ./images subdirectory and add a relative reference in markdown. For instance:

src/wordpress_markdown_blog_loader/api.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ def raw_content(self) -> Optional[str]:
204204
def categories(self) -> list[id]:
205205
return self.get("categories", [])
206206

207+
@property
208+
def industries_taxonomy(self) -> list[id]:
209+
return self.get("industries_taxonomy", [])
210+
211+
@property
212+
def partners_taxonomy(self) -> list[id]:
213+
return self.get("partners_taxonomy", [])
214+
215+
@property
216+
def capabilities(self) -> list[id]:
217+
return self.get("capabilities", [])
218+
207219
@property
208220
def tags(self) -> list[int]:
209221
return self.get("tags", [])
@@ -415,6 +427,37 @@ def categories(self) -> Dict[str, int]:
415427
def categories_by_id(self) -> Dict[int, str]:
416428
return {id: slug for slug, id in self.categories.items()}
417429

430+
@property
431+
@cache
432+
def industries_taxonomy(self) -> Dict[str, int]:
433+
return {c["slug"]: c["id"] for c in self.get_all("industries_taxonomy")}
434+
435+
@property
436+
@cache
437+
def industries_taxonomy_by_id(self) -> Dict[str, int]:
438+
return {id: slug for slug, id in self.industries_taxonomy.items()}
439+
440+
@property
441+
@cache
442+
def partners_taxonomy(self) -> Dict[str, int]:
443+
return {c["slug"]: c["id"] for c in self.get_all("partners_taxonomy")}
444+
445+
@property
446+
@cache
447+
def partners_taxonomy_by_id(self) -> Dict[str, int]:
448+
return {id: slug for slug, id in self.partners_taxonomy.items()}
449+
450+
@property
451+
@cache
452+
def capabilities(self) -> Dict[str, int]:
453+
return {c["slug"]: c["id"] for c in self.get_all("capabilities")}
454+
455+
@property
456+
@cache
457+
def capabilities_by_id(self) -> Dict[str, int]:
458+
return {id: slug for slug, id in self.capabilities.items()}
459+
460+
418461
@property
419462
@cache
420463
def tags(self) -> Dict[str, int]:
@@ -573,6 +616,37 @@ def get_category_id_by_name(self, category: str) -> str:
573616
)
574617
)
575618

619+
def get_industry_taxonomy_by_name(self, slug: str) -> str:
620+
if slug in self.industries_taxonomy:
621+
return self.industries_taxonomy[slug]
622+
623+
raise ValueError(
624+
"invalid industries_taxonomy '{}' try one of\n {}".format(
625+
slug, ",\n ".join(self.industries_taxonomy.keys())
626+
)
627+
)
628+
629+
def get_partners_taxonomy_by_name(self, slug: str) -> str:
630+
if slug in self.partners_taxonomy:
631+
return self.partners_taxonomy[slug]
632+
633+
raise ValueError(
634+
"invalid partners_taxonomy '{}' try one of\n {}".format(
635+
slug, ",\n ".join(self.partners_taxonomy.keys())
636+
)
637+
)
638+
639+
def get_capabilities_by_name(self, slug: str) -> str:
640+
if slug in self.capabilities:
641+
return self.capabilities[slug]
642+
643+
raise ValueError(
644+
"invalid capabilities '{}' try one of\n {}".format(
645+
slug, ",\n ".join(self.capabilities.keys())
646+
)
647+
)
648+
649+
576650
def get_tag_id_by_name(self, tag: str) -> str:
577651
if tag in self.tags:
578652
return self.tags[tag]

src/wordpress_markdown_blog_loader/blog.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from binx_og_image_generator import generate as generate_og_image
1515
from binx_og_image_generator.generator import Blog as ImageGeneratorBlog
1616
from markdown import markdown
17+
1718
from wordpress_markdown_blog_loader.api import Post, Medium
1819
from wordpress_markdown_blog_loader.api import Wordpress, WordpressEndpoint
1920
from wordpress_markdown_blog_loader.remove_newlines import (
@@ -196,6 +197,30 @@ def categories(self):
196197
def categories(self, categories: list[str]):
197198
self.blog.metadata["categories"] = categories
198199

200+
@property
201+
def industry_taxonomy(self):
202+
return self.blog.metadata.get("industry_taxonomy", [])
203+
204+
@industry_taxonomy.setter
205+
def industry_taxonomy(self, slugs: list[str]):
206+
self.blog.metadata["industry_taxonomy"] = slugs
207+
208+
@property
209+
def partners_taxonomy(self):
210+
return self.blog.metadata.get("partners_taxonomy", [])
211+
212+
@partners_taxonomy.setter
213+
def partners_taxonomy(self, slugs: list[str]):
214+
self.blog.metadata["partners_taxonomy"] = slugs
215+
216+
@property
217+
def capabilities(self) -> list[str]:
218+
return self.blog.metadata.get("capabilities", [])
219+
220+
@capabilities.setter
221+
def capabilities(self, slugs: list[str]):
222+
self.blog.metadata["capabilities"] = slugs
223+
199224
@property
200225
def tags(self):
201226
return self.blog.metadata.get("tags", [])
@@ -375,8 +400,10 @@ def to_wordpress(self, wp: Wordpress) -> dict:
375400
"categories": [wp.get_category_id_by_name(c) for c in self.categories],
376401
"tags": [wp.get_tag_id_by_name(c) for c in self.tags],
377402
"acf": {"show_header_image": bool(self.image)},
403+
"industry_taxonomy": [wp.get_industry_taxonomy_by_name(c) for c in self.industry_taxonomy],
404+
"partners_taxonomy": [wp.get_partners_taxonomy_by_name(c) for c in self.partners_taxonomy],
405+
"capabilities": [wp.get_capabilities_by_name(c) for c in self.capabilities],
378406
}
379-
380407
if self.permalink_template:
381408
result["permalink_template"] = self.permalink_template
382409

@@ -421,6 +448,9 @@ def from_wordpress(
421448
blog.author = wordpress.get_user_by_id(post.author).name
422449
blog.guid = post.guid
423450
blog.categories = [wordpress.categories_by_id[c] for c in post.categories]
451+
blog.industry_taxonomy = [wordpress.industries_taxonomy_by_id for c in post.industry_taxonomy]
452+
blog.partners_taxonomy = [wordpress.partners_taxonomy_by_id for c in post.partners_taxonomy]
453+
blog.capabilities = [wordpress.capabilities_by_id for c in post.capabilities]
424454
if post.tags:
425455
blog.tags = [wordpress.tags_by_id[t] for t in post.tags]
426456
blog.date = post.date

0 commit comments

Comments
 (0)