Kirby Query Language command for removing spaces in an array?

I have the following KQL syntax:

{{ page.tags }}

which list tags like this: “tag1, tag2, tag3”.
For building a Twitter Intent link I need to remove the spaces so that the output looks like this: “tag1,tag2,tag3”.
How can I achieve that?
The source field for tags is defined as this:

                type: tags
                options: query
                query: site.index.pluck("tags", ",", true)

I’m guessing your pulling this stuff into some kind of javascript front end?

You could cheat and strip spaces on the javascript side of the fence before doing something with it:

let str = 'tag1, tag2, tag3';
str = str.replace(/\s+/g, '');

No, I want to provide an easy way to share an article on Twitter directly from the panel like this:

                type: info
                label: Hilfreiche Links
                text: |
                      **(link:{{ page.title }}&hashtags={{ page.tags }},peleke,blog&url={{ page.url }} text: Auf Twitter veröffentlichen target: _blank)**

As described in the documentation there are no spaces allowed for the hashtags.

Oh, KQL was a bit misleading, because that is a Kirby plugin.

In your case, you’d better create a custom page method or a field method that returns the desired value.

Kirby::plugin('your/plugin', [
    'fieldMethods' => [
        'removeSpaces' => function ($field) {
             return implode(',', $field->split(','));

Then in your blueprint: {{ page.tags.removeSpaces }}.

The code converts the field value to an array with split() and then joins the pieces again with a comma.

The alternative would be the PHP variant to what @jimbobrjames posted above, but that would also remove whitespace from multi-word tags, therefore the above is more reliable (or the pattern would have to be extended).

Great Sonja, thanks a lot!
Without you working with Kirby (as a beginner) would be only half the fun!
Regarding Kirby Query Language: isn’t that the right term for the official core implementation of those variables? Query Language | Kirby CMS