Skip to content
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

preview_path not does not correspond to the real path #4963

Open
tpavel-aspose opened this issue Feb 16, 2021 · 8 comments · May be fixed by #6220
Open

preview_path not does not correspond to the real path #4963

tpavel-aspose opened this issue Feb 16, 2021 · 8 comments · May be fixed by #6220

Comments

@tpavel-aspose
Copy link

Uploading image.png…
hugo version: 0.80.0
In editor path equal as conversion-api/conversion-sdk-api/xhtml-converter
title: XHTML converter
Preview link now as
netlify.app/html/conversion-api-conversion-sdk-api-xhtml-converter-_index
but must equal
netlify.app/html/conversion-api/conversion-sdk-api/xhtml-converter/

my config

collections:
  - name: html
    label: HTML
    label_singular: "Page"
    folder: content/html
    slug: "{{slug}}"
    preview_path: "html/{{slug}}"
    create: true
    media_folder: ''
    public_folder: ''
    nested:
      depth: 100
      summary: "{{title}}"
    fields:
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Keywords", name: "keywords", widget: "string", required: false}
      - {label: "Description", name: "description", widget: "string", required: false}
      - {label: "Weight", name: "weight", widget: "number", value_type: "int", default: 10, step: 10, min: 1, max: 1000, required: false }
      - {label: "Type", name: "type", widget: "hidden", default: "docs"}
      - {label: "Body", name: "body", widget: "markdown", required: false}
    meta: { path: { widget: string, label: "Path", index_file: "_index" } }
    summary: "{{weight}} - {{title}}"
    sortable_fields: ["weight",'title', "commit_author", "commit_date"]
@jwktje
Copy link

jwktje commented Feb 22, 2021

I have this same error. I tried testing with different tags but {{filename}} doesn't even seem to work at all.

@erezrokah
Copy link
Contributor

The CMS escapes template variables since they can break URL structure.
You might be able to construct the full preview path based on multiple fields, e.g {{field1}}/{{field2}} or we can consider proving an option to opt out of the CMS behavior (or even use https://www.netlifycms.org/docs/beta-features/#summary-string-template-transformations)

@lsolesen
Copy link

lsolesen commented Apr 4, 2021

It is not an option for me to rebuild the link, as I add the slashes manually, so an option to opt out og that behavior would be great.

@lrq3000
Copy link

lrq3000 commented Jul 12, 2021

This issue also happens with GatsbyJS. It's because of nested collections, {{slug}} contains the full nested subfolders path but it's escaped with dashes so it's not a path anymore.

Any way to fix this? Maybe an undocumented templating tag specifically for nested folders path?

@lrq3000
Copy link

lrq3000 commented Jul 12, 2021

/EDIT: there was a typo in my previous message, it's the {{slug}} tag that contains the full nested path.

@lrq3000
Copy link

lrq3000 commented Jul 12, 2021

To summarize the issue, for the moment there seems to be no way to set up adequately the preview_path to allow previews of collections that are nested, because there is no specific tag and the only one that is the closest to what we need is {{slug}} but it escapes path delimiters into dashes to be URL safe.

@erezrokah
Copy link
Contributor

or we can consider proving an option to opt out of the CMS behavior (or even use https://www.netlifycms.org/docs/beta-features/#summary-string-template-transformations)

If anyone would like to follow up with a PR to one of the suggestions in this comment it would be great.

@mikestopcontinues
Copy link

@erezrokah Please see my proposed solution. If it works for you, I'll add and update the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants