# Set a credit in layers

*nods · The package*

A studio, a project, an installation and the site itself can each set a value. The resolver folds them into one configuration.

```js
import { creditHTML, optionsFromConfig, withWords } from '@nodsto/credit';
import { resolveWithDefaults } from '@nodsto/record/config';

const { config, blocked } = resolveWithDefaults([
  {
    origin: 'workspace',
    config: { words: { statement: 'Site by {creators}' } },
    pin: ['words.statement'],
  },
  {
    origin: 'project',
    config: {
      words: { statement: 'Made by {creators}', join: { two: ' with ' } },
      document: { target: '_self' },
    },
  },
  { origin: 'host', config: { document: { target: '_self' } } },
]);

const html = creditHTML(withWords(record, config), optionsFromConfig(config));
```

## Pass the layers in order.

`resolveWithDefaults` folds the layers leaf by leaf, so a project that sets one value keeps everything else the studio set in the same group. It returns the configuration and a list of what it left out.

blocked

```
[
  {
    "path": "words.statement",
    "origin": "project",
    "reason": "pinned",
    "pinnedBy": "workspace"
  },
  {
    "path": "document.target",
    "origin": "project",
    "reason": "host-only"
  }
]
```

## Let the later layer win.

A layer can pin a path, which locks it against the layers after it. The site’s own code comes last and nothing is pinned against it.

default The package’s own values.

workspace The studio, for every credit it places.

project One piece of work.

instance One installation of a credit, on one site.

host The site’s own code. It is read last and always wins.

## Set values in six groups.

select What this installation shows, section by section. It narrows a surface and leaves the record whole.

words Every string a person chose, among them the statement, the control’s label and the joining words.

style The line style, the card, the tone and the tokens.

behaviour What a click opens, whether a pointer opens it too, and the timings.

link Where a credited name points.

document The rel, the target, the class and the summary, which reach into the site’s own page. Only the site may set it.

## Read why a value was left out.

A refused value falls back to the layer under it. A token has to be named `--nods-*` or for a template, and its value may hold neither a closing brace nor anything that loads a file.

host-only The value is in the document group and came from a layer other than the site.

pinned An earlier layer pinned the path.

unknown-group The group is none of the six.

bad-token-name The token is named for neither nods nor a template.

bad-token-value The value could close the rule or load a file.

## Cap every layer with what the client agreed to.

Consent is a term of your agreement with the client. It takes the lowest tier any layer states, so no setting can raise it. Four tiers run from nothing to everything.

| Tier | Agreed as | The site carries |
|---|---|---|
| `none` | No credit | Nothing is added. |
| `fingerprint` | In the code only | A machine-readable record in the page source. Visitors see no change. |
| `line` | Text and link | One line in the footer, with each name linked. |
| `full` | Full | The line, and a panel with the whole record that opens when a visitor asks for it. |

That is the whole package. [Paste the block into a site](https://docs.nods.to/paste-block/) starts the platform.

---
https://docs.nods.to/config/ · nods 0.1.0 · MIT
