dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.09k stars 866 forks source link

Url prettifier #2865

Open AndreyAkinshin opened 6 years ago

AndreyAkinshin commented 6 years ago

Right now, markdown files (articles) are translated to html files which are available via direct link like https://mydomain.com/articles/article-name.html. I want to "prettify" it and get an url like https://mydomain.com/articles/article-name/. Actually, I want a copy of article-name.html in https://mydomain.com/articles/article-name/index.html. Does DocFX provide any API for that?

superyyrrzz commented 6 years ago

Not supported for now, but it will be supported in vNext.

AndreyAkinshin commented 6 years ago

@superyyrrzz great! Any ETA when it will be available?

yufeih commented 6 years ago

We don't have an exact release date yet, it is a work on progress.

yufeih commented 6 years ago

This is implemented in v3.

We use pretty url by default: http://a.com/article-name/. It can be into http://a.com/article-name.html by setting uglifyUrl: true

AndreyAkinshin commented 6 years ago

@yufeih, awesome, thanks! By the way, it will be possible to automatically generate redirects from ugly urls to pretty urls? (e.g., http://a.com/article-name.html -> http://a.com/article-name/). With such redirects, all external links to old urls will be valid after prettification.

yufeih commented 6 years ago

This is a static switch. docfx has no idea when you made the switch. It'll generate redirects for every new file.

Automatic redirect generation is best handled by other tools that know the exact files to be redirected during a change.

arakis commented 4 years ago

Today, there's still no v3 released. So, this is a small quick and dirty workarround:

$destinationRoot = "path/to/output"

[RegEx]$Search = '(index\.html)"'
$Replace = '"'

[RegEx]$Search2 = '(\.html)"'
$Replace2 = '"'

ForEach ($File in (Get-ChildItem -Path $destinationRoot -Recurse -File)) {
    (Get-Content $File.FullName) -Replace $Search,$Replace -Replace $Search2,$Replace2 | 
        Set-Content $File.FullName
}

Live sample: https://www.aximo.games (hostet on github pages)

AndreyAkinshin commented 1 year ago

@yufeih is it possible to backport this feature to v2?

yufeih commented 1 year ago

Reopen as the feature isn't available in v2.

mjegob commented 1 year ago

@yufeih any ETA when this feature will be available? Really looking forward to it! Thanks! 😊

yufeih commented 1 year ago

@mjegob A fixed is released in v2.73.2 to allow TOC expansion work on URL rewrite. Full URL prettifier however isn't supported yet.

DavidMarquezF commented 6 months ago

Any plans to add an option to build the docs with pretty urls like v3 did?