|
@@ -34,7 +34,18 @@ exports.swigFilters = function(app, swig) {
|
|
|
return function(req, res, next) {
|
|
return function(req, res, next) {
|
|
|
|
|
|
|
|
swig.setFilter('path2name', function(string) {
|
|
swig.setFilter('path2name', function(string) {
|
|
|
- return string.replace(/.+\/(.+)?$/, '$1');
|
|
|
|
|
|
|
+ var name = string;
|
|
|
|
|
+ if (string.match(/.+\/([^/]+\/\d{4}\/\d{2}\/\d{2})$/)) { // /.../hoge/YYYY/MM/DD 形式のページ
|
|
|
|
|
+ return string.replace(/.+\/([^/]+\/\d{4}\/\d{2}\/\d{2})$/, '$1');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (string.match(/.+\/([^/]+\/\d{4}\/\d{2})$/)) { // /.../hoge/YYYY/MM 形式のページ
|
|
|
|
|
+ return string.replace(/.+\/([^/]+\/\d{4}\/\d{2})$/, '$1');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (string.match(/.+\/([^/]+\/\d{4})$/)) { // /.../hoge/YYYY 形式のページ
|
|
|
|
|
+ return string.replace(/.+\/([^/]+\/\d{4})$/, '$1');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return string.replace(/.+\/(.+)?$/, '$1'); // ページの末尾を拾う
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
swig.setFilter('datetz', function(input, format) {
|
|
swig.setFilter('datetz', function(input, format) {
|