keystatic icon indicating copy to clipboard operation
keystatic copied to clipboard

Admin panel does not work with trailingSlash: "always" in Astro js

Open f33w opened this issue 1 year ago • 8 comments

Hi there, I've installed Astro through Keystatic CLI, then changed trailingslash configuration to "always", but admin panel still uses no trailing slash path. That shoots errors, 404s every now and then

Astro config

import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import markdoc from '@astrojs/markdoc';
import keystatic from '@keystatic/astro';

import mdx from "@astrojs/mdx";

// https://astro.build/config
export default defineConfig({
  trailingSlash: "always",
  integrations: [react(), markdoc(), keystatic(), mdx()],
  output: 'hybrid'
});

Keystatic config:

import { config, fields, collection } from '@keystatic/core';

export default config({
  storage: {
    kind: 'local',
  },
  collections: {
    posts: collection({
      label: 'Posts',
      slugField: 'title',
      path: 'src/content/posts/*',
      format: { contentField: 'content' },
      schema: {
        title: fields.slug({ name: {
           label: 'Title',
           description: 'modifies meta, SERP, OG',
           validation: {
            isRequired: true,
            length: { min: 58 } } 
          } }),
        description: fields.text({
          label: 'Description',
          multiline: true,
          validation: {
            isRequired: true,
            length: { min: 150, max: 160 } },
        }),
        pubDate: fields.date({ label: 'Pub Date', defaultValue: { kind: "today" }, validation: { isRequired: true } }),
        lastMod: fields.date({ label: 'Last mod', defaultValue: { kind: "today" }, validation: { isRequired: true }}),
        articleSection: fields.text({ label: 'Article section', description: 'modifies OG', defaultValue: 'retirement', validation: { isRequired: true }, }),
        content: fields.mdx ({ label: 'Content' }),
      },
    }),
    authors: collection({
      label: 'Authors',
      slugField: 'name',
      path: 'src/content/authors/*',
      schema: {
        name: fields.slug({ name: { label: 'Name' } }),
      }
    })
  },
});

f33w avatar Mar 31 '24 07:03 f33w

same issue nextjs @emmatown

safethecode avatar Jun 11 '24 01:06 safethecode

same issue nextjs @emmatown

and @jossmac

safethecode avatar Jun 11 '24 04:06 safethecode

I have the same issue on a NextJS site. If I click "Add" on a collection page in the Keystatic UI, I get a 404 Page not found. If I change my Next config to trailingSlash: false, then the page loads and I can add new posts. Further evidence is that if I navigate to a collection item and click "duplicate," the page loads fine regardless of the trailingSlash setting. I think this is because /keystatic/master/collection/blog/create?duplicate=... never has a trailing slash.

I'm using the GitHub reader. I haven't tested it with the local reader. The behavior I noted earlier happens on all collections, the schemas for which vary (some use fields.markdoc, some are much simpler, only fields.text).

thinlines avatar Jun 11 '24 05:06 thinlines

Same issue

reteps avatar Oct 20 '24 18:10 reteps