1
0
mirror of https://github.com/thangisme/notes.git synced 2024-10-31 18:27:30 -04:00

Merge pull request #3 from pmarsceill/v0.1.2

Fix paths in docs
This commit is contained in:
Patrick Marsceill 2018-10-23 13:21:57 -04:00 committed by GitHub
commit c1cacf277c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 12 deletions

View File

@ -15,7 +15,7 @@
# in the templates via {{ site.myvariable }}.
title: Just the Docs
description: A Jekyll theme for documentation
# baseurl: "" # the subpath of your site, e.g. /blog
baseurl: "/just-the-docs" # the subpath of your site, e.g. /blog
# url: "" # the base hostname & protocol for your site, e.g. http://example.com
sass:

View File

@ -5,7 +5,7 @@
<div class="page-wrap">
<div class="side-bar">
<a href="{{ site.url }}" class="site-title fs-6 text-grey-dk-300 lh-tight">{{ site.title }}</a>
<a href="{{ site.baseurl }}/" class="site-title fs-6 text-grey-dk-300 lh-tight">{{ site.title }}</a>
<span class="fs-3"><button class="js-main-nav-trigger navigation-list-toggle btn btn-outline" type="button" data-text-toggle="Hide">Menu</button></span>
<div class="navigation main-nav js-main-nav">
{% include nav.html %}
@ -38,7 +38,7 @@
{% if page.parent != nil and page.parent != page.title %}
<nav class="breadcrumb-nav">
<ol class="breadcrumb-nav-list">
<li class="breadcrumb-nav-list-item"><a href="{{ site.url }}/{{ page.parent | slugify }}">{{ page.parent }}</a></li>
<li class="breadcrumb-nav-list-item"><a href="{{ site.url | absolute_url }}/{{ page.parent | slugify }}">{{ page.parent }}</a></li>
<li class="breadcrumb-nav-list-item"><span>{{ page.title }}</span></li>
</ol>
</nav>

View File

@ -35,14 +35,29 @@ function initSearch() {
var index = lunr(function () {
this.ref('id');
this.field('title', { boost: 20 });
this.field('content');
this.field('content', { boost: 10 });
this.field('url');
});
// Get the generated search_data.json file so lunr.js can search it locally.
sc = document.getElementsByTagName("script");
source = '';
for(idx = 0; idx < sc.length; idx++)
{
s = sc.item(idx);
if(s.src && s.src.match(/just-the-docs\.js$/))
{ source = s.src; }
}
jsPath = source.replace('just-the-docs.js', '');
jsonPath = jsPath + '/search-data.json';
var request = new XMLHttpRequest();
request.open('GET', '/search-data.json', true);
request.open('GET', jsonPath, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
@ -103,11 +118,12 @@ function initSearch() {
var resultsLink = document.createElement('a');
var resultsUrlDesc = document.createElement('span');
var resultsUrl = store[results[i].ref].url;
var resultsRelUrl = store[results[i].ref].relUrl;
var resultsTitle = store[results[i].ref].title;
resultsLink.setAttribute('href', store[results[i].ref].url);
resultsLink.setAttribute('href', resultsUrl);
resultsLink.innerText = resultsTitle;
resultsUrlDesc.innerText = resultsUrl;
resultsUrlDesc.innerText = resultsRelUrl;
resultsList.classList.add('search-results-list');
resultsListItem.classList.add('search-results-list-item');

View File

@ -4,8 +4,9 @@
{% for page in site.html_pages %}"{{ forloop.index0 }}": {
"id": "{{ forloop.index0 }}",
"title": "{{ page.title | xml_escape }}",
"content": "{{ page.content | markdownify | strip_html | xml_escape | remove: 'Table of contents' | remove: page.title | strip_newlines | replace: '\', ' '}}",
"url": "{{ page.url | xml_escape }}"
"content": "{{ page.content | markdownify | strip_html | xml_escape | remove: 'Table of contents' | strip_newlines | replace: '\', ' ' }}",
"url": "{{ page.url | absolute_url | xml_escape }}",
"relUrl": "{{ page.url | xml_escape }}"
}{% if forloop.last %}{% else %},
{% endif %}{% endfor %}
}

View File

@ -2,7 +2,7 @@
Gem::Specification.new do |spec|
spec.name = "just-the-docs"
spec.version = "0.1.1"
spec.version = "0.1.2"
spec.authors = ["Patrick Marsceill"]
spec.email = ["patrick.marsceill@gmail.com"]

View File

@ -2,10 +2,12 @@ namespace :search do
desc 'Generate the files needed for search functionality'
task :init do
puts 'Creating search data json file...'
touch 'search-data.json'
touch 'assets/js/search-data.json'
content = %Q[{{ page.content | markdownify | strip_html | xml_escape | remove: 'Table of contents' | strip_newlines | replace: '\\', ' ' }}]
puts 'Done.'
puts 'Generating content...'
File.open('search-data.json', 'w') do |f|
File.open('assets/js/search-data.json', 'w') do |f|
f.puts '---
---
{
@ -18,5 +20,6 @@ namespace :search do
{% endif %}{% endfor %}
}'
end
puts 'Done.'
end
end