-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Enhancement: Conditional UI for Metadata #362
Comments
Love this idea. Another use case for conditional metadata is when it applies only to section pages (for example, |
Good news @michaeltlombardi and @bwklein, this is now supported in the latest beta version. Sample{
"title": "Description",
"name": "description",
"type": "string",
"when": {
"fieldRef": "title",
"operator": "contains",
"value": "website",
"caseSensitive": false
}
}
OperatorThe following operators are supported:
|
@estruyf I finally got some time to dig in today, looking to make the section-only metadata (in my case, controlling whether a section is collapsed or flattened in site navigation) conditional. I'm not savvy enough with the code base yet to follow things around properly, but I can intuitively see how this implementation works conditionally on other metadata fields - is there a way to reference the file name in this implementation? I'm looking to make something like this work: Example JSON Definition{
"name": "default",
"$schema": "https://beta.frontmatter.codes/config/taxonomy.contenttypes.schema.json",
"pageBundle": false,
"fields": [
{
"title": "Platen",
"type": "fields",
"name": "Platen",
"fields": [
{
"title": "Menu options",
"name": "Menu",
"type": "fields",
"fields": [
{
"title": "Flatten section in site menu",
"name": "FlattenSection",
"type": "boolean",
"when": {
"fieldRef": "file.baseName",
"operator": "eq",
"value": "_index.md"
}
},
{
"title": "Collapse section in site menu",
"name": "CollapseSection",
"type": "boolean",
"when": {
"fieldRef": "file.baseName",
"operator": "eq",
"value": "_index.md"
}
},
{
"title": "Hide from site menu",
"description": "Applicable to any page.",
"name": "Hide",
"type": "boolean"
}
]
}
]
}
]
} Where the |
This change adds the `toroidal` and `toroidal/admin` content types to the Front Matter configuration so that site maintainers can edit the metadata for those pages in a friendly UI. For member pages and the admin page, this is fully functional. For the webring index, this is limited currently by the implementation of estruyf/vscode-front-matter#362, which introduces `where` logic for the fields but doesn't yet support using that logic to control behavior based on the file name, which would allow us to handle section pages (which are always named `_index.md`) separately from member pages. This change also updates the archetypes for Toroidal to set the `type` to `toroidal` for the index and member pages, ensuring that Front Matter picks up the type correctly for selecting the metadata to display. Due to a limitation outlined in estruyf/vscode-front-matter#360 (see [this comment for more information][01]), we have to use `type` to identify files. This has some implications for Hugo sites which don't _directly_ impact this change. [01]: estruyf/vscode-front-matter#360 (comment)
Discussed in #357
Originally posted by bwklein June 13, 2022
I would like to show only the fields that are required based on some boolean or choice field selections.
For example, I have a 'Heading' partial that can either have text based title or a logo based heading.
I would like to allow the editor to choose if they want a text or logo based heading with a boolean choice like "Logo Heading?"
If
true
, then I would like to show them a Logo choice field and a string field for 'Classes' that they can pass in to style the logo. Essentially showing them a Field Group for the 'Logo' settings.If
false
, then I would like to show the fieldgroup for the "Text" heading data.Solution
The text was updated successfully, but these errors were encountered: