mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
4966f6ab62
Fixes #3379
37 lines
769 B
JavaScript
37 lines
769 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/duplicateslugs.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter function for [duplicateslugs[]]
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.duplicateslugs = function(source,operator,options) {
|
|
var slugs = Object.create(null), // Hashmap by slug of title, replaced with "true" if the duplicate title has already been output
|
|
results = [];
|
|
source(function(tiddler,title) {
|
|
var slug = options.wiki.slugify(title);
|
|
if(slug in slugs) {
|
|
if(slugs[slug] !== true) {
|
|
results.push(slugs[slug]);
|
|
slugs[slug] = true;
|
|
}
|
|
results.push(title);
|
|
} else {
|
|
slugs[slug] = title;
|
|
}
|
|
});
|
|
return results;
|
|
};
|
|
|
|
})();
|