Hi everyone,
I’m customizing my Obsidian setup and need some help with CSS to hide certain frontmatter fields in preview mode. Specifically, I want to display only the “kind,” “topics,” and “status” fields, and hide all other fields.
Here’s the current look of my frontmatter:
aliases::
title::
kind::
mode::
topics::
status::
date:: [[2024-06-08]]
summary::
I’ve tried the following CSS to achieve this, but it didn’t work as expected:
/* Ensure frontmatter is displayed */
.markdown-preview-view .frontmatter {
display: block;
}
/* Hide all frontmatter fields except 'kind', 'topics', and 'status' */
.markdown-preview-view .frontmatter > :not(.frontmatter-key:contains("kind")):not(.frontmatter-key:contains("topics")):not(.frontmatter-key:contains("status")) {
display: none;
}
/* Ensure 'kind', 'topics', and 'status' are visible */
.markdown-preview-view .frontmatter > .frontmatter-key:contains("kind"),
.markdown-preview-view .frontmatter > .frontmatter-key:contains("topics"),
.markdown-preview-view .frontmatter > .frontmatter-key:contains("status") {
display: block;
}
I also tried the following CSS, but it didn’t work either:
div.metadata-properties > div.metadata-property[data-property-key="Property Name"] {
display: none;
}
I’m not sure if I’m targeting the elements properly or if there’s an issue with the syntax.
Has anyone successfully hidden specific frontmatter fields in preview mode? Any suggestions or insights would be greatly appreciated!
Thank you in advance for your help!