fix: collection page title for nested paths
This commit is contained in:
parent
eae0e49642
commit
2eaecc948e
@ -150,6 +150,17 @@
|
|||||||
'index.md': {
|
'index.md': {
|
||||||
content: '---\ntitle: Posts\n---\n',
|
content: '---\ntitle: Posts\n---\n',
|
||||||
},
|
},
|
||||||
|
news: {
|
||||||
|
'hello-world-news': {
|
||||||
|
'index.md': {
|
||||||
|
content:
|
||||||
|
'---\ntitle: Hello World News\n---\nCoffee is a small tree or shrub that grows in the forest understory in its wild form, and traditionally was grown commercially under other trees that provided shade. The forest-like structure of shade coffee farms provides habitat for a great number of migratory and resident species.\n',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'index.md': {
|
||||||
|
content: '---\ntitle: News Articles\n---\n',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'index.md': {
|
'index.md': {
|
||||||
content: '---\ntitle: Pages\n---\n',
|
content: '---\ntitle: Pages\n---\n',
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
selectEntryCollectionTitle,
|
selectEntryCollectionTitle,
|
||||||
selectFolderEntryExtension,
|
selectFolderEntryExtension,
|
||||||
} from '@staticcms/core/lib/util/collection.util';
|
} from '@staticcms/core/lib/util/collection.util';
|
||||||
|
import { isNotEmpty } from '@staticcms/core/lib/util/string.util';
|
||||||
import { addFileTemplateFields } from '@staticcms/core/lib/widgets/stringTemplate';
|
import { addFileTemplateFields } from '@staticcms/core/lib/widgets/stringTemplate';
|
||||||
import Button from '../common/button/Button';
|
import Button from '../common/button/Button';
|
||||||
|
|
||||||
@ -47,15 +48,12 @@ const CollectionHeader = ({
|
|||||||
return acc;
|
return acc;
|
||||||
}, {} as Record<string, Entry>);
|
}, {} as Record<string, Entry>);
|
||||||
|
|
||||||
const path = filterTerm.split('/');
|
if (isNotEmpty(filterTerm)) {
|
||||||
if (path.length > 0) {
|
|
||||||
const extension = selectFolderEntryExtension(collection);
|
const extension = selectFolderEntryExtension(collection);
|
||||||
|
|
||||||
const finalPathPart = path[path.length - 1];
|
|
||||||
|
|
||||||
let entry =
|
let entry =
|
||||||
entriesByPath[
|
entriesByPath[
|
||||||
`${collection.folder}/${finalPathPart}/${collection.nested.path.index_file}.${extension}`
|
`${collection.folder}/${filterTerm}/${collection.nested.path.index_file}.${extension}`
|
||||||
];
|
];
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
|
@ -33,7 +33,6 @@ const CollectionRoute = ({ isSearchResults, isSingleSearchResult }: CollectionRo
|
|||||||
const href = window.location.href;
|
const href = window.location.href;
|
||||||
if (!href.includes('noredirect')) {
|
if (!href.includes('noredirect')) {
|
||||||
window.history.replaceState(null, document.title, `${href}?noredirect`);
|
window.history.replaceState(null, document.title, `${href}?noredirect`);
|
||||||
console.log('REPLACE STATE', document.title, `${href}?noredirect`);
|
|
||||||
}
|
}
|
||||||
return <Navigate to={`/collections/${collection.name}/entries/${collection.files[0].name}`} />;
|
return <Navigate to={`/collections/${collection.name}/entries/${collection.files[0].name}`} />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user