Skip to content

Commit

Permalink
Hide TOC if it only contains a single "top" item
Browse files Browse the repository at this point in the history
  • Loading branch information
t11r committed May 16, 2024
1 parent 4fec80e commit 43c4acf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default {
return this.$store.manifest?.items?.some((canvas) => 'annotations' in canvas);
},
hasToc() {
return this.$store.manifest?.structures?.length > 0;
return this.$store.structures.some((structure) => !structure.behavior?.includes('top'));
},
},
created() {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function Store(args) {
return sections;
}),
structures: computed(() => {
if (!store.manifest.structures) {
if (!store.manifest?.structures) {
return [];
}

Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/toc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,12 @@ describe('TOC', () => {
.should('not.contain', 'Table of Contents')
.contains('Miniatur: Jesu Gebet in Gethsemane');
});

it('hides the whole TOC if it only contains a single "top" item', () => {
const manifestUrl = `${Cypress.env('iiifApiUrl')}/manifest/bodleian-faeff7fb-f8a7-44b5-95ed-cff9a9ffd198.json`;

cy.visit(`/?manifest=${manifestUrl}`);

cy.contains('Contents').should('not.exist');
});
});

Large diffs are not rendered by default.

0 comments on commit 43c4acf

Please sign in to comment.