From 8b48fe47d2cc52b6d88c309346a9af359cc7bf58 Mon Sep 17 00:00:00 2001 From: Sascha Zarhuber Date: Tue, 3 Oct 2017 17:54:32 +0200 Subject: [PATCH 1/4] feat(normalize): Added option to normalize tag names --- lib/index.js | 7 +- yarn.lock | 847 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 853 insertions(+), 1 deletion(-) create mode 100644 yarn.lock diff --git a/lib/index.js b/lib/index.js index ea2f546..b33f36f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -18,6 +18,7 @@ function plugin(opts) { opts.layout = opts.layout || 'partials/tag.hbt'; opts.handle = opts.handle || 'tags'; opts.metadataKey = opts.metadataKey || 'tags'; + opts.normalize = opts.normalize || opts.slugify || false; opts.sortBy = opts.sortBy || 'title'; opts.reverse = opts.reverse || false; opts.perPage = opts.perPage || 0; @@ -97,9 +98,13 @@ function plugin(opts) { // Trim leading + trailing white space from tag. var tag = String(rawTag).trim(); + // If normalize/slugify was set to true, remove all special characters like ÄÖØß... + const normalizedTag = opts.normalize ? safeTag(tag) : tag; + // Save url safe formatted and display versions of tag data - data[opts.handle].push({ name: tag, slug: safeTag(tag)}); + // Prevent transforming into a safe tag again, if it was done before + data[opts.handle].push({ name: tag, slug: opts.normalize ? tag : safeTag(tag)}); // Add each tag to our overall tagList and initialize array if it // doesn't exist. diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..285c509 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,847 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +absolute@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/absolute/-/absolute-0.0.1.tgz#c22822f87e1c939f579887504d9c109c4173829d" + +acorn@^4.0.3: + version "4.0.13" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +alter@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/alter/-/alter-0.2.0.tgz#c7588808617572034aae62480af26b1d4d1cb3cd" + dependencies: + stable "~0.1.3" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ansi-red@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c" + dependencies: + ansi-wrap "0.1.0" + +ansi-regex@^0.2.0, ansi-regex@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" + +ansi-styles@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de" + +ansi-wrap@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" + +argparse@^1.0.7: + version "1.0.9" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" + dependencies: + sprintf-js "~1.0.2" + +array-differ@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +assert-dir-equal@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/assert-dir-equal/-/assert-dir-equal-1.0.1.tgz#1a0bc214bd227282d7b3cc8b61381a934edcebc9" + dependencies: + buffer-equal "0.0.0" + fs-readdir-recursive "0.0.1" + is-utf8 "~0.2.0" + +ast-traverse@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ast-traverse/-/ast-traverse-0.1.1.tgz#69cf2b8386f19dcda1bb1e05d68fe359d8897de6" + +ast-types@0.8.12: + version "0.8.12" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.12.tgz#a0d90e4351bb887716c83fd637ebf818af4adfcc" + +ast-types@0.9.6: + version "0.9.6" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.6.tgz#102c9e9e9005d3e7e3829bf0c4fa24ee862ee9b9" + +async@^1.3.0, async@^1.4.0: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + +async@~0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +bluebird@^3.1.1: + version "3.5.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" + +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +breakable@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/breakable/-/breakable-1.0.0.tgz#784a797915a38ead27bad456b5572cb4bbaa78c1" + +buffer-equal@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-0.0.0.tgz#4a68196ac33522daa17ec99858b302a636b62cf1" + +camelcase@^1.0.2, camelcase@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chalk@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174" + dependencies: + ansi-styles "^1.1.0" + escape-string-regexp "^1.0.0" + has-ansi "^0.1.0" + strip-ansi "^0.3.0" + supports-color "^0.2.0" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +clone@^0.1.11: + version "0.1.19" + resolved "https://registry.yarnpkg.com/clone/-/clone-0.1.19.tgz#613fb68639b26a494ac53253e15b1a6bd88ada85" + +co-from-stream@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/co-from-stream/-/co-from-stream-0.0.0.tgz#1a5cd8ced77263946094fa39f2499a63297bcaf9" + dependencies: + co-read "0.0.1" + +co-fs-extra@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/co-fs-extra/-/co-fs-extra-0.0.2.tgz#02cfb5cd5c24b25f6880d3e602a79bbe3a40f934" + dependencies: + co-fs "1.2.0" + fs-extra "0.12.0" + thunkify "2.1.2" + +co-fs@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/co-fs/-/co-fs-1.2.0.tgz#a6df045ce58c04eed45586ff4385032813aba64e" + dependencies: + co-from-stream "0.0.0" + thunkify "0.0.1" + +co-read@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/co-read/-/co-read-0.0.1.tgz#f81b3eb8a86675fec51e3d883a7f564e873c9389" + +co@3.1.0, co@~3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/co/-/co-3.1.0.tgz#4ea54ea5a08938153185e15210c68d9092bc1b78" + +coffee-script@^1.12.4: + version "1.12.7" + resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.7.tgz#c05dae0cb79591d05b3070a8433a98c9a89ccc53" + +commander@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" + +commander@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" + +commander@^2.5.0, commander@^2.6.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" + +commoner@~0.10.3: + version "0.10.8" + resolved "https://registry.yarnpkg.com/commoner/-/commoner-0.10.8.tgz#34fc3672cd24393e8bb47e70caa0293811f4f2c5" + dependencies: + commander "^2.5.0" + detective "^4.3.1" + glob "^5.0.15" + graceful-fs "^4.1.2" + iconv-lite "^0.4.5" + mkdirp "^0.5.0" + private "^0.1.6" + q "^1.1.2" + recast "^0.11.17" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +consolidate@^0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/consolidate/-/consolidate-0.14.5.tgz#5a25047bc76f73072667c8cb52c989888f494c63" + dependencies: + bluebird "^3.1.1" + +debug@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +debug@^2.2.0: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +decamelize@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +defined@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" + +defs@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/defs/-/defs-1.1.1.tgz#b22609f2c7a11ba7a3db116805c139b1caffa9d2" + dependencies: + alter "~0.2.0" + ast-traverse "~0.1.1" + breakable "~1.0.0" + esprima-fb "~15001.1001.0-dev-harmony-fb" + simple-fmt "~0.1.0" + simple-is "~0.2.0" + stringmap "~0.2.2" + stringset "~0.2.1" + tryor "~0.1.2" + yargs "~3.27.0" + +detective@^4.3.1: + version "4.5.0" + resolved "https://registry.yarnpkg.com/detective/-/detective-4.5.0.tgz#6e5a8c6b26e6c7a254b1c6b6d7490d98ec91edd1" + dependencies: + acorn "^4.0.3" + defined "^1.0.0" + +diff@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + +escape-string-regexp@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" + +escape-string-regexp@^1.0.0: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esprima-fb@~15001.1001.0-dev-harmony-fb: + version "15001.1001.0-dev-harmony-fb" + resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz#43beb57ec26e8cf237d3dd8b33e42533577f2659" + +esprima@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" + +esprima@~3.1.0: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + dependencies: + is-extendable "^0.1.0" + +extend@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +fs-extra@0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.12.0.tgz#407cf6e11321e440d66f9486fba1cc9eb4c21868" + dependencies: + jsonfile "^2.0.0" + mkdirp "^0.5.0" + ncp "^0.6.0" + rimraf "^2.2.8" + +fs-extra@~0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.10.0.tgz#99c0ec2fd5eaaad9d646245e4b014b56729982af" + dependencies: + jsonfile "^1.2.0" + mkdirp "^0.5.0" + ncp "^0.5.1" + rimraf "^2.2.8" + +fs-readdir-recursive@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-0.0.1.tgz#f2223ab40293e436696d33b67f6b3e6d2e6a8c12" + +fs-readdir-recursive@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +glob@3.2.11: + version "3.2.11" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" + dependencies: + inherits "2" + minimatch "0.3" + +glob@^5.0.15: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.0.5: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +gnode@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/gnode/-/gnode-0.1.2.tgz#0a955a5cc222f699e14306a4559505d90080fdd9" + dependencies: + regenerator "~0.8.8" + +graceful-fs@^4.1.2, graceful-fs@^4.1.6: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +gray-matter@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-2.1.1.tgz#3042d9adec2a1ded6a7707a9ed2380f8a17a430e" + dependencies: + ansi-red "^0.1.1" + coffee-script "^1.12.4" + extend-shallow "^2.0.1" + js-yaml "^3.8.1" + toml "^2.3.2" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +handlebars@*: + version "4.0.10" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" + dependencies: + async "^1.4.0" + optimist "^0.6.1" + source-map "^0.4.4" + optionalDependencies: + uglify-js "^2.6" + +has-ansi@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" + dependencies: + ansi-regex "^0.2.0" + +iconv-lite@^0.4.5: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + +is-buffer@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" + +is-extendable@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-utf8@^0.2.0, is-utf8@~0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +is@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/is/-/is-2.2.1.tgz#5b0557a3dc68089d978ecd1184cc8fc529837a04" + +jade@0.26.3: + version "0.26.3" + resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" + dependencies: + commander "0.6.1" + mkdirp "0.3.0" + +js-yaml@^3.8.1: + version "3.10.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsonfile@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-1.2.0.tgz#5f35d6cd9f946ec97b5b18353fa9e58df1b86f6a" + +jsonfile@^2.0.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + optionalDependencies: + graceful-fs "^4.1.6" + +kind-of@^3.0.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + dependencies: + invert-kv "^1.0.0" + +lodash.omit@^4.0.2: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +lru-cache@2: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + +metalsmith-layouts@1.x: + version "1.8.1" + resolved "https://registry.yarnpkg.com/metalsmith-layouts/-/metalsmith-layouts-1.8.1.tgz#a365d39939d9146cdfe51fadee7d875573fccbdc" + dependencies: + async "^1.3.0" + consolidate "^0.14.0" + debug "^2.2.0" + extend "^3.0.0" + fs-readdir-recursive "^1.0.0" + is-utf8 "^0.2.0" + lodash.omit "^4.0.2" + multimatch "^2.0.0" + +metalsmith@1.x: + version "1.7.0" + resolved "https://registry.yarnpkg.com/metalsmith/-/metalsmith-1.7.0.tgz#cb6860d5010d8036ada27c4496d149abe2a3504d" + dependencies: + absolute "0.0.1" + async "~0.9.0" + chalk "^0.5.0" + clone "^0.1.11" + co-fs-extra "0.0.2" + commander "^2.6.0" + fs-extra "~0.10.0" + gnode "^0.1.0" + gray-matter "^2.0.0" + is "^2.2.0" + is-utf8 "~0.2.0" + recursive-readdir "^1.2.1" + rimraf "^2.2.8" + stat-mode "^0.2.0" + thunkify "^2.1.2" + unyield "0.0.1" + ware "^1.2.0" + +minimatch@0.3, minimatch@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +mkdirp@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" + +mkdirp@0.5.1, mkdirp@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha@2.x: + version "2.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58" + dependencies: + commander "2.3.0" + debug "2.2.0" + diff "1.4.0" + escape-string-regexp "1.0.2" + glob "3.2.11" + growl "1.9.2" + jade "0.26.3" + mkdirp "0.5.1" + supports-color "1.2.0" + to-iso-string "0.0.2" + +moment@^2.10.3: + version "2.18.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +multimatch@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-2.1.0.tgz#9c7906a22fb4c02919e2f5f75161b4cdbd4b2a2b" + dependencies: + array-differ "^1.0.0" + array-union "^1.0.1" + arrify "^1.0.0" + minimatch "^3.0.0" + +ncp@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/ncp/-/ncp-0.5.1.tgz#743985316e3db459281b587169e845735a05439f" + +ncp@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/ncp/-/ncp-0.6.0.tgz#df8ce021e262be21b52feb3d3e5cfaab12491f0d" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +os-locale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + dependencies: + lcid "^1.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +private@^0.1.6, private@~0.1.5: + version "0.1.7" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" + +q@^1.1.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" + +recast@0.10.33: + version "0.10.33" + resolved "https://registry.yarnpkg.com/recast/-/recast-0.10.33.tgz#942808f7aa016f1fa7142c461d7e5704aaa8d697" + dependencies: + ast-types "0.8.12" + esprima-fb "~15001.1001.0-dev-harmony-fb" + private "~0.1.5" + source-map "~0.5.0" + +recast@^0.11.17: + version "0.11.23" + resolved "https://registry.yarnpkg.com/recast/-/recast-0.11.23.tgz#451fd3004ab1e4df9b4e4b66376b2a21912462d3" + dependencies: + ast-types "0.9.6" + esprima "~3.1.0" + private "~0.1.5" + source-map "~0.5.0" + +recursive-readdir@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-1.3.0.tgz#c6e66c9ae473f4928f8e6c67a05d80e7a56528ef" + dependencies: + minimatch "0.3.0" + +regenerator-runtime@~0.9.5: + version "0.9.6" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.9.6.tgz#d33eb95d0d2001a4be39659707c51b0cb71ce029" + +regenerator@~0.8.8: + version "0.8.46" + resolved "https://registry.yarnpkg.com/regenerator/-/regenerator-0.8.46.tgz#154c327686361ed52cad69b2545efc53a3d07696" + dependencies: + commoner "~0.10.3" + defs "~1.1.0" + esprima-fb "~15001.1001.0-dev-harmony-fb" + private "~0.1.5" + recast "0.10.33" + regenerator-runtime "~0.9.5" + through "~2.3.8" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +rimraf@^2.2.8: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + dependencies: + glob "^7.0.5" + +sigmund@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + +simple-fmt@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/simple-fmt/-/simple-fmt-0.1.0.tgz#191bf566a59e6530482cb25ab53b4a8dc85c3a6b" + +simple-is@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/simple-is/-/simple-is-0.2.0.tgz#2abb75aade39deb5cc815ce10e6191164850baf0" + +slug@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/slug/-/slug-0.9.1.tgz#af08f608a7c11516b61778aa800dce84c518cfda" + dependencies: + unicode ">= 0.3.1" + +source-map@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +source-map@~0.5.0, source-map@~0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + +stable@~0.1.3: + version "0.1.6" + resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.6.tgz#910f5d2aed7b520c6e777499c1f32e139fdecb10" + +stat-mode@^0.2.0: + version "0.2.2" + resolved "https://registry.yarnpkg.com/stat-mode/-/stat-mode-0.2.2.tgz#e6c80b623123d7d80cf132ce538f346289072502" + +stringmap@~0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/stringmap/-/stringmap-0.2.2.tgz#556c137b258f942b8776f5b2ef582aa069d7d1b1" + +stringset@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/stringset/-/stringset-0.2.1.tgz#ef259c4e349344377fcd1c913dd2e848c9c042b5" + +strip-ansi@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220" + dependencies: + ansi-regex "^0.2.1" + +supports-color@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" + +supports-color@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" + +through@~2.3.8: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +thunkify@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-0.0.1.tgz#bd5d36b1069b4078e5dcbac8fab45359bea6183d" + +thunkify@2.1.2, thunkify@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d" + +to-iso-string@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" + +toml@^2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/toml/-/toml-2.3.3.tgz#8d683d729577cb286231dfc7a8affe58d31728fb" + +tryor@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/tryor/-/tryor-0.1.2.tgz#8145e4ca7caff40acde3ccf946e8b8bb75b4172b" + +uglify-js@^2.6: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + dependencies: + source-map "~0.5.1" + yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +"unicode@>= 0.3.1": + version "10.0.0" + resolved "https://registry.yarnpkg.com/unicode/-/unicode-10.0.0.tgz#e5d51c1db93b6c71a0b879e0b0c4af7e6fdf688e" + +unyield@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/unyield/-/unyield-0.0.1.tgz#150e65da42bf7742445b958a64eb9b85d1d2b180" + dependencies: + co "~3.1.0" + +ware@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/ware/-/ware-1.3.0.tgz#d1b14f39d2e2cb4ab8c4098f756fe4b164e473d4" + dependencies: + wrap-fn "^0.1.0" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +window-size@^0.1.2: + version "0.1.4" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wrap-fn@^0.1.0: + version "0.1.5" + resolved "https://registry.yarnpkg.com/wrap-fn/-/wrap-fn-0.1.5.tgz#f21b6e41016ff4a7e31720dbc63a09016bdf9845" + dependencies: + co "3.1.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +y18n@^3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" + +yargs@~3.27.0: + version "3.27.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.27.0.tgz#21205469316e939131d59f2da0c6d7f98221ea40" + dependencies: + camelcase "^1.2.1" + cliui "^2.1.0" + decamelize "^1.0.0" + os-locale "^1.4.0" + window-size "^0.1.2" + y18n "^3.2.0" From 0cda0da979a25bce95d53f118aebe2727908ead5 Mon Sep 17 00:00:00 2001 From: Sascha Zarhuber Date: Tue, 3 Oct 2017 18:04:52 +0200 Subject: [PATCH 2/4] feat(tests): Added umlaut and special char in test case --- lib/index.js | 5 +++-- package.json | 1 + test/fixtures/src/about.html | 2 +- test/fixtures/src/index.html | 2 +- test/fixtures/src/json.html | 2 +- test/fixtures/src/page.html | 2 +- test/index.js | 3 ++- yarn.lock | 6 ++++++ 8 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/index.js b/lib/index.js index b33f36f..e9ab255 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,3 +1,4 @@ +var debug = require('debug')('metalsmith-tags'); var slug = require('slug'); /** @@ -99,8 +100,8 @@ function plugin(opts) { var tag = String(rawTag).trim(); // If normalize/slugify was set to true, remove all special characters like ÄÖØß... - const normalizedTag = opts.normalize ? safeTag(tag) : tag; - + var tag = opts.normalize ? safeTag(tag) : tag; + debug(tag); // Save url safe formatted and display versions of tag data // Prevent transforming into a safe tag again, if it was done before diff --git a/package.json b/package.json index 66c8f0d..07afb60 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "homepage": "https://github.com/totocaster/metalsmith-tags", "devDependencies": { "assert-dir-equal": "1.0.1", + "debug": "^3.1.0", "handlebars": "*", "metalsmith": "1.x", "metalsmith-layouts": "1.x", diff --git a/test/fixtures/src/about.html b/test/fixtures/src/about.html index dcad0e2..8084f8f 100644 --- a/test/fixtures/src/about.html +++ b/test/fixtures/src/about.html @@ -1,6 +1,6 @@ --- title: about -tags: hello +tags: hello, skøl date: 2014-02-02T17:39:06.157Z --- diff --git a/test/fixtures/src/index.html b/test/fixtures/src/index.html index 835fa91..d57ad8d 100644 --- a/test/fixtures/src/index.html +++ b/test/fixtures/src/index.html @@ -1,6 +1,6 @@ --- title: test -tags: hello, world, this is, tag +tags: hello, world, this is, tag, sköl date: 2014-03-02T17:39:06.157Z --- diff --git a/test/fixtures/src/json.html b/test/fixtures/src/json.html index 9176a73..ae5cfab 100644 --- a/test/fixtures/src/json.html +++ b/test/fixtures/src/json.html @@ -1,7 +1,7 @@ --- { "title": "test json", - "tags": ["hello", "tag"], + "tags": ["hello", "tag", "skol"], "date": "2014-01-07T17:39:06.157Z" } --- diff --git a/test/fixtures/src/page.html b/test/fixtures/src/page.html index f81163d..a9e0470 100644 --- a/test/fixtures/src/page.html +++ b/test/fixtures/src/page.html @@ -1,6 +1,6 @@ --- title: test page 2 -tags: hello, this, tag +tags: hello, this, tag, skØl date: 2014-02-07T17:39:06.157Z --- diff --git a/test/index.js b/test/index.js index 6f28ea1..8a90c4e 100644 --- a/test/index.js +++ b/test/index.js @@ -63,7 +63,8 @@ describe('metalsmith-tags', function() { Metalsmith('test/fixtures') .use(tags({ handle: 'tags', - path: 'topics' + path: 'topics', + normalize: true, })) .use(function(files, metalsmith, done) { tagList = metalsmith.metadata().tags; diff --git a/yarn.lock b/yarn.lock index 285c509..3f3c7c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -235,6 +235,12 @@ debug@^2.2.0: dependencies: ms "2.0.0" +debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + decamelize@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" From ca8860e1b101299826683604130cf66d29ac224c Mon Sep 17 00:00:00 2001 From: Sascha Zarhuber Date: Wed, 4 Oct 2017 16:39:29 +0200 Subject: [PATCH 3/4] fix(tests): Fixed tests --- README.md | 9 ++ .../expected/no-pagination/topics/skol.html | 10 +++ .../no-pagination/topics/this-is.html | 2 +- .../pagination/topics/skol/2/index.html | 4 + .../pagination/topics/skol/3/index.html | 4 + .../pagination/topics/skol/4/index.html | 4 + .../pagination/topics/skol/index.html | 4 + .../pagination/topics/this-is/index.html | 2 +- test/index.js | 83 +++++++++++++++++-- 9 files changed, 114 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/expected/no-pagination/topics/skol.html create mode 100644 test/fixtures/expected/pagination/topics/skol/2/index.html create mode 100644 test/fixtures/expected/pagination/topics/skol/3/index.html create mode 100644 test/fixtures/expected/pagination/topics/skol/4/index.html create mode 100644 test/fixtures/expected/pagination/topics/skol/index.html diff --git a/README.md b/README.md index ae6672e..654a46c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ You can use different handle for the tags, by configuring the `handle` option. ` /* Can also use deprecated template property. "template": "/partials/tag.hbt", */ + "normalize": true, "sortBy": "date", "reverse": true, "skipMetadata": false, @@ -68,6 +69,10 @@ metalsmith // metalsmith-templates plugin. The `template` property is deprecated here // as well but still available for use. // template:'/partials/tag.hbt', + // ------ + // Normalize special characters like ØçßÜ to their ASCII equivalents ocssü + // makes use of the value assigned to the 'slug' property below + normalize: true, // provide posts sorted by 'date' (optional) sortBy: 'date', // sort direction (optional) @@ -97,6 +102,10 @@ metalsmith It is possible to use `opts.metadataKey` for defining the name of the global tag list. By default it is `'tags'`. +### Normalized characters + + Handle with care. This is to be seen rather as a fallback as it heavily depends on your 'slug' settings. If you use the standard setting provided in this readme (*rfc3986*), you should be good to go. + ## Pagination Additionally you can paginate your tag pages. To do so add two additional properties to your configuration object, `pathPage` and `perPage`, and modify `path` to point to the root pagination location: diff --git a/test/fixtures/expected/no-pagination/topics/skol.html b/test/fixtures/expected/no-pagination/topics/skol.html new file mode 100644 index 0000000..f8229e0 --- /dev/null +++ b/test/fixtures/expected/no-pagination/topics/skol.html @@ -0,0 +1,10 @@ +

Posts for skol

+
    +
  • 07/02/2014 test page 2
  • + +
  • 07/01/2014 test json
  • + +
  • 02/03/2014 test
  • + +
  • 02/02/2014 about
  • +
\ No newline at end of file diff --git a/test/fixtures/expected/no-pagination/topics/this-is.html b/test/fixtures/expected/no-pagination/topics/this-is.html index 0ac07f6..612a27f 100644 --- a/test/fixtures/expected/no-pagination/topics/this-is.html +++ b/test/fixtures/expected/no-pagination/topics/this-is.html @@ -1,4 +1,4 @@ -

Posts for this is

+

Posts for this-is

  • 02/03/2014 test
\ No newline at end of file diff --git a/test/fixtures/expected/pagination/topics/skol/2/index.html b/test/fixtures/expected/pagination/topics/skol/2/index.html new file mode 100644 index 0000000..ec6b6af --- /dev/null +++ b/test/fixtures/expected/pagination/topics/skol/2/index.html @@ -0,0 +1,4 @@ +

Posts for skol

+
    +
  • 07/01/2014 test json
  • +
PreviousNext \ No newline at end of file diff --git a/test/fixtures/expected/pagination/topics/skol/3/index.html b/test/fixtures/expected/pagination/topics/skol/3/index.html new file mode 100644 index 0000000..548602b --- /dev/null +++ b/test/fixtures/expected/pagination/topics/skol/3/index.html @@ -0,0 +1,4 @@ +

Posts for skol

+
    +
  • 02/03/2014 test
  • +
PreviousNext \ No newline at end of file diff --git a/test/fixtures/expected/pagination/topics/skol/4/index.html b/test/fixtures/expected/pagination/topics/skol/4/index.html new file mode 100644 index 0000000..7aaffbc --- /dev/null +++ b/test/fixtures/expected/pagination/topics/skol/4/index.html @@ -0,0 +1,4 @@ +

Posts for skol

+
    +
  • 02/02/2014 about
  • +
Previous \ No newline at end of file diff --git a/test/fixtures/expected/pagination/topics/skol/index.html b/test/fixtures/expected/pagination/topics/skol/index.html new file mode 100644 index 0000000..ff0b227 --- /dev/null +++ b/test/fixtures/expected/pagination/topics/skol/index.html @@ -0,0 +1,4 @@ +

Posts for skol

+
    +
  • 07/02/2014 test page 2
  • +
Next \ No newline at end of file diff --git a/test/fixtures/expected/pagination/topics/this-is/index.html b/test/fixtures/expected/pagination/topics/this-is/index.html index 0ac07f6..612a27f 100644 --- a/test/fixtures/expected/pagination/topics/this-is/index.html +++ b/test/fixtures/expected/pagination/topics/this-is/index.html @@ -1,4 +1,4 @@ -

Posts for this is

+

Posts for this-is

  • 02/03/2014 test
\ No newline at end of file diff --git a/test/index.js b/test/index.js index 8a90c4e..cbc3102 100644 --- a/test/index.js +++ b/test/index.js @@ -22,7 +22,13 @@ describe('metalsmith-tags', function() { })) .build(function(err,files){ if (err) return done(err); - assert.equal(files['index.html'].tags.toString(),[{ name: 'hello', slug: 'hello'}, { name: 'world', slug: 'world'}, { name: 'this is', slug: 'this-is'}, { name: 'tag', slug: 'tag'}].toString()); + assert.equal(files['index.html'].tags.toString(),[ + { name: 'hello', slug: 'hello'}, + { name: 'world', slug: 'world'}, + { name: 'this is', slug: 'this-is'}, + { name: 'tag', slug: 'tag'}, + { name: 'skol', slug: 'skol'}, + ].toString()); done(); }); }); @@ -42,7 +48,55 @@ describe('metalsmith-tags', function() { .build(function(err, files){ if (err) return done(err); var tagListKeys = Object.keys(tagList).sort(); - assert.deepEqual(tagListKeys, ['hello', 'tag', 'this', 'this is', 'world']); + assert.deepEqual(tagListKeys, [ + 'hello', + 'skol', + 'skØl', + 'sköl', + 'skøl', + 'tag', + 'this', + 'this is', + 'world', + ]); + // Ensure every object in the metadata tags array is a data object. + tagListKeys.forEach(function(tagName) { + var tagPostsArray = tagList[tagName]; + tagPostsArray.forEach(function(fileData) { + assert.equal(typeof fileData, 'object'); + assert.ok(fileData.stats); + assert.ok(fileData.contents); + assert.ok(fileData.tags); + }); + }); + done(); + }); + }); + + it('should normalize special characters into their ascii equivalent using given slug function', function(done) { + var tagList; + + Metalsmith('test/fixtures') + .use(tags({ + handle: 'tags', + path: 'topics', + normalize: true, + })) + .use(function(files, metalsmith, done) { + tagList = metalsmith.metadata().tags; + done(); + }) + .build(function(err, files){ + if (err) return done(err); + var tagListKeys = Object.keys(tagList).sort(); + assert.deepEqual(tagListKeys, [ + 'hello', + 'skol', + 'tag', + 'this', + 'this-is', + 'world', + ]); // Ensure every object in the metadata tags array is a data object. tagListKeys.forEach(function(tagName) { var tagPostsArray = tagList[tagName]; @@ -64,7 +118,6 @@ describe('metalsmith-tags', function() { .use(tags({ handle: 'tags', path: 'topics', - normalize: true, })) .use(function(files, metalsmith, done) { tagList = metalsmith.metadata().tags; @@ -73,13 +126,23 @@ describe('metalsmith-tags', function() { .build(function(err, files){ if (err) return done(err); var tagListKeys = Object.keys(tagList).sort(); - assert.deepEqual(tagListKeys, ['hello', 'tag', 'this', 'this is', 'world']); + assert.deepEqual(tagListKeys, [ + 'hello', + 'skol', + 'skØl', + 'sköl', + 'skøl', + 'tag', + 'this', + 'this is', + 'world', + ]); // Ensure every object in the metadata tags array is a data object. tagListKeys.forEach(function(tagName) { var tagPostsArray = tagList[tagName]; assert.ok(tagList[tagName].urlSafe); assert.equal(typeof tagList[tagName].urlSafe, 'string'); - assert.equal(slug(tagName), tagList[tagName].urlSafe); + assert.equal(slug(tagName, {mode: 'rfc3986'}), tagList[tagName].urlSafe); }); done(); }); @@ -117,6 +180,7 @@ describe('metalsmith-tags', function() { handle: 'tags', path: 'topics/:tag.html', layout: './tag.hbt', + normalize: true, sortBy: 'date', reverse: true })) @@ -136,6 +200,7 @@ describe('metalsmith-tags', function() { pathPage: 'topics/:tag/:num/index.html', perPage: 1, layout: './tag.hbt', + normalize: true, sortBy: 'date', reverse: true })) @@ -158,7 +223,13 @@ describe('metalsmith-tags', function() { })) .build(function(err, files) { if (err) return done(err); - assert.equal(files['index.html'].tags.toString(),[{ name: 'hello', slug: 'HELLO'}, { name: 'world', slug: 'WORLD'}, { name: 'this is', slug: 'THIS IS'}, { name: 'tag', slug: 'TAG'}].toString()); + assert.equal(files['index.html'].tags.toString(),[ + { name: 'hello', slug: 'HELLO'}, + { name: 'world', slug: 'WORLD'}, + { name: 'this is', slug: 'THIS IS'}, + { name: 'tag', slug: 'TAG'}, + { name: 'skol', slug: 'SKOL'}, + ].toString()); done(); }); }) From d483c9efa4ff74f8508723387fff3e364f3f7ecd Mon Sep 17 00:00:00 2001 From: Sascha Zarhuber Date: Wed, 4 Oct 2017 16:42:33 +0200 Subject: [PATCH 4/4] fix(docs): Added reference to issue --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 654a46c..e68a810 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ metalsmith ### Normalized characters - Handle with care. This is to be seen rather as a fallback as it heavily depends on your 'slug' settings. If you use the standard setting provided in this readme (*rfc3986*), you should be good to go. + Handle with care. This is to be seen rather as a fallback as it heavily depends on your 'slug' settings. If you use the standard setting provided in this readme (*rfc3986*), you should be good to go. Should fix [issue #48](https://github.com/totocaster/metalsmith-tags/issues/48). ## Pagination