Skip to content

feat: expose slug in getCollection result #7436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,18 @@ export class PreviewPane extends React.Component {
* This function exists entirely to expose collections from outside of this entry
*
*/
getCollection = async (collectionName, slug) => {
getCollection = async (collectionName, slugToLoad) => {
const { state } = this.props;
const selectedCollection = state.collections.get(collectionName);

if (typeof slug === 'undefined') {
if (typeof slugToLoad === 'undefined') {
const entries = await getAllEntries(state, selectedCollection);
return entries.map(entry => Map().set('data', entry.data));

return entries.map(({ data, slug, path }) => Map({ data, slug, path }));
}

const entry = await tryLoadEntry(state, selectedCollection, slug);
return Map().set('data', entry.data);
const { data, slug, path } = await tryLoadEntry(state, selectedCollection, slugToLoad);
return Map({ data, slug, path });
};

render() {
Expand Down