delucis / astro-netlify-cms

Integration to add Netlify CMS’s admin dashboard to any Astro project
161 stars 21 forks source link

admin page is blank, 404 error trying to get admin-dashboard.astro #50

Closed Skrubbadubba closed 1 year ago

Skrubbadubba commented 1 year ago

So far I installed the package, pasted the necessary code into astro.config.mjs. This is what I get when visiting /admin

image

config:

import { defineConfig } from 'astro/config';
import svelte from "@astrojs/svelte";
import NetlifyCMS from 'astro-netlify-cms';
import mdx from "@astrojs/mdx";

// https://astro.build/config
export default defineConfig({
  site: 'https://kodvet.gitlab-pages.liu.se/',
  base: '/sektionshemsidan',
  // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
  // base: 'kvit/',
  sitemap: true,
  // Generate sitemap (set to "false" to disable)
  // GitLab Pages requires exposed files to be located in a folder called "public".
  // So we're instructing Astro to put the static build output in a folder of that name.
  outDir: 'public',
  // The folder name Astro uses for static files (`public`) is already reserved
  // for the build output. So in deviation from the defaults we're using a folder
  // called `static` instead.
  publicDir: 'static',
  integrations: [NetlifyCMS({
      config: {
        backend: {
          name: 'git-gateway',
          branch: 'main',
        },
        media_folder: 'public/assets/blog',
        public_folder: '/assets/blog',
        collections: [
          // Content collections
          {
      name: 'posts',
      label: 'Blog Posts',
      folder: 'src/pages/posts',
      create: true,
      delete: true,
      fields: [
        { name: 'title', widget: 'string', label: 'Post Title' },
        { name: 'body', widget: 'markdown', label: 'Post Body' },
      ],
    }
        ],
      },
    }), svelte(), mdx()]
});
delucis commented 1 year ago

Thanks for opening an issue. Do you see any errors logged in your terminal when trying to load the admin dashboard? I assume this is in dev mode too?

This looks like a set up I haven't tested yet. One thing that's worked for some people is changing the order of integrations, e.g. moving svelte & MDX before the Netlify CMS integration.

Would you be able to share your repo? If so, I'll take a look.

Skrubbadubba commented 1 year ago

Yes its in dev. The console throws a 404 error (GET) trying to access admin-dashboard.astro (I think the full url was "[full-path-to-local-project]/node_modules/astro-netlify-cms/admin-dashboard.astro). Can't remember what line was trying to call it, I think it was a script tag at the top of the document body, maybe thats not really important.

https://gitlab.liu.se/Kodvet/sektionshemsidan/-/tree/main repo should be public now. As of now, I've set up netlify-CMS the manual way, and got that working so I'm probably not gonna use this. But just clone and hop back a couple of commits, or do npm uninstall netlify-cms-app and remove static/admin. Then you can install this integration and look around from there.

Another thing. When I first tried this, I had weird problems which I eventually found to be happening when I installed the integration. On simply installing, it would throw a syntax error on a svelte component that worked before. I also had alot of other nonsensical problems with other things, I think I somehow really fucked up my working tree, so maybe it doesnt matter. Did a clean clone of our project and those errors was gone, but then ended up here.

Skrubbadubba commented 1 year ago

Also, earlier I tried cloning your demo https://github.com/delucis/astro-netlify-cms-starter. Tried adding the svelte integration, and a dummy svelte component to the project. Worked fine. So maybe I just did something dumb on my project idk 🤷‍♂️

delucis commented 1 year ago

Thanks for the extra details. I can’t quite figure out which commit to look at in your repo — found some using astro-netlify-cms but there seemed to also be an admin/index.astro in your repo that might have been conflicting? I’ll close for now if this is resolved for you, but happy to re-open if you have more details or someone else reports this.