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

WIP: Add support for memberspace #712

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions layouts/partials/fragments/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@
</a>
</li>
{{- end -}}
{{- end -}}
{{- with ($page_scratch.Get "memberspace") }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a vendor specific fragment into another fragments code seems problematic.
We should inject it from a memberspace fragment or at least make this injection more generic.
As it currently stands this seems too bundled.

<li class="nav-item">
<a href="https://{{- .Params.subdomain -}}.memberspace.com/member/sign_in" class="nav-link anchor">
Login / Signup
</a>
</li>
{{- end }}
</ul>
{{- if .Params.search }}
Expand Down
12 changes: 12 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,16 @@
{{- partial "helpers/config.html" (dict "root" $ "head" true "type" .type "data" .) -}}
{{- end -}}
{{- end -}}

{{- with (.Scratch.Get "memberspace") -}}
<script>
var MemberSpace = window.MemberSpace || {subdomain: "{{- print .Params.subdomain -}}"};
(function(d){
var s = d.createElement("script");
s.src = "https://cdn.memberspace.com/scripts/widgets.js";
var e = d.getElementsByTagName("script")[0];
e.parentNode.insertBefore(s,e);
}(document));
</script>
{{- end -}}
</head>
3 changes: 3 additions & 0 deletions layouts/partials/helpers/fragments.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
looking from the page directory or file to it's parents and so on. */}}
{{- $page_scratch.Set "page_fragments" (slice) -}}
{{- $page_scratch.Set "page_config" (slice) -}}
{{- $page_scratch.Set "memberspace" nil -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a global variable for a vendor specific fragment seems problematic.

{{- $page_scratch.Set "experimentals_used_messages" (slice) -}}
{{- $page_scratch.Set "fragments_directory_name" (slice) -}}
{{- if $page_scratch.Get "fragments" -}}
Expand All @@ -183,6 +184,8 @@
{{- if or $is_404 (ne .Params.fragment "404") -}}
{{- if eq .Params.fragment "config" -}}
{{- $page_scratch.Add "page_config" . -}}
{{- else if eq .Params.fragment "memberspace" -}}
{{- $page_scratch.Set "memberspace" . -}}
{{- else -}}
{{- $page_scratch.Add "page_fragments" . -}}
{{- $page_scratch.Add "fragments_directory_name" (printf "%s%s/" $root.File.Dir (replace $name ".md" "")) -}}
Expand Down