Collection. Dynamic detection for 'template' and 'filter'

Hi. We faced a problem with collections on multilang site.
Classic way and tutorial says about using /en/{slug}/, /fr/{slug}, etc. But we want to use different domain for different languages.

And proposal is ability to add custom function into “template” and “filter” keys into yml file. This can be an special syntax “fn:{filename:functionName}” and files on some folder near ‘/content/adapters’ like an ‘/content/collections’.
Function should receive current ‘req’ express object.

This will be very useful for custom filtration such as - language, dynamic routing with day or month ("/day/12-17"), etc

Hey @Systerr,

Just wanted to clarify your use case. Are you wanting to use a single Ghost install to manage multiple sites on different domains? Because that can be achieved with the Ghost Content API while using Ghost as a Headless CMS.

You could filter content by certain attributes and feed them into a static site generator that builds to different domains.

This would be my approach if I wanted more flexibility on where my Ghost content goes :blush:

Hi @DavidDarnes your solution is a nice. I was thinking about it before, but it required more time as we need to implement views on our side. But this way we plan to go in future.

For now we have a multilanguage site. We installed blog to subdirectory /blog . Nginx do all routing work fo us to blog. Blog is fully separated for now. Language detection happens on js side (we using nodejs too on production) based on domain name and subdomain name. Like aibnb do.
So we have scheme like that: -> en -> ru -> ru -> en
… same for other langs
when we came to blog link ( we want to display it on english language (english template and filter collection based on language tag).

We already implemented language detection module based on domain as a separated module (js) and we can reuse it really was in ghost site for detection is easy way.

We happy with default theme and way that it works and do not want to reimplement it on react from time consumption perspective.

That our user case.