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

Enhancement: define filename prefixes on folder level #458

Closed
estruyf opened this issue Nov 8, 2022 Discussed in #452 · 10 comments
Closed

Enhancement: define filename prefixes on folder level #458

estruyf opened this issue Nov 8, 2022 Discussed in #452 · 10 comments

Comments

@estruyf
Copy link
Owner

estruyf commented Nov 8, 2022

Discussed in #452

Originally posted by rshmhrj November 6, 2022
Hi all!
First -- thanks for all the work on this awesome extension. I have found it extremely useful in setting up and maintaining the site. The more I use it, and the more familiar I am getting with the settings, the better it gets!

Context:

I have two sections in my Hugo site: posts and references. From the front matter dashboard, clicking create content pops up a question asking which folder to add the content to, what to title it, and then it auto creates the file based on a template.

It also slugifies the title and prepends the date for the filename.

For posts, I like the auto dating behavior. For references, I want to disable it.

Question

Is there a config setting to selectively enable/disable the auto-dating based on which folder is selected?

Obviously, the "workaround" is to create it and then manually delete the date portion of the filename (which takes 2 seconds), but just wondering if such a feature / configuration exists. I searched through the existing issues and discussions , but didn't find anything specifically related to the folder choice.

Thanks again!

@estruyf
Copy link
Owner Author

estruyf commented Nov 9, 2022

This is now available in the beta for you to try out by setting the filePrefix on the folder setting.

"frontMatter.content.pageFolders": [
  {
    "title": "blog",
    "path": "[[workspace]]/blog",
    "filePrefix": "yyyy-MM-dd"
  },
  {
    "title": "docs",
    "path": "[[workspace]]/docs",
    "filePrefix": ""
  }
]

@rshmhrj
Copy link

rshmhrj commented Nov 11, 2022

Thanks for working on this @estruyf -- really appreciate the quick turnaround! Tested it out and it seems to work perfectly.

Testing steps:

  • Used vscodium not vs-code

  • Uninstalled FM and installed beta version.

    • Note: name in marketplace is Front Matter CMS (BETA) v8.2.3428349. I expected it to be VS Code Marketplace - Front Matter BETA per the Readme
      image
  • Starting pageFolders structure:

    "frontMatter.content.pageFolders": [
      {
        "title": "posts",
        "path": "[[workspace]]/content/posts"
      },
      {
        "title": "refs",
        "path": "[[workspace]]/content/refs"
      }
    ],
  • Result

    • Created test1 in both posts and refs
    • Both files were autonamed to 2022-11-10-test1.md
  • Updated pageFolders structure:

    "frontMatter.content.pageFolders": [
     {
       "title": "posts",
       "path": "[[workspace]]/content/posts",
       "filePrefix": "yyyy-MM-dd"
     },
     {
       "title": "refs",
       "path": "[[workspace]]/content/refs",
       "filePrefix": ""
     }
    ],
  • Result

    • Created test2 in both posts and refs
    • File in posts was named 2022-11-10-test2.md
    • File in refs was named test2.md

/lgtm

@rshmhrj
Copy link

rshmhrj commented Nov 11, 2022

@estruyf the only minor issue I'm seeing with it is the squiggly line, and the message about filePrefix not being allowed here:
image

@estruyf
Copy link
Owner Author

estruyf commented Nov 12, 2022

@rshmhrj no worries, this is because both beta and main schema have not been updated. That is the reason why you experience this. More important is that the functionality is working as expected.

@rshmhrj
Copy link

rshmhrj commented Nov 13, 2022

Hi @estruyf,
Played around with it some more and found that if I set
frontMatter.taxonomy.contentTypes[0].pageBundle = true
simultaneously with
frontMatter.content.pageFolders[0].filePrefix = yyyy-MM-dd
the result is a pageBundle without the date prefix

flipping frontMatter.taxonomy.contentTypes[0].pageBundle = false
results in the standalone .md file with the date prefix.

estruyf added a commit that referenced this issue Nov 14, 2022
@estruyf
Copy link
Owner Author

estruyf commented Nov 14, 2022

Thanks @rshmhrj, this functionality was indeed not yet implemented. It should have been fixed.

@rshmhrj
Copy link

rshmhrj commented Nov 14, 2022

Yes! Tested it and it works with the bundle and with/without dates as expected!

Thanks so much @estruyf !! 😄

@estruyf
Copy link
Owner Author

estruyf commented Nov 14, 2022

Thank you @rshmhrj for testing it out and providing the feedback!

@dennisl68-castra
Copy link

Shouldn't such a setting be ContentType specific rather than folder specific?

@estruyf
Copy link
Owner Author

estruyf commented Dec 2, 2022

@dennisl68-castra we should also support having it on a content-type level, so that it is up to the user to decide. Like with the preview URL option, these can be defined globally, folder, and content-type level.

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

No branches or pull requests

3 participants