See, that is the point I got stuck on.
Attempts of fixing stackboit.config.ts
I thought of doing it the way you describe myself. But I have not found any combination of entries in stackbit.config.ts that would let the Visual editor even fucking load. It is stuck in booting mode since June with the following minimalist .ts:
stackbit.configs.ts v1
export default {
stackbitVersion: '~0.6.0',
ssgName: 'nextjs'
}
NOT WORKING
All I need is the content to sit in plaintext files inside the same repo. I have deployed, like you suggested, a new version based on the same old template from scratch to go and steal the stackbit.config.js
but this is fruitless since the folder structures are completely different in terms of where content is stored and how it is split up (aka content model).
Then I tried
stackbit.configs.ts v2
import { defineStackbitConfig, DocumentStringLikeFieldNonLocalized, SiteMapEntry } from '@stackbit/types';
import { GitContentSource } from '@stackbit/cms-git';
import { allModels } from 'sources/local/models';
export default {
stackbitVersion: '~0.6.0',
ssgName: 'nextjs'
}
NOT WORKING
and finally I tried
stackbit.configs.ts v3
import { defineStackbitConfig, DocumentStringLikeFieldNonLocalized, SiteMapEntry } from '@stackbit/types';
import { GitContentSource } from '@stackbit/cms-git';
import { allModels } from 'sources/local/models';
const gitContentSource = new GitContentSource({
rootPath: __dirname,
contentDirs: ['content'],
models: Object.values(allModels),
assetsConfig: {
referenceType: 'static',
staticDir: 'public',
uploadDir: 'images',
publicPath: '/'
}
});
export const config = defineStackbitConfig({
stackbitVersion: '~0.6.0',
ssgName: 'nextjs',
nodeVersion: '18',
styleObjectModelName: 'ThemeStyle',
contentSources: [gitContentSource],
presetSource: {
type: 'files',
presetDirs: ['sources/local/presets']
},
siteMap: ({ documents, models }): SiteMapEntry[] => {
const pageModels = models.filter((model) => model.type === 'page').map((model) => model.name);
return documents
.filter((document) => pageModels.includes(document.modelName))
.map((document) => {
let slug = (document.fields.slug as DocumentStringLikeFieldNonLocalized)?.value;
if (!slug) return null;
/* Remove the leading slash in order to generate correct urlPath
regardless of whether the slug is '/', 'slug' or '/slug' */
slug = slug.replace(/^\/+/, '');
switch (document.modelName) {
case 'PostFeedLayout':
return {
urlPath: '/blog',
document: document
};
case 'PostLayout':
return {
urlPath: `/blog/${slug}`,
document: document
};
default:
return {
urlPath: `/${slug}`,
document: document
};
}
});
}
});
export default config;
NOT WORKING
Current “Progress”
Well, I keep getting an annoying lodash error (see below) no matter what I do to the stackbit file.
lodash Error
### Diagnosis
The build failed at the `npm run build` stage with a `Type error: '?' expected` in the file `node_modules/@types/lodash/common/object.d.ts` at line [293](https://app.netlify.com/sites/iaeste-hh-ee1a7/deploys/66a6489e57cdf10008706edd#L293).
### Solution
This error is likely due to a TypeScript error in the `@types/lodash` definition file. To resolve this issue, you can try the following steps:
* Update your dependencies to ensure you have the latest version of `@types/lodash`.
* If updating doesn't resolve the error, you may need to check your code for any issues that could be causing this TypeScript error, such as incorrect type usage or undefined checks.
Additionally, you should consider checking for any compatibility issues between the version of `@types/lodash` and other dependencies in your project.
At this point I am questioning whether there is any point to continuing to use the current repository. Even without the visual editor the repository doesn’t build any more, thus it seems to be most reasonable to rebuild from scratch using the visual editor.