
<script>
export default {
    render: function(createElement) {
        var paths = this.path.split('/');
        var pathsNames = decodeURIComponent(this.path).split('/');

        if (paths.length === 1 && paths[0] === '') {
            paths = [];
        }

        var pathsStruct = [];

        for (var i = 0; i < paths.length; i++) {
            pathsStruct.push({
                name: pathsNames[i],
                path: paths.slice(0, i + 1).join('/')
            });
        }

        var homeAttrs = {
            props: {
                to: {
                    name: 'browser'
                }
            }
        };

        var links = [
            createElement('router-link', homeAttrs, 'Home')
        ];

        for (var i = 0; i < pathsStruct.length; i++) {
            var struct = pathsStruct[i];
            var structAttrs = {
                props: {
                    to: {
                        name: 'browser',
                        params: [struct.path]
                    }
                }
            };

            links.push(' -> ');
            links.push(createElement('router-link', structAttrs, struct.name));
        }

        return createElement('span', {}, links);
    },

    props: {
        path: {
            type: String,
            required: true
        }
    }
};
</script>
