Skip to content
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

Use property alias for metas plugin #321

Closed
oscarotero opened this issue Nov 22, 2022 · 0 comments
Closed

Use property alias for metas plugin #321

oscarotero opened this issue Nov 22, 2022 · 0 comments
Labels
enhancement New feature or request Idea plugins
Milestone

Comments

@oscarotero
Copy link
Member

oscarotero commented Nov 22, 2022

Enter your suggestions in details:

The metas plugin has the defaultPageData option to configure default values for the metas properties. I think this is not convenient due two reasons:

  • It cannot be configured per page because it's defined in the _config.ts file
  • If some defaults values are defined in a _data file (for example, metas.title), then you need to do metas.title = null to use the default value configured.

I propose to change the plugin to implement a syntax to define aliases to existing variables. For example:

title: Hello world
description: This is my site

metas:
  title: $title
  description: $description

Any value starting with $ sign would be interpreted as an alias to an existing value (in the example above, title and description. It could allow also values like $header.title.

This allows to have different defaults for different types of pages, using _data files in subfolders.

Edit:

Maybe the sign ~ is better, because it's what's used by the url plugin to refer to source files (like ~/about-me.md):

title: Hello world
description: This is my site

metas:
  title: ~title
  description: ~description

Other alternative syntaxes:

title: Hello world
description: This is my site

metas:
  title: &title
  description: &description

(Cons: The & sign is a thing in Yaml).

title: Hello world
description: This is my site

metas:
  title: {{ title }}
  description: {{ description }}

(Const: It looks like nunjucks, people may think it's possible to use filters and other nunjucks features).

Any feedback is welcome!

@oscarotero oscarotero added enhancement New feature or request plugins Idea labels Nov 22, 2022
@oscarotero oscarotero added this to the 1.14.0 milestone Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Idea plugins
Projects
None yet
Development

No branches or pull requests

1 participant