mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-31 05:22:43 +00:00
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;
|
||
|
};
|
||
|
|
||
|
})();
|