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

Settings for HTML files #15

Closed
gsidhu opened this issue Feb 25, 2024 · 2 comments
Closed

Settings for HTML files #15

gsidhu opened this issue Feb 25, 2024 · 2 comments

Comments

@gsidhu
Copy link

gsidhu commented Feb 25, 2024

First: Great work here! I have tried several CMS for Jekyll/Hugo and this one comes the closest to winning for me. So I really want to make it work for me as well!

I have a Hugo blog with posts and pages that I have been able to set up.

I was hoping I would also be able to add my shortcodes directory to the CMS. I tried the following –

content:
  - name: shortcodes
      label: Shortcodes
      type: collection
      path: 'layouts/shortcodes'
      filename: fields.title.html
      format: raw
      subfolders: false
      fields:
          - name: title
            label: Title
            type: string
            required: true
          - name: code
            label: Code
            type: code
            options:
              language: html
            required: true

And it shows me this screen –
image

Clicking on an entry, shows me the code block as intended –
image

I am wondering if it is possible to edit/create files that do not have a YAML frontmatter? As is the case with my shortcodes here, I would like –

  1. The filename to be accessible as a field under View. So the 'collection view' doesn't show blanks.
  2. The filename to be definable when creating a new entry (shortcode).

Is that possible? Will it be possible in a later version?

Related Issue: #13

@hunvreus
Copy link
Member

hunvreus commented Mar 1, 2024

Yes you can in the latest version. If you omit the fields property, it will show the name of the file in the collection view.:

content:
  - name: shortcodes
    label: Shortcodes
    type: collection
    path: layouts/shortcodes
    filename: shortcode-{year}-{month}-{day}-{hour}-{minute}-{second}.html
    subfolders: false

This should work now for you. You'll notice I provided a custom filename, that is because right now y ou can rename the file once it's created, but you can't customize the filename on creation. I intend to adjust this moving forward, allowing users to change the filename when editing/creating, I'm just not 100% sure about the UX yet. Maybe allow to expose the filename in a field.

Let me know if it's working for you now.

@gsidhu
Copy link
Author

gsidhu commented Mar 1, 2024

It works!

I understand the issue about customising the filename on creation/editing. Would like to report a tiny feature request about that –

Currently when I create a new file it gets named using the shortcode-{year}-{month}-{day}-{hour}-{minute}-{second}.html schema. When I rename it, I see the toast notification that the file has been renamed but the file-list-table doesn't refresh. I have to manually refresh the page to get it to show the new filename. It would be ideal if the table component were to refresh on file rename. Or just the specific tr element could be refreshed by updating the viewContents variable.

Also, sharing my complete config for any future passerby –

media:
  input: static
  output: /
content:
  - name: pages
    label: Pages
    type: collection
    path: 'content'
    subfolders: false
    view:
      fields: [ title, date ]
    fields:
      - name: title
        label: Title
        type: string
        required: true
      - name: date
        label: Date
        type: date
        required: true
        options:
          time: true
          format: DD-MM-YYYY HH:mm:ss Z
      - name: lastmod
        label: Last Modified
        type: date
        required: true
        options:
          time: true
          format: DD-MM-YYYY HH:mm:ss Z
      - name: layout
        label: Layout
        type: select
        required: true
        options: 
          values:
            - value: page
              label: Page
      - name: author
        label: Author
        type: string
      - name: hiddenFromHomePage
        label: Hidden from Home Page
        type: boolean
        default: true
      - name: description
        label: Description
        type: string
      - name: keywords
        label: Keywords
        type: string
      - name: categories
        label: Categories
        type: string
      - name: tags
        label: Tags
        type: string
      - name: body
        label: Body
        type: rich-text
  - name: posts
    label: Posts
    path: 'content/posts'
    subfolders: false
    type: collection
    view:
      fields: [ title, draft, date ]
      primary: title
    fields:
      - name: title
        label: Title
        type: string
        required: true
      - name: date
        label: Date
        type: date
        required: true
        options:
          time: true
          format: DD-MM-YYYY HH:mm:ss Z
      - name: lastmod
        label: Last Modified
        type: date
        required: true
        options:
          time: true
          format: DD-MM-YYYY HH:mm:ss Z
      - name: layout
        label: Layout
        type: select
        required: true
        options: 
          values:
            - value: single
              label: Single
            - value: newsletter
              label: Newsletter
      - name: draft
        label: Draft
        type: boolean
        default: true
        required: true
      - name: author
        label: Author
        type: string
      - name: description
        label: Description
        type: string
      - name: keywords
        label: Keywords
        type: string
      - name: categories
        label: Categories
        type: string
      - name: tags
        label: Tags
        type: string
      - name: body
        label: Body
        type: rich-text
  - name: newsletter
    label: Newsletter
    path: 'content/newsletter'
    type: collection
    view:
      fields: [ title, date ]
      primary: title
    fields:
      - name: title
        label: Title
        type: string
        required: true
      - name: date
        label: Date
        type: date
        required: true
        options:
          time: true
          format: DD-MM-YYYY HH:mm:ss Z
      - name: lastmod
        label: Last Modified
        type: date
        required: true
        options:
          time: true
          format: DD-MM-YYYY HH:mm:ss Z
      - name: draft
        label: Draft
        type: boolean
        default: true
        required: true
      - name: layout
        label: Layout
        type: select
        options: 
          values:
            - value: newsletter
              label: Newsletter
        required: true
      - name: author
        label: Author
        type: string
      - name: description
        label: Description
        type: string
      - name: keywords
        label: Keywords
        type: string
      - name: categories
        label: Categories
        type: select
        options: 
          values:
            - value: newsletter
              label: Newsletter
      - name: tags
        label: Tags
        type: string
      - name: body
        label: Body
        type: rich-text
  - name: shortcodes
    label: Shortcodes
    type: collection
    path: 'layouts/shortcodes'
    filename: shortcode-{year}-{month}-{day}-{hour}-{minute}-{second}.html
    subfolders: false

@gsidhu gsidhu closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants