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

Fix staging typsense links #3825

Closed
wants to merge 1 commit into from
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
191 changes: 0 additions & 191 deletions assets/js/howtos.js

This file was deleted.

11 changes: 7 additions & 4 deletions assets/js/models.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import params from "@params";

const { TypesenseInstantSearchAdapter, instantsearch } = window;

let api = "";
if (document.getElementsByClassName("mr-component").length){
api = document.getElementsByClassName("mr-component")[0].id;
console.log(api);
}
let baseURL = params.baseURL.substr(-1) === '/' ? params.baseURL.slice(0, -1) : params.baseURL;

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
Expand Down Expand Up @@ -43,7 +46,7 @@ if (api == "") {
};
itemtemplate = `
<div class="type"><p><code>{{#helpers.highlight}}{ "attribute": "api" }{{/helpers.highlight}}</code></p></div>
<div class="name"><p><a href="{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model" }{{/helpers.highlight}}</code></a></p></div>
<div class="name"><p><a href="${baseURL}{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model" }{{/helpers.highlight}}</code></a></p></div>
<div class="description">{{#helpers.highlight}}{ "attribute": "description" }{{/helpers.highlight}}</div>
`;
} else {
Expand All @@ -52,7 +55,7 @@ if (api == "") {
hitsPerPage: 5,
};
itemtemplate = `
<div class="name"><p><a href="{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model" }{{/helpers.highlight}}</code></a></p></div>
<div class="name"><p><a href="${baseURL}{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model" }{{/helpers.highlight}}</code></a></p></div>
<div class="description">{{#helpers.highlight}}{ "attribute": "description" }{{/helpers.highlight}}</div>
`;
}
Expand Down Expand Up @@ -140,7 +143,7 @@ if (mlmodel) {
hitsPerPage: 5,
};
itemtemplateML = `
<div class="name"><p><a href="{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model_id" }{{/helpers.highlight}}</code></a></p></div>
<div class="name"><p><a href="${baseURL}{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model_id" }{{/helpers.highlight}}</code></a></p></div>
<div class="type">{{#helpers.highlight}}{ "attribute": "type" }{{/helpers.highlight}}</div>
<div class="framework">{{#helpers.highlight}}{ "attribute": "framework" }{{/helpers.highlight}}</div>
<div class="description">{{#helpers.highlight}}{ "attribute": "description" }{{/helpers.highlight}}</div>
Expand Down Expand Up @@ -228,7 +231,7 @@ if (scripts) {
hitsPerPage: 5,
};
itemtemplateScripts = `
<div class="name"><p><a href="{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model_id" }{{/helpers.highlight}}</code></a></p></div>
<div class="name"><p><a href="${baseURL}{{url}}"><code>{{#helpers.highlight}}{ "attribute": "model_id" }{{/helpers.highlight}}</code></a></p></div>
<div class="description">{{#helpers.highlight}}{ "attribute": "description" }{{/helpers.highlight}}</div>
`;

Expand Down
12 changes: 8 additions & 4 deletions assets/js/tutorials.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import params from "@params";

const { TypesenseInstantSearchAdapter, instantsearch } = window;
const observer = lozad();

Expand Down Expand Up @@ -91,19 +93,21 @@ const customRefinementList = instantsearch.connectors.connectRefinementList(
},
);

let baseURL = params.baseURL.substr(-1) === '/' ? params.baseURL.slice(0, -1) : params.baseURL;

search.addWidgets([
instantsearch.widgets.hits({
container: "#hits",
templates: {
item: `
<div class="col tutorial hover-card {{resource}}">
<a href="{{relpermalink}}" target="_blank">
<a href="${baseURL}{{relpermalink}}" target="_blank">
{{#webm}}
<div class="hover-card-video">
<div>
<video autoplay loop muted playsinline alt="{{videoAlt}}" width="100%" style="width: {{ .maxWidth }}" class="{{- if .class -}}{{ .class}}{{- end }} lozad">
<source data-src="{{webm}}" type="video/webm">
<source data-src="{{mp4}}" type="video/mp4">
<source data-src="${baseURL}{{webm}}" type="video/webm">
<source data-src="${baseURL}{{mp4}}" type="video/mp4">
There should have been a video here but your browser does not seem to support it.
</video>
</div>
Expand All @@ -112,7 +116,7 @@ search.addWidgets([
{{#image}}
<div class="hover-card-img">
<picture>
<img src="{{image}}" alt="{{imageAlt}}" loading="lazy">
<img src="${baseURL}{{image}}" alt="{{imageAlt}}" loading="lazy">
</picture>
</div>
{{/image}}
Expand Down
8 changes: 0 additions & 8 deletions layouts/docs/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,5 @@

{{ partial "scripts.html" . }}

<script src="https://cdn.jsdelivr.net/npm/typesense-instantsearch-adapter@2/dist/typesense-instantsearch-adapter.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

{{ $jsTutorials := resources.Get "js/tutorials.js" }}
{{ $jsTutorials := $jsTutorials | minify }}
<script type="text/javascript" src="{{ $jsTutorials.RelPermalink }}" crossorigin="anonymous"></script>

</body>
</html>
14 changes: 13 additions & 1 deletion layouts/docs/tutorials.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,20 @@ <h4 class="alert-heading">Javascript</h4>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

{{ $jsTutorials := resources.Get "js/tutorials.js" }}
{{ if (eq (substr .Site.BaseURL -1) "/" ) }}
{{- $opts := dict
"params" (dict "baseURL" (substr .Site.BaseURL 0 -1 ))
-}}
{{- $jsTutorials = $jsTutorials | js.Build $opts -}}
{{ $jsTutorials := $jsTutorials | minify }}
<script type="text/javascript" src="{{ $jsTutorials.RelPermalink }}" crossorigin="anonymous"></script>

{{ else }}
{{- $opts := dict
"params" (dict "baseURL" .Site.BaseURL)
-}}
{{- $jsTutorials = $jsTutorials | js.Build $opts -}}
{{ $jsTutorials := $jsTutorials | minify }}
<script type="text/javascript" src="{{ $jsTutorials.RelPermalink }}" crossorigin="anonymous"></script>
{{ end }}
</body>
</html>
2 changes: 1 addition & 1 deletion layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="td-navbar-nav-scroll ml-md-auto td-topbar-sections" id="main_navbar">
<ul>
<li><a href="https://app.viam.com/fleet/" title="Fleet" class="navsectiontop">Fleet</a></li>
<li><a href="https://app.viam.com/data/view" title="Data" class="navsectiontop">Data</a></li>
<li><a href="https://app.viam.com/data/view/" title="Data" class="navsectiontop">Data</a></li>
<li><a href="https://app.viam.com/registry/" title="Registry" class="navsectiontop">Registry</a></li>
<li><a href="{{ .Site.BaseURL }}" title="Docs" class="navsectiontop active-path">Docs</a></li>
</ul>
Expand Down
58 changes: 29 additions & 29 deletions layouts/partials/page-description.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{{ $recentlyChanged := (lt (sub now.Unix .Lastmod.Unix) 3600) }}
{{- $recentlyChanged := (lt (sub now.Unix .Lastmod.Unix) 3600) -}}

{{if .Params.metaDescription }}
{{if gt (len .Params.metaDescription) 158}}
{{- if .Params.metaDescription -}}
{{if gt (len .Params.metaDescription) 158 -}}
{{- warnf "Page description too long (%d) - should be 50-158 characters: %q." (len .Params.metaDescription) .Path -}}
{{ end }}
{{if lt (len .Params.metaDescription) 50}}
{{- end -}}
{{- if lt (len .Params.metaDescription) 50 -}}
{{- warnf "Page description too short (%d) - should be 50-158 characters: %q." (len .Params.metaDescription) .Path -}}
{{ end }}
{{ with .Params.metaDescription | plainify -}}
{{ . -}}
{{ end }}
{{else if .Description }}
{{ if $recentlyChanged}}
{{if gt (len .Description) 158}}
{{- end -}}
{{- with .Params.metaDescription | plainify -}}
{{- . -}}
{{- end -}}
{{- else if .Description -}}
{{- if $recentlyChanged -}}
{{- if gt (len .Description) 158 -}}
{{- warnf "Page description too long (%d) - change it or add a metaDescription with 50-158 characters: %q." (len .Description) .Path -}}
{{ end }}
{{if lt (len .Description) 50}}
{{- end -}}
{{if lt (len .Description) 50 -}}
{{- warnf "Page description too short (%d) - change it or add a metaDescription with 50-158 characters: %q.\n This may be a good start:\n%q" (len .Description) .Path (.Summary | plainify) -}}
{{ end }}
{{ end }}
{{ with .Description | plainify -}}
{{ . -}}
{{ end }}
{{ else -}}
{{ if .IsPage -}}
{{ if not .Params.empty_node }}
{{- end -}}
{{- end -}}
{{- with .Description | plainify -}}
{{- . -}}
{{- end -}}
{{- else -}}
{{- if .IsPage -}}
{{- if not .Params.empty_node -}}
{{- errorf "No description for page %q" .Path -}}
{{ end -}}
{{ else -}}
{{ with .Site.Params.description | plainify -}}
{{ . -}}
{{ end -}}
{{ end -}}
{{ end -}}
{{- end -}}
{{- else -}}
{{- with .Site.Params.description | plainify -}}
{{- . -}}
{{- end -}}
{{- end -}}
{{- end -}}
Loading
Loading