Table of contents
No headers

GetPageTags

Last modified 00:17, 30 Sep 2016
Table of contents
No headers
/**
    Get a list of tags for the current page.  Can be filtered by free vs. structured.
*/

var structuredTags = $0 ?? json.parse(site.classifications.configuration) ?? import('MindTouch/Functions/GetStructuredTagsDefinition');
var structuredPrefixes = [];
if (structuredTags) {
    foreach (var tagInfo in structuredTags) {
        structuredPrefixes ..= [ tagInfo.prefix ];
    }
}

var pageTags = page.tags;
var tags = {
    free: [],
    structured: []
};
if (#pageTags) {
    foreach (var tag in map.keys(pageTags)) {
        var isStructured = false;
        foreach (var prefix in structuredPrefixes) {
            if (!isStructured && string.startswith(tag, prefix .. ':')) {
                isStructured = true;
                break;
            }
        }
        if (isStructured) {
            tags.structured ..= [ tag ];
        } else {
            tags.free ..= [ tag ];
        }
    }
}
export = tags;
Page statistics
145 view(s) and 8 edit(s)

Tags

This page has no custom tags.
This page has no classifications.

Comments

You must to post a comment.

Attachments