Attributes evaluation

Attributes evaluation allow you to dynamically compute the value of your attributes.

To dinamically compute the value of an attribute, just prefix it with eval:. ssgo will simply evaluate the expression given as value of the attribute, and will replace it into the built page.

For example, let's say that one of your creators is triggering a build page with the following data:

  metaTitle: 'Lorem ipsum dolor si amet',
  slugify: (str: string) => str.toLowerCase().replace(' ', '-')
  image: {
    imgSrc: '',

Then you can evaluate the value of attributes as follows:

    <meta name="title" eval:content="metaTitle" />
    <img eval:src="image.imgSrc" eval:alt="slugify(metaTitle)" />

Once built, our page will look like that:

    <meta name="title" content="Lorem ipsum dolor si amet" />
    <img src="" alt="lorem-ipsum-dolor-si-amet" />

The special treatment of the class attribute

As the class attribute generally contains more than one value, ssgo allows passing a object to eval:class: every value of the object will be evaluated, and if truthy, the corresponding key will be added to the resulting class attribute:

    'flex shadow': true,
    'flex-col': metaTitle.length > 2,
    'flex-row justify-between': metaTitle.length <= 2

The previous example will output:

Something about this page is wrong? Edit it on GitHub.