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

User Story: Path Rewrites #238

Closed
about-code opened this issue Apr 9, 2022 · 2 comments · Fixed by #241
Closed

User Story: Path Rewrites #238

about-code opened this issue Apr 9, 2022 · 2 comments · Fixed by #241
Labels
enhancement New feature or request

Comments

@about-code
Copy link
Owner

about-code commented Apr 9, 2022

What's your user story?
As a publisher using a static website renderer I would like to be able to rewrite paths reflecting the input directory structure in order to align them with some output directory structure produced subsequently by a static website renderer. I may also just want to replace a file extension like .md with .html.

How would you like the system behave to satisfy your needs? How would you like it not?

I would like an option pathRewrites which is either ...

Alternative 1: versatile

... a map where key refers to the intended replacement and value is an array of one or more search strings or regular expression patterns to replace with key.

{
  "linking": {
    "pathRewrites": {
       ".html": [ ".md" ],
       "../target/dir/": ["../someDir/", "../some/other/"],
       "$1/folder": [ "^(.*)/directory" ]
    }
  }
}

In particular the use of an array in the value position allows to address situations in which a static website renderer or compiler collects files from multiple directories and writes them into a single target directory.

Alternative 2: simple

... a map where key refers to the regular expression search pattern and value is the replacement string

{
  "linking": {
    "pathRewrites": {
       ".md": ".html",
       "../someDir/": "../target/dir/",
       "^(.*)/directory": "$1/folder"
    }
  }
}

Alternative 3: both

... a map where key refers to the intended replacement and value is is a search string or an array of one or more search strings or regular expression patterns to replace with key.

Do you know examples of systems that have a similar feature you need?

TypeScript's paths option.

@about-code about-code added the enhancement New feature or request label Apr 9, 2022
@about-code
Copy link
Owner Author

Related #165

This was referenced Apr 9, 2022
about-code added a commit that referenced this issue Apr 10, 2022
@about-code
Copy link
Owner Author

#241 implements alternative 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant