def _collect_layer_metadata(config, layer_config):
    """Collect metadata for adding it to a layer."""
    meta = config.get("common_items", dict()).copy()
    meta.update(layer_config)
    if "title" not in meta and "title_pattern" in meta:
        meta["title"] = meta["title_pattern"]
    return meta