statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.64k stars 235 forks source link

Snake case file names are stripped of underscoress #917

Closed psgivens closed 3 years ago

psgivens commented 3 years ago

Snake cased file names are stripped of underscores.

input file: goal1_fig1.cshtml output file: goal1fig1.html

input file: 2020_report_nav_config.json output file: 2020reportnavconfig.json

You can imagine how this affects my links and browser side javascript using these files.

Thanks, Phillip

I'll continue to use wyam until this is fixed.

daveaglick commented 3 years ago

Try globally setting OptimizeContentFileNames and/or OptimizeDataFileNames to false:

.AddSetting("OptimizeContentFileNames", false)

(You could also change the setting in a configuration file)

See https://statiq.dev/web/configuration/settings for more info. Let me know if that still doesn't work.

psgivens commented 3 years ago

I added that fluent line after Bootstrapper and before .Factory, but I get this: Program.cs(13,18): error CS0117: 'Bootstrapper' does not contain a definition for 'AddSetting'

I found the corresponding AddSetting method in your code and was sure to add using Statiq.App. I am using <PackageReference Include="Statiq.Web" Version="1.0.0-beta.5" />

I don't know why AddSetting is unavailable.

Here is my main method

public static async Task<int> Main(string[] args) =>
    await Bootstrapper
        .AddSetting("OptimizeContentFileNames", false)
        .Factory
        .CreateDefault(args)                
        .AddWeb()
        .RunAsync();

If I try this:

public static async Task<int> Main(string[] args) =>
    await Bootstrapper
        .Factory
        .CreateDefault(args)                
        .AddSetting("OptimizeContentFileNames", false)
        .AddWeb()
        .RunAsync();

I get this

Program.cs(16,18): error CS1061: 'Bootstrapper' does not contain a definition for 'AddSetting' and no accessible extension method 'AddSetting' accepting a first argument of type 'Bootstrapper' could be found (are you missing a using directive or an assembly reference?)

The only package reference I have is to Statiq.Web. Should I have another?

psgivens commented 3 years ago

SOLVED The problem with extension methods is that it is difficult to find out what the right namespace to include. I needed using Statiq.Common.

using System.Threading.Tasks;
using Statiq.App;
using Statiq.Web;
using Statiq.Common;
public static async Task<int> Main(string[] args) =>
    await Bootstrapper
        .Factory
        .CreateDefault(args)
        .AddSetting(WebKeys.OptimizeContentFileNames, false)
        .AddSetting(WebKeys.OptimizeDataFileNames, false)                
        .AddWeb()
        .RunAsync();        
psgivens commented 3 years ago

SOLVED The problem with extension methods is that it is difficult to find out what the right namespace to include. I needed using Statiq.Common.

using System.Threading.Tasks;
using Statiq.App;
using Statiq.Web;
using Statiq.Common;
public static async Task<int> Main(string[] args) =>
    await Bootstrapper
        .Factory
        .CreateDefault(args)
        .AddSetting(WebKeys.OptimizeContentFileNames, false)
        .AddSetting(WebKeys.OptimizeDataFileNames, false)                
        .AddWeb()
        .RunAsync();        
psgivens commented 3 years ago

Thank you for all your work on this. I really liked Wyam and am sure that I will really like this when I start using it.