Skip to content

Commit

Permalink
docs: update docset build to fetch data samples from absolute instead…
Browse files Browse the repository at this point in the history
… of relative URL
  • Loading branch information
hydrosquall committed Aug 9, 2021
1 parent 7de7f26 commit 7cd4a30
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"schema": "mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",
"renameschema": "scripts/rename-schema.sh",
"presite": "yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",
"docset": "yarn data && yarn schema && yarn build:site && yarn build:docset && yarn build:versions && scripts/create-example-pages.sh",
"docset": "yarn schema && yarn build:site && yarn build:docset && yarn build:versions && scripts/create-example-pages.sh",
"site": "yarn site:only",
"site:only": "pushd site && bundle exec jekyll serve -I -l && popd",
"prettierbase": "prettier '**/*.{md,css,yml}'",
Expand Down
18 changes: 8 additions & 10 deletions site/_config_docset.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Config for building a docset
# Initially created by Dash, but supported by several OSS tools too
# (Velocity, Zeal, etc)
# For usage: https://github.com/hydrosquall/vega-lite-docset-generator

title: Vega-Lite
description: Bare SEO for offline usage
description: N/A

# removing baseurl b/c dash docsets don't work with absolute paths
# end up needing the
# if this doesn't work out, rewrite all link refs using BS4 later...

# using https://ricostacruz.com/til/relative-paths-in-jekyll as workaround
# Alternative: Rewrite the paths to relative URLs locally
# None of these worked when simply applied to base.html, so I ended up transforming
# the base URL in my python script instead. Leaving notes in here for posterity.
# https://ricostacruz.com/til/relative-paths-in-jekyll
# https://gist.github.com/Ketrel/1f36fca6b4148f7263b3ee8fdb0923e7
# https://github.com/jekyll/jekyll/issues/6360

baseurl: 'DOCSET_BASE_TO_REPLACE' # the subpath of your site, e.g. /blog/
url: 'https://vega.github.io' # the base hostname & protocol for your site
Expand All @@ -31,7 +31,5 @@ kramdown:
disable: true

plugins:
# - jekyll-sitemap
# - jekyll-seo-tag
- jekyll-mentions
- jekyll-redirect-from
4 changes: 2 additions & 2 deletions site/_layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

{% if site.is_docset_build == true %}
<script>
// This is used for data fetching in code samples, we know exactly where this lives
const BASEURL = '{{site.baseurl}}';
// Docset doesn't serve JSON from a fileserver, so it needs to load data from github
const BASEURL = 'https://vega.github.io/vega-lite/';
</script>
{% else %} {% seo %}
<script>
Expand Down
2 changes: 1 addition & 1 deletion site/_layouts/plain.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<header>
<nav class="page-centered">
<div class="dropdown">
<a class="vl-title" href="{{ site.baseurl }}/index.html">{{ site.title }}</a>
<a class="vl-title" href="{{ site.baseurl }}/">{{ site.title }}</a>
<div class="dropdown-content">
<a href="https://vega.github.io/vega/">Vega</a>
<a href="https://altair-viz.github.io/">Altair</a>
Expand Down

0 comments on commit 7cd4a30

Please sign in to comment.