From 857f62cf9ceccdfd475508285a27a95f7963714d Mon Sep 17 00:00:00 2001 From: Michal Kowalik Date: Sun, 8 Sep 2024 16:24:07 +0200 Subject: [PATCH] feat: added index.html to tags and archives links --- lib/models/category.ts | 2 +- lib/models/tag.ts | 2 +- lib/plugins/helper/list_archives.ts | 2 +- test/scripts/helpers/list_archives.ts | 82 +++++++------- test/scripts/helpers/list_categories.ts | 100 ++++++++--------- test/scripts/helpers/list_tags.ts | 70 ++++++------ test/scripts/helpers/tagcloud.ts | 140 ++++++++++++------------ test/scripts/models/category.ts | 4 +- test/scripts/models/tag.ts | 4 +- 9 files changed, 203 insertions(+), 203 deletions(-) diff --git a/lib/models/category.ts b/lib/models/category.ts index 2fdbfb58df..b94359b3d4 100644 --- a/lib/models/category.ts +++ b/lib/models/category.ts @@ -33,7 +33,7 @@ export = (ctx: Hexo) => { if (catDir === '/') catDir = ''; if (!catDir.endsWith('/')) catDir += '/'; - return `${catDir + this.slug}/`; + return `${catDir + this.slug}/index.html`; }); Category.virtual('permalink').get(function() { diff --git a/lib/models/tag.ts b/lib/models/tag.ts index 84a118aa25..901cb9f699 100644 --- a/lib/models/tag.ts +++ b/lib/models/tag.ts @@ -24,7 +24,7 @@ export = (ctx: Hexo) => { let tagDir = ctx.config.tag_dir; if (!tagDir.endsWith('/')) tagDir += '/'; - return `${tagDir + this.slug}/`; + return `${tagDir + this.slug}/index.html`; }); Tag.virtual('permalink').get(function() { diff --git a/lib/plugins/helper/list_archives.ts b/lib/plugins/helper/list_archives.ts index c4ee26a93a..ca656665f8 100644 --- a/lib/plugins/helper/list_archives.ts +++ b/lib/plugins/helper/list_archives.ts @@ -79,7 +79,7 @@ function listArchivesHelper(this: LocalsType, options: Options = {}) { url += `${item.month}/`; } - return url_for.call(this, url); + return url_for.call(this, url + 'index.html'); }; if (style === 'list') { diff --git a/test/scripts/helpers/list_archives.ts b/test/scripts/helpers/list_archives.ts index 43ea874267..57daa64986 100644 --- a/test/scripts/helpers/list_archives.ts +++ b/test/scripts/helpers/list_archives.ts @@ -35,9 +35,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -49,8 +49,8 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -62,9 +62,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -75,9 +75,9 @@ describe('list_archives', () => { }); result.should.eql([ - 'February 20141', - 'October 20131', - 'June 20132' + 'February 20141', + 'October 20131', + 'June 20132' ].join(', ')); }); @@ -88,9 +88,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -102,9 +102,9 @@ describe('list_archives', () => { }); result.should.eql([ - 'February 2014', - 'October 2013', - 'June 2013' + 'February 2014', + 'October 2013', + 'June 2013' ].join(', ')); }); @@ -115,9 +115,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -131,9 +131,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -147,9 +147,9 @@ describe('list_archives', () => { }); result.should.eql([ - 'FEBRUARY 20141', - 'OCTOBER 20131', - 'JUNE 20132' + 'FEBRUARY 20141', + 'OCTOBER 20131', + 'JUNE 20132' ].join(', ')); }); @@ -160,9 +160,9 @@ describe('list_archives', () => { }); result.should.eql([ - 'February 20141', - 'October 20131', - 'June 20132' + 'February 20141', + 'October 20131', + 'June 20132' ].join('')); }); @@ -173,9 +173,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -187,9 +187,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -201,9 +201,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); }); @@ -216,9 +216,9 @@ describe('list_archives', () => { result.should.eql([ '' ].join('')); diff --git a/test/scripts/helpers/list_categories.ts b/test/scripts/helpers/list_categories.ts index eccb59df7c..9846ed2612 100644 --- a/test/scripts/helpers/list_categories.ts +++ b/test/scripts/helpers/list_categories.ts @@ -42,18 +42,18 @@ describe('list_categories', () => { result.should.eql([ '' ].join('')); @@ -67,13 +67,13 @@ describe('list_categories', () => { result.should.eql([ '' ].join('')); @@ -85,10 +85,10 @@ describe('list_categories', () => { }); result.should.eql([ - 'bat1', - 'baz4', - 'bar2', - 'foo1' + 'bat1', + 'baz4', + 'bar2', + 'foo1' ].join(', ')); }); @@ -100,18 +100,18 @@ describe('list_categories', () => { result.should.eql([ '' ].join('')); @@ -125,18 +125,18 @@ describe('list_categories', () => { result.should.eql([ '' ].join('')); @@ -150,13 +150,13 @@ describe('list_categories', () => { result.should.eql([ '' ].join('')); @@ -170,16 +170,16 @@ describe('list_categories', () => { result.should.eql([ '