mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge ec3e57ef77 into b7408cbfe9
This commit is contained in:
commit
ef8d405623
2 changed files with 17 additions and 5 deletions
3
RELEASE.md
Normal file
3
RELEASE.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Release type: minor
|
||||
|
||||
Allow extensionless internal links
|
||||
|
|
@ -13,7 +13,6 @@ try:
|
|||
except ModuleNotFoundError:
|
||||
from backports.zoneinfo import ZoneInfo
|
||||
|
||||
|
||||
from pelican.plugins import signals
|
||||
from pelican.settings import DEFAULT_CONFIG, Settings
|
||||
|
||||
|
|
@ -281,7 +280,9 @@ class Content:
|
|||
# XXX Put this in a different location.
|
||||
if what in {"filename", "static", "attach"}:
|
||||
|
||||
def _get_linked_content(key: str, url: ParseResult) -> Optional[Content]:
|
||||
def _get_linked_content(
|
||||
key: str, url: ParseResult, extension: Optional[str] = None
|
||||
) -> Optional[Content]:
|
||||
nonlocal value
|
||||
|
||||
def _find_path(path: str) -> Optional[Content]:
|
||||
|
|
@ -294,13 +295,15 @@ class Content:
|
|||
)
|
||||
return self._context[key].get(path, None)
|
||||
|
||||
url_path = url.path if not extension else f"{url.path}.{extension}"
|
||||
|
||||
# try path
|
||||
result = _find_path(url.path)
|
||||
result = _find_path(url_path)
|
||||
if result is not None:
|
||||
return result
|
||||
|
||||
# try unquoted path
|
||||
result = _find_path(unquote(url.path))
|
||||
result = _find_path(unquote(url_path))
|
||||
if result is not None:
|
||||
return result
|
||||
|
||||
|
|
@ -330,7 +333,13 @@ class Content:
|
|||
else:
|
||||
key = "static_content"
|
||||
|
||||
linked_content = _get_linked_content(key, value)
|
||||
# Where do we find a comprehensive list of Reader extensions?
|
||||
reader_ext = ["md", "markdown"]
|
||||
extensions = [None] + reader_ext
|
||||
for extension in extensions:
|
||||
if linked_content := _get_linked_content(key, value, extension):
|
||||
break
|
||||
|
||||
if linked_content:
|
||||
if what == "attach":
|
||||
linked_content.attach_to(self) # type: ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue