Skip to content

Manual init API should not raise an error if a valid full config is provided #569

@vadimkantorov

Description

@vadimkantorov

I'm using the following HTML within Astro. I'd like to import the config object from my own JSON file. However, Sveltia then shows an error message loading the config:

Image Image

For some reason, it still tries to load config.yml, despite I commented it out (and I actually deleted this file).

How do I properly provide my own config object?

I saw this example: https://sveltia-cms-site.pages.dev/en/docs/api/initialization#typing-the-configuration-object, but it is not complete and still seems not working

<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta name="robots" content="noindex" />
		<!--<link href="/admin/config.yml" type="text/yaml" rel="cms-config-url" />-->
		<title>Content Manager</title>
        <style>
			/* Fix cursor */
			.app-shell p,
			.app-shell h1,
			.app-shell h2,
			.app-shell h3,
			.app-shell h4,
			.app-shell h5,
			.app-shell h5 {
				cursor: auto !important;
				user-select: text !important;
			}
			/* Improve scrollbar layout */
			::-webkit-scrollbar-track {
				border: none;
				background-color: transparent;
			}
			::-webkit-scrollbar {
				width: 6px;
				height: 6px;
				background-color: transparent;
			}
			::-webkit-scrollbar-thumb {
				background-color: #2c3337;
				border-radius: 2px;
			}
			::-webkit-scrollbar-thumb:hover {
				background-color: #576b77;
			}
			/* Scrollbar layout Dark theme */
			[data-theme='dark'] ::-webkit-scrollbar-thumb {
				background-color: #b6b6b6;
			}
			[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
				background-color: white;
			}
			/* Improve sidebar width */
			.secondary-sidebar {
				min-width: 340px;
			}
		</style>
    </head>
    <script>
        import { init } from '@sveltia/cms';
        import config from "../../content/sveltia.config.json" with { type: "json" };
        //init();
        init({config: config});
    </script>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions