Skip to content
This repository has been archived by the owner on Jul 21, 2019. It is now read-only.

Remove filesystem deps #471

Closed
mattstratton opened this issue Apr 3, 2017 · 2 comments
Closed

Remove filesystem deps #471

mattstratton opened this issue Apr 3, 2017 · 2 comments
Assignees
Milestone

Comments

@mattstratton
Copy link
Member

With the use of the relURL function, we can determine the URL path of an element and we should be able to use that to decide which event, year, etc it is instead of this same copy-pasted code we keep using:

{{ $path := split $.Source.File.Path .Site.Params.PathSeparator }}
{{ $event_slug := index $path 1 }}
{{ $e :=  (index $.Site.Data.events $event_slug) }}
{{/* end site data query */}}

I already do this a little bit; for example, in partials/head/seo/schema.html there is this code:

  {{ $path := split ( .Permalink | relURL) "/" }}
  {{ $event_slug := index $path 2 }}

This might sound pedantic, but it has a far-reaching effect; it removes the need for a Windows-specific config file, because we are not splitting on filesystem paths anymore.

TBH, I'm not 100% sold that the PathSeparator value is really truly needed anyway; we have places in the code where it doesn't need it. Although that night be that Go is using some OS callbacks for us in the function. For example:

{{ $.Scratch.Set "contentdir" (printf "static/events/%s/" $event_slug) }}
  {{if (where (readDir "static/events") "Name" $event_slug)}}

You would think that would NOT work on Windows, because the paths it is checking for with readDir are not Windows-friendly, but I am guessing readDir knows how to handle this.

@mattstratton mattstratton added this to the 1.8 milestone Apr 3, 2017
@mattstratton
Copy link
Member Author

The thing I wonder about is that it bases itself on Permalink, which I think behaves oddly when we have baseURL set to "/", so we'll need to fix this with the other stuff related to baseUrl in the builds.

@mattstratton mattstratton modified the milestones: 1.8, Next Tasks May 9, 2017
@mattstratton mattstratton modified the milestones: Next Tasks, 1.10 May 11, 2017
@mattstratton
Copy link
Member Author

Depends on #455

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

No branches or pull requests

1 participant