Split uri into url and destination, remove trailing slashes from links
This commit is contained in:
@@ -13,11 +13,11 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class Article(Content):
|
class Article(Content):
|
||||||
def __init__(self, path: Path, meta: dict[str, Any]):
|
def __init__(self, source: Path, meta: dict[str, Any]):
|
||||||
if "tags" not in meta:
|
if "tags" not in meta:
|
||||||
log.warning("no tags for article in '%s'", path)
|
log.warning("no tags for article in '%s'", source)
|
||||||
super().__init__(
|
super().__init__(
|
||||||
path,
|
source,
|
||||||
meta["section"],
|
meta["section"],
|
||||||
meta["slug"],
|
meta["slug"],
|
||||||
meta["date"],
|
meta["date"],
|
||||||
@@ -35,7 +35,7 @@ class Article(Content):
|
|||||||
template = site.jinja_env.get_template("article.html")
|
template = site.jinja_env.get_template("article.html")
|
||||||
html = template.render(article=self, content=content, site=site)
|
html = template.render(article=self, content=content, site=site)
|
||||||
|
|
||||||
out_path = site.output_path / self.uri
|
out_path = site.output_path / self.destination
|
||||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
out_path.write_text(html, encoding="utf-8")
|
out_path.write_text(html, encoding="utf-8")
|
||||||
log.debug("Rendered %s -> %s", self.source, out_path)
|
log.debug("Rendered %s -> %s", self.source, out_path)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Content(Output):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path: Path,
|
source: Path,
|
||||||
section: str,
|
section: str,
|
||||||
slug: str,
|
slug: str,
|
||||||
created: date,
|
created: date,
|
||||||
@@ -21,10 +21,10 @@ class Content(Output):
|
|||||||
tags: set[str] | None = None,
|
tags: set[str] | None = None,
|
||||||
summary: str | None = None,
|
summary: str | None = None,
|
||||||
):
|
):
|
||||||
super().__init__(Content.build_uri(section, slug))
|
super().__init__(Content.build_path(section, slug))
|
||||||
if tags is None:
|
if tags is None:
|
||||||
tags = set()
|
tags = set()
|
||||||
self.source = path
|
self.source = source
|
||||||
self.section: str = section
|
self.section: str = section
|
||||||
self.created = created
|
self.created = created
|
||||||
self.updated = updated
|
self.updated = updated
|
||||||
@@ -32,11 +32,11 @@ class Content(Output):
|
|||||||
self.summary: str | None = summary
|
self.summary: str | None = summary
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_uri(section: str, slug: str) -> str:
|
def build_path(section: str, slug: str) -> Path:
|
||||||
if not Content._SECTION_RE.match(section):
|
if not Content._SECTION_RE.match(section):
|
||||||
raise ContentError(f"Invalid section '{section}'")
|
raise ContentError(f"Invalid section '{section}'")
|
||||||
uri = f"{section}/{slug}.html"
|
path = Path(f"{section}/{slug}.html")
|
||||||
return uri
|
return path
|
||||||
|
|
||||||
def read_body(self) -> str:
|
def read_body(self) -> str:
|
||||||
with self.source.open("r", encoding="utf-8") as f:
|
with self.source.open("r", encoding="utf-8") as f:
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class File(Output):
|
class File(Output):
|
||||||
def __init__(self, uri: str, source: Path):
|
def __init__(self, path: Path, source: Path):
|
||||||
super().__init__(uri)
|
super().__init__(path)
|
||||||
self.source = source
|
self.source = source
|
||||||
|
|
||||||
def write(self, site: Site) -> None:
|
def write(self, site: Site) -> None:
|
||||||
dest = site.output_path / self.uri
|
dest = site.output_path / self.destination
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.copyfile(self.source, dest)
|
shutil.copyfile(self.source, dest)
|
||||||
log.debug("Copied %s -> %s", self.source, dest)
|
log.debug("Copied %s -> %s", self.source, dest)
|
||||||
|
|||||||
+11
-10
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
from math import ceil
|
from math import ceil
|
||||||
from itertools import batched
|
from itertools import batched
|
||||||
from typing import TYPE_CHECKING, Literal
|
from typing import TYPE_CHECKING, Literal
|
||||||
@@ -22,7 +23,7 @@ class Index(Output):
|
|||||||
total_pages: int,
|
total_pages: int,
|
||||||
label: str | None,
|
label: str | None,
|
||||||
):
|
):
|
||||||
super().__init__(Index.build_uri(kind, page_num, label))
|
super().__init__(Index.build_path(kind, page_num, label))
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
self.items = items
|
self.items = items
|
||||||
self.page_num = page_num
|
self.page_num = page_num
|
||||||
@@ -30,25 +31,25 @@ class Index(Output):
|
|||||||
self.label = label
|
self.label = label
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_uri(
|
def build_path(
|
||||||
kind: Literal["root", "section", "tag"],
|
kind: Literal["root", "section", "tag"],
|
||||||
page_num: int,
|
page_num: int,
|
||||||
label: str | None,
|
label: str | None,
|
||||||
) -> str:
|
) -> Path:
|
||||||
if page_num == 1:
|
if page_num == 1:
|
||||||
file = "index.html"
|
file = Path("index.html")
|
||||||
else:
|
else:
|
||||||
file = f"page-{page_num}.html"
|
file = Path(f"page-{page_num}.html")
|
||||||
|
|
||||||
if kind == "root":
|
if kind == "root":
|
||||||
uri = file
|
path = file
|
||||||
elif kind == "section":
|
elif kind == "section":
|
||||||
assert label, "label can't be None if kind is not root"
|
assert label, "label can't be None if kind is not root"
|
||||||
uri = f"{label}/{file}"
|
path = Path(label) / file
|
||||||
else:
|
else:
|
||||||
assert label, "label can't be None if kind is not root"
|
assert label, "label can't be None if kind is not root"
|
||||||
uri = f"tags/{label}/{file}"
|
path = Path("tags") / label / file
|
||||||
return uri
|
return path
|
||||||
|
|
||||||
def write(self, site: Site) -> None:
|
def write(self, site: Site) -> None:
|
||||||
template = site.jinja_env.get_template("index.html")
|
template = site.jinja_env.get_template("index.html")
|
||||||
@@ -60,7 +61,7 @@ class Index(Output):
|
|||||||
kind=self.kind,
|
kind=self.kind,
|
||||||
label=self.label,
|
label=self.label,
|
||||||
)
|
)
|
||||||
dest = site.output_path / self.uri
|
dest = site.output_path / self.destination
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
dest.write_text(html, encoding="utf-8")
|
dest.write_text(html, encoding="utf-8")
|
||||||
log.debug("Wrote %s", dest)
|
log.debug("Wrote %s", dest)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from omicron.ssg.output.output import Output
|
from omicron.ssg.output.output import Output
|
||||||
|
|
||||||
@@ -11,12 +12,12 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class Memory(Output):
|
class Memory(Output):
|
||||||
def __init__(self, uri: str, content: str):
|
def __init__(self, destination: Path, content: str):
|
||||||
super().__init__(uri)
|
super().__init__(destination)
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
||||||
def write(self, site: Site) -> None:
|
def write(self, site: Site) -> None:
|
||||||
dest = site.output_path / self.uri
|
dest = site.output_path / self.destination
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
dest.write_text(self.content, encoding="utf-8")
|
dest.write_text(self.content, encoding="utf-8")
|
||||||
log.debug("Wrote %s", dest)
|
log.debug("Wrote %s", dest)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from omicron.ssg.site import Site # for static checking with mypy
|
from omicron.ssg.site import Site # for static checking with mypy
|
||||||
@@ -8,8 +9,13 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class Output(ABC):
|
class Output(ABC):
|
||||||
def __init__(self, uri: str):
|
def __init__(self, destination: Path):
|
||||||
self.uri = uri
|
self.destination = destination
|
||||||
|
url = "/" + destination.as_posix()
|
||||||
|
url = url.removesuffix("/index.html")
|
||||||
|
if url == "":
|
||||||
|
url = "/"
|
||||||
|
self.url = url
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def write(self, site: Site) -> None:
|
def write(self, site: Site) -> None:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from omicron.ssg.output.output import Output
|
from omicron.ssg.output.output import Output
|
||||||
|
|
||||||
@@ -12,13 +13,13 @@ else:
|
|||||||
|
|
||||||
class Tags(Output):
|
class Tags(Output):
|
||||||
def __init__(self, tags: list[tuple[str, int]]):
|
def __init__(self, tags: list[tuple[str, int]]):
|
||||||
super().__init__("tags/index.html")
|
super().__init__(Path("tags/index.html"))
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
|
|
||||||
def write(self, site: Site) -> None:
|
def write(self, site: Site) -> None:
|
||||||
template = site.jinja_env.get_template("tags.html")
|
template = site.jinja_env.get_template("tags.html")
|
||||||
html = template.render(site=site, tags=self.tags)
|
html = template.render(site=site, tags=self.tags)
|
||||||
dest = site.output_path / self.uri
|
dest = site.output_path / self.destination
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
dest.write_text(html, encoding="utf-8")
|
dest.write_text(html, encoding="utf-8")
|
||||||
log.debug("Wrote %s", dest)
|
log.debug("Wrote %s", dest)
|
||||||
|
|||||||
+22
-24
@@ -32,7 +32,7 @@ class Site:
|
|||||||
self.content: list[Content] = []
|
self.content: list[Content] = []
|
||||||
self.other_outputs: list[Output] = []
|
self.other_outputs: list[Output] = []
|
||||||
self.by_tag: dict[str, list[Content]] = {}
|
self.by_tag: dict[str, list[Content]] = {}
|
||||||
self.by_uri: dict[str, Output] = {}
|
self.by_path: dict[Path, Output] = {}
|
||||||
self.by_section: dict[str, list[Content]] = {}
|
self.by_section: dict[str, list[Content]] = {}
|
||||||
self.tags_by_count: list[tuple[str, int]] = []
|
self.tags_by_count: list[tuple[str, int]] = []
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class Site:
|
|||||||
self.name: str = config["name"]
|
self.name: str = config["name"]
|
||||||
self.template: str = config["template"]
|
self.template: str = config["template"]
|
||||||
self.items_per_page: int = int(config.get("items_per_page", 20))
|
self.items_per_page: int = int(config.get("items_per_page", 20))
|
||||||
self.origin, self.base_dir = Site.parse_base_uri(config.get("base_uri"))
|
self.origin, self.base_dir = Site.parse_base_url(config.get("base_url"))
|
||||||
self.template_path: Path = Site.resolve_template_path(self.template)
|
self.template_path: Path = Site.resolve_template_path(self.template)
|
||||||
self.output_path: Path = self.site_path / "output"
|
self.output_path: Path = self.site_path / "output"
|
||||||
self.jinja_env = Environment(loader=FileSystemLoader(self.template_path))
|
self.jinja_env = Environment(loader=FileSystemLoader(self.template_path))
|
||||||
@@ -59,9 +59,9 @@ class Site:
|
|||||||
return cast(dict[str, Any], config)
|
return cast(dict[str, Any], config)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_base_uri(value: str | None) -> tuple[str, str]:
|
def parse_base_url(value: str | None) -> tuple[str, str]:
|
||||||
if not value:
|
if not value:
|
||||||
return ("", "/")
|
return ("", "")
|
||||||
parsed = urlparse(value)
|
parsed = urlparse(value)
|
||||||
if parsed.scheme and parsed.netloc:
|
if parsed.scheme and parsed.netloc:
|
||||||
origin = f"{parsed.scheme}://{parsed.netloc}"
|
origin = f"{parsed.scheme}://{parsed.netloc}"
|
||||||
@@ -70,9 +70,7 @@ class Site:
|
|||||||
else:
|
else:
|
||||||
origin = ""
|
origin = ""
|
||||||
|
|
||||||
path = parsed.path
|
path = parsed.path.removesuffix("/")
|
||||||
if not path.endswith("/"):
|
|
||||||
path += "/"
|
|
||||||
return (origin, path)
|
return (origin, path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -93,12 +91,12 @@ class Site:
|
|||||||
self.by_tag[tag] = []
|
self.by_tag[tag] = []
|
||||||
self.by_tag[tag].append(content)
|
self.by_tag[tag].append(content)
|
||||||
|
|
||||||
def add_by_uri(self, output: Output) -> None:
|
def add_by_path(self, output: Output) -> None:
|
||||||
if output.uri in self.by_uri:
|
if output.destination in self.by_path:
|
||||||
raise ContentError(
|
raise ContentError(
|
||||||
f"uri '{output.uri}' is already claimed by another output"
|
f"path '{output.destination}' is already claimed by another output"
|
||||||
)
|
)
|
||||||
self.by_uri[output.uri] = output
|
self.by_path[output.destination] = output
|
||||||
|
|
||||||
def update_tags_by_count(self) -> None:
|
def update_tags_by_count(self) -> None:
|
||||||
tags = [(tag, len(items)) for tag, items in self.by_tag.items()]
|
tags = [(tag, len(items)) for tag, items in self.by_tag.items()]
|
||||||
@@ -111,43 +109,43 @@ class Site:
|
|||||||
return
|
return
|
||||||
for file in assets_path.rglob("*"):
|
for file in assets_path.rglob("*"):
|
||||||
if file.is_file():
|
if file.is_file():
|
||||||
uri = "assets/" + file.relative_to(assets_path).as_posix()
|
path = Path("assets") / file.relative_to(assets_path)
|
||||||
asset = File(uri, file)
|
asset = File(path, file)
|
||||||
self.add_by_uri(asset)
|
self.add_by_path(asset)
|
||||||
self.other_outputs.append(asset)
|
self.other_outputs.append(asset)
|
||||||
log.debug("Discovered template asset %s", uri)
|
log.debug("Discovered template asset %s", path)
|
||||||
|
|
||||||
def discover(self) -> None:
|
def discover(self) -> None:
|
||||||
log.info("Discovering content...")
|
log.info("Discovering content...")
|
||||||
self.discover_assets()
|
self.discover_assets()
|
||||||
pygments = Memory("assets/pygments.css", highlight_style())
|
pygments = Memory(Path("assets/pygments.css"), highlight_style())
|
||||||
self.other_outputs.append(pygments)
|
self.other_outputs.append(pygments)
|
||||||
self.add_by_uri(pygments)
|
self.add_by_path(pygments)
|
||||||
content_path = self.site_path / "content"
|
content_path = self.site_path / "content"
|
||||||
for file in content_path.rglob("*"):
|
for file in content_path.rglob("*"):
|
||||||
if file.is_file() and is_content(file):
|
if file.is_file() and is_content(file):
|
||||||
content = create_content(file)
|
content = create_content(file)
|
||||||
self.add_by_uri(content)
|
self.add_by_path(content)
|
||||||
self.add_by_section(content)
|
self.add_by_section(content)
|
||||||
self.add_by_tag(content)
|
self.add_by_tag(content)
|
||||||
self.content.append(content)
|
self.content.append(content)
|
||||||
self.update_tags_by_count()
|
self.update_tags_by_count()
|
||||||
for index in discover_index(self):
|
for index in discover_index(self):
|
||||||
self.add_by_uri(index)
|
self.add_by_path(index)
|
||||||
self.other_outputs.append(index)
|
self.other_outputs.append(index)
|
||||||
tags_page = discover_tags(self)
|
tags_page = discover_tags(self)
|
||||||
self.add_by_uri(tags_page)
|
self.add_by_path(tags_page)
|
||||||
self.other_outputs.append(tags_page)
|
self.other_outputs.append(tags_page)
|
||||||
log.info("Discovered %d content items", len(self.content))
|
log.info("Discovered %d content items", len(self.content))
|
||||||
|
|
||||||
def build(self) -> None:
|
def build(self) -> None:
|
||||||
if not self.origin:
|
if not self.origin:
|
||||||
log.warning(
|
log.warning(
|
||||||
"base_uri config value is missing a domain name, "
|
"base_url config value is missing a domain name, "
|
||||||
"can't add canonical uri to content"
|
"can't add canonical url to content"
|
||||||
)
|
)
|
||||||
if not self.base_dir.startswith("/"):
|
if self.base_dir and not self.base_dir.startswith("/"):
|
||||||
raise ConfigError("base_uri config value must be an absolute path")
|
raise ConfigError("base_url config value must be an absolute path")
|
||||||
self.discover()
|
self.discover()
|
||||||
self.output_path.mkdir(parents=True, exist_ok=True)
|
self.output_path.mkdir(parents=True, exist_ok=True)
|
||||||
for content in self.content:
|
for content in self.content:
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
{% block title %}{{ article.title }} — {{ site.name }}{% endblock %}
|
{% block title %}{{ article.title }} — {{ site.name }}{% endblock %}
|
||||||
|
|
||||||
{% block head %}<link rel="canonical" href="{{ site.origin }}{{ site.base_dir }}{{ article.uri }}">{% endblock %}
|
{% block head %}<link rel="canonical" href="{{ site.origin }}{{ site.base_dir }}{{ article.url }}">{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumb %}
|
{% block breadcrumb %}
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<a href="{{ site.base_dir }}">{{ site.name }}</a> ›
|
<a href="{{ site.base_dir or "/" }}">{{ site.name }}</a> ›
|
||||||
<a href="{{ site.base_dir }}{{ article.section }}/">{{ article.section }}</a> ›
|
<a href="{{ site.base_dir }}/{{ article.section }}">{{ article.section }}</a> ›
|
||||||
{{ article.title }}
|
{{ article.title }}
|
||||||
</nav>
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
{% if article.tags %}
|
{% if article.tags %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for tag in article.tags | sort %}
|
{% for tag in article.tags | sort %}
|
||||||
<li><a href="{{ site.base_dir }}tags/{{ tag }}/">{{ tag }}</a></li>
|
<li><a href="{{ site.base_dir }}/tags/{{ tag }}">{{ tag }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{% block title %}{{ site.name }}{% endblock %}</title>
|
<title>{% block title %}{{ site.name }}{% endblock %}</title>
|
||||||
<link rel="stylesheet" href="{{ site.base_dir }}assets/style.css">
|
<link rel="stylesheet" href="{{ site.base_dir }}/assets/style.css">
|
||||||
<link rel="stylesheet" href="{{ site.base_dir }}assets/pygments.css">
|
<link rel="stylesheet" href="{{ site.base_dir }}/assets/pygments.css">
|
||||||
{% block head %}{% endblock %}
|
{% block head %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
{% block breadcrumb %}<a href="{{ site.base_dir }}">{{ site.name }}</a>{% endblock %}
|
{% block breadcrumb %}<a href="{{ site.base_dir or "/" }}">{{ site.name }}</a>{% endblock %}
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
{% block main %}{% endblock %}
|
{% block main %}{% endblock %}
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% set prefix = (label + "/") if kind == "section" else (("tags/" + label + "/") if kind == "tag" else "") %}
|
{% set base_path = ("/" + label) if kind == "section" else (("/tags/" + label) if kind == "tag" else "") %}
|
||||||
{% set heading = label or "" %}
|
{% set heading = label or "" %}
|
||||||
|
|
||||||
{% block title %}{% if heading %}{{ heading }} — {% endif %}{{ site.name }}{% if page_num > 1 %} — Page {{ page_num }}{% endif %}{% endblock %}
|
{% block title %}{% if heading %}{{ heading }} — {% endif %}{{ site.name }}{% if page_num > 1 %} — Page {{ page_num }}{% endif %}{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link rel="canonical" href="{{ site.origin }}{{ site.base_dir }}{{ prefix }}{% if page_num > 1 %}page-{{ page_num }}.html{% endif %}">
|
<link rel="canonical" href="{{ site.origin }}{{ site.base_dir }}{% if page_num == 1 %}{{ base_path or "/" }}{% else %}{{ base_path }}/page-{{ page_num }}.html{% endif %}">
|
||||||
{% if page_num > 1 %}<meta name="robots" content="noindex, follow">{% endif %}
|
{% if page_num > 1 %}<meta name="robots" content="noindex, follow">{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumb %}
|
{% block breadcrumb %}
|
||||||
{% if kind == "section" %}
|
{% if kind == "section" %}
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<a href="{{ site.base_dir }}">{{ site.name }}</a> ›
|
<a href="{{ site.base_dir or "/" }}">{{ site.name }}</a> ›
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</nav>
|
</nav>
|
||||||
{% elif kind == "tag" %}
|
{% elif kind == "tag" %}
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<a href="{{ site.base_dir }}">{{ site.name }}</a> ›
|
<a href="{{ site.base_dir or "/" }}">{{ site.name }}</a> ›
|
||||||
<a href="{{ site.base_dir }}tags/">Tags</a> ›
|
<a href="{{ site.base_dir }}/tags">Tags</a> ›
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</nav>
|
</nav>
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
<article>
|
<article>
|
||||||
<header>
|
<header>
|
||||||
<h2><a href="{{ site.base_dir }}{{ item.uri }}">{{ item.title }}</a></h2>
|
<h2><a href="{{ site.base_dir }}{{ item.url }}">{{ item.title }}</a></h2>
|
||||||
<time datetime="{{ item.created }}">{{ item.created }}</time>
|
<time datetime="{{ item.created }}">{{ item.created }}</time>
|
||||||
</header>
|
</header>
|
||||||
{% if item.summary %}<p>{{ item.summary }}</p>{% endif %}
|
{% if item.summary %}<p>{{ item.summary }}</p>{% endif %}
|
||||||
@@ -40,15 +40,15 @@
|
|||||||
{% if total_pages > 1 %}
|
{% if total_pages > 1 %}
|
||||||
<nav>
|
<nav>
|
||||||
{% if page_num > 1 %}
|
{% if page_num > 1 %}
|
||||||
<a href="{{ site.base_dir }}{{ prefix }}{{ "" if page_num - 1 == 1 else "page-" ~ (page_num - 1) ~ ".html" }}">← Newer</a>
|
<a href="{{ site.base_dir }}{% if page_num - 1 == 1 %}{{ base_path or "/" }}{% else %}{{ base_path }}/page-{{ page_num - 1 }}.html{% endif %}">← Newer</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for p in range(1, total_pages + 1) %}
|
{% for p in range(1, total_pages + 1) %}
|
||||||
{% if p == page_num %}<strong>{{ p }}</strong>
|
{% if p == page_num %}<strong>{{ p }}</strong>
|
||||||
{% else %}<a href="{{ site.base_dir }}{{ prefix }}{{ "" if p == 1 else "page-" ~ p ~ ".html" }}">{{ p }}</a>
|
{% else %}<a href="{{ site.base_dir }}{% if p == 1 %}{{ base_path or "/" }}{% else %}{{ base_path }}/page-{{ p }}.html{% endif %}">{{ p }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if page_num < total_pages %}
|
{% if page_num < total_pages %}
|
||||||
<a href="{{ site.base_dir }}{{ prefix }}page-{{ page_num + 1 }}.html">Older →</a>
|
<a href="{{ site.base_dir }}{{ base_path }}/page-{{ page_num + 1 }}.html">Older →</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</nav>
|
</nav>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
{% block title %}Tags — {{ site.name }}{% endblock %}
|
{% block title %}Tags — {{ site.name }}{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link rel="canonical" href="{{ site.origin }}{{ site.base_dir }}tags/">
|
<link rel="canonical" href="{{ site.origin }}{{ site.base_dir }}/tags">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumb %}
|
{% block breadcrumb %}
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<a href="{{ site.base_dir }}">{{ site.name }}</a> ›
|
<a href="{{ site.base_dir or "/" }}">{{ site.name }}</a> ›
|
||||||
Tags
|
Tags
|
||||||
</nav>
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<h1>Tags</h1>
|
<h1>Tags</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{% for tag, count in tags %}
|
{% for tag, count in tags %}
|
||||||
<li><a href="{{ site.base_dir }}tags/{{ tag }}/">{{ tag }}</a> ({{ count }})</li>
|
<li><a href="{{ site.base_dir }}/tags/{{ tag }}">{{ tag }}</a> ({{ count }})</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user