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

Add ability to have Colab badges on pages #210

Merged
merged 11 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ exclude:

exclude: [vendor]

# This specifies what badges are turned on by default for notebook docs.
default_badges:
colab: true

highlighter: rouge
markdown: kramdown
kramdown:
Expand Down
5 changes: 5 additions & 0 deletions docs/_includes/notebook_colab_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="px-2">
<a href="https://colab.research.google.com/github/{{site.repository}}/blob/{{page.branch | default: "master"}}/{{page.nb_path}}" target="_blank">
<img class="notebook-badge-image" src="{{ "images/colab.svg" | relative_url }}" alt="Open In Colab"/>
</a>
</div>
3 changes: 3 additions & 0 deletions docs/_layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<div class="post-header">
<a id="{{page.title}}"></a>
<h1 class="post-title-main">{{ page.title }}</h1>
{% if page.nb_path and site.github_username and site.github_repo %}
{% unless site.default_badges.colab != true %}{% include notebook_colab_link.html %}{% endunless %}
{% endif -%}
</div>

{% if page.simple_map == true %}
Expand Down
4 changes: 4 additions & 0 deletions docs/css/customstyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1333,3 +1333,7 @@ div.input + details {
.output_wrapper{
overflow: scroll;
}

.notebook-badge-image {
border:0 !important;
}
1 change: 1 addition & 0 deletions docs/images/colab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions nbdev/templates/jekyll.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ sidebar: home_sidebar
{% if resources.tags != "" and resources.tags != nil %}tags: {{resources.tags}}{% endif %}
{% if resources.summary != "" and resources.summary != nil %}summary: "{{resources.summary}}"{% endif %}
{% if resources.summary != "" and resources.summary != nil %}description: "{{resources.summary}}"{% endif %}
hamelsmu marked this conversation as resolved.
Show resolved Hide resolved
{% if resources.nb_path != "" and resources.nb_path != nil %}nb_path: "{{resources.nb_path}}"{% endif %}
---
{% include 'autogen.tpl' %}

Expand Down