Skip to content

Commit

Permalink
feat: added index.html to tags and archives links
Browse files Browse the repository at this point in the history
  • Loading branch information
majkel89 committed Sep 8, 2024
1 parent 439ee6d commit 5724ae4
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 161 deletions.
2 changes: 1 addition & 1 deletion lib/models/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion lib/models/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
100 changes: 50 additions & 50 deletions test/scripts/helpers/list_categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/bar/">bar</a><span class="category-list-count">2</span>',
'<a class="category-list-link" href="/categories/baz/bar/index.html">bar</a><span class="category-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -67,13 +67,13 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -85,10 +85,10 @@ describe('list_categories', () => {
});

result.should.eql([
'<a class="category-link" href="/categories/bat/">bat<span class="category-count">1</span></a>',
'<a class="category-link" href="/categories/baz/">baz<span class="category-count">4</span></a>',
'<a class="category-link" href="/categories/baz/bar/">bar<span class="category-count">2</span></a>',
'<a class="category-link" href="/categories/foo/">foo<span class="category-count">1</span></a>'
'<a class="category-link" href="/categories/bat/index.html">bat<span class="category-count">1</span></a>',
'<a class="category-link" href="/categories/baz/index.html">baz<span class="category-count">4</span></a>',
'<a class="category-link" href="/categories/baz/bar/index.html">bar<span class="category-count">2</span></a>',
'<a class="category-link" href="/categories/foo/index.html">foo<span class="category-count">1</span></a>'
].join(', '));
});

Expand All @@ -100,18 +100,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">baz</a>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/bar/">bar</a>',
'<a class="category-list-link" href="/categories/baz/bar/index.html">bar</a>',
'</li>',
'</ul>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -125,18 +125,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="test-list">',
'<li class="test-list-item">',
'<a class="test-list-link" href="/categories/bat/">bat</a><span class="test-list-count">1</span>',
'<a class="test-list-link" href="/categories/bat/index.html">bat</a><span class="test-list-count">1</span>',
'</li>',
'<li class="test-list-item">',
'<a class="test-list-link" href="/categories/baz/">baz</a><span class="test-list-count">4</span>',
'<a class="test-list-link" href="/categories/baz/index.html">baz</a><span class="test-list-count">4</span>',
'<ul class="test-list-child">',
'<li class="test-list-item">',
'<a class="test-list-link" href="/categories/baz/bar/">bar</a><span class="test-list-count">2</span>',
'<a class="test-list-link" href="/categories/baz/bar/index.html">bar</a><span class="test-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
'<li class="test-list-item">',
'<a class="test-list-link" href="/categories/foo/">foo</a><span class="test-list-count">1</span>',
'<a class="test-list-link" href="/categories/foo/index.html">foo</a><span class="test-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -150,13 +150,13 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -170,16 +170,16 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/bar/">bar</a><span class="category-list-count">2</span>',
'<a class="category-list-link" href="/categories/baz/bar/index.html">bar</a><span class="category-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
Expand All @@ -195,18 +195,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/bar/">bar</a><span class="category-list-count">2</span>',
'<a class="category-list-link" href="/categories/baz/bar/index.html">bar</a><span class="category-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -222,18 +222,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">BAT</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">BAT</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/">BAZ</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">BAZ</a><span class="category-list-count">4</span>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/bar/">BAR</a><span class="category-list-count">2</span>',
'<a class="category-list-link" href="/categories/baz/bar/index.html">BAR</a><span class="category-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">FOO</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">FOO</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -246,10 +246,10 @@ describe('list_categories', () => {
});

result.should.eql([
'<a class="category-link" href="/categories/bat/">bat<span class="category-count">1</span></a>',
'<a class="category-link" href="/categories/baz/">baz<span class="category-count">4</span></a>',
'<a class="category-link" href="/categories/baz/bar/">bar<span class="category-count">2</span></a>',
'<a class="category-link" href="/categories/foo/">foo<span class="category-count">1</span></a>'
'<a class="category-link" href="/categories/bat/index.html">bat<span class="category-count">1</span></a>',
'<a class="category-link" href="/categories/baz/index.html">baz<span class="category-count">4</span></a>',
'<a class="category-link" href="/categories/baz/bar/index.html">bar<span class="category-count">2</span></a>',
'<a class="category-link" href="/categories/foo/index.html">foo<span class="category-count">1</span></a>'
].join(''));
});

Expand All @@ -260,10 +260,10 @@ describe('list_categories', () => {
});

result.should.eql([
'<a class="category-link" href="/categories/bat/">bat<span class="category-count">1</span></a>|',
'<a class="category-link" href="/categories/baz/">baz<span class="category-count">4</span></a>|',
'<a class="category-link" href="/categories/baz/bar/">bar<span class="category-count">2</span></a>|',
'<a class="category-link" href="/categories/foo/">foo<span class="category-count">1</span></a>'
'<a class="category-link" href="/categories/bat/index.html">bat<span class="category-count">1</span></a>|',
'<a class="category-link" href="/categories/baz/index.html">baz<span class="category-count">4</span></a>|',
'<a class="category-link" href="/categories/baz/bar/index.html">bar<span class="category-count">2</span></a>|',
'<a class="category-link" href="/categories/foo/index.html">foo<span class="category-count">1</span></a>'
].join(''));
});

Expand All @@ -275,18 +275,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item has-children">',
'<a class="category-list-link" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/baz/bar/">bar</a><span class="category-list-count">2</span>',
'<a class="category-list-link" href="/categories/baz/bar/index.html">bar</a><span class="category-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand All @@ -300,18 +300,18 @@ describe('list_categories', () => {
result.should.eql([
'<ul class="category-list">',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/bat/">bat</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/bat/index.html">bat</a><span class="category-list-count">1</span>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link current" href="/categories/baz/">baz</a><span class="category-list-count">4</span>',
'<a class="category-list-link current" href="/categories/baz/index.html">baz</a><span class="category-list-count">4</span>',
'<ul class="category-list-child">',
'<li class="category-list-item">',
'<a class="category-list-link current" href="/categories/baz/bar/">bar</a><span class="category-list-count">2</span>',
'<a class="category-list-link current" href="/categories/baz/bar/index.html">bar</a><span class="category-list-count">2</span>',
'</li>',
'</ul>',
'</li>',
'<li class="category-list-item">',
'<a class="category-list-link" href="/categories/foo/">foo</a><span class="category-list-count">1</span>',
'<a class="category-list-link" href="/categories/foo/index.html">foo</a><span class="category-list-count">1</span>',
'</li>',
'</ul>'
].join(''));
Expand Down
Loading

0 comments on commit 5724ae4

Please sign in to comment.