Commit 521249f6 authored by fauno's avatar fauno

urls e indice relativos

parent 3ed7ba71
<!DOCTYPE html>
<html lang="{{ site.lang }}" prefix="og: http://ogp.me">
<head>
{% assign base = '' %}
{% assign depth = page.url | split: '/' %}
{% for dots in depth offset: 2 %}
{% assign base = base | append: '../' %}
{% endfor %}
<base href="{{ base }}" />
<base href="{{ page.url | base }}" />
<meta charset="utf-8" />
<title>{{ site.title }}{% if page.title %} - {{ page.title }}{% endif %}</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
......
......@@ -2,6 +2,8 @@
layout: default
---
{% assign relative_url = page.url | remove_first: '/' %}
<article>
<header>
<h4><a href="" alt='Inicio'>{{ site.title }}</a></h4>
......@@ -10,11 +12,11 @@ layout: default
<ul class="list-inline">
{% for format in site.pandoc.outputs %}
{% capture extension %}{{ format | first }}{% endcapture %}
<li><a href="{{ page.url | remove_first: '/' | remove:'.html' }}.{{ extension }}">{{ extension }}</a></li>
<li><a href="{{ relative_url | remove:'.html' }}.{{ extension }}">{{ extension }}</a></li>
{% endfor %}
<li><a href="{{ page.url | remove_first: '/' | remove:'.html' }}-imposed.pdf">impresión</a></li>
<li><a href="{{ page.url | remove_first: '/' | remove:'.html' }}-binder.pdf">binder</a></li>
<li><a href="{{ relative_url | remove:'.html' }}-imposed.pdf">impresión</a></li>
<li><a href="{{ relative_url | remove:'.html' }}-binder.pdf">binder</a></li>
{% if page.cover %}
<li><a href="{{ page.cover }}">tapas</a></li>
......@@ -41,9 +43,9 @@ layout: default
</p>
{% endif %}
{{ content }}
{{ content | html_relativize_anchors_to: relative_url }}
{% if site.related_posts %}
{% if site.related_posts.size > 0 %}
<footer id="related">
<h2>Otras lecturas</h2>
<ul class="posts">
......
......@@ -14,6 +14,24 @@ module Jekyll
def month_i18n(date, months)
months[date.month - 1]
end
def base(url)
base = ''
depth = url.split('/').size - 2
depth.times do
base += '../'
end
base
end
# TODO: Mover a jekyll-relative-urls
# TODO: Hacerlo con Nokogiri?
#
# Agrega una URL base a los anchors de una cadena HTML
def html_relativize_anchors_to(input, base)
input.gsub!(/((href|src)=["'])#/, "\\1#{base}#")
end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment