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

How to deal with internal link? #57

Open
PaulPichaureau opened this issue Jan 7, 2018 · 1 comment
Open

How to deal with internal link? #57

PaulPichaureau opened this issue Jan 7, 2018 · 1 comment
Milestone

Comments

@PaulPichaureau
Copy link
Contributor

PaulPichaureau commented Jan 7, 2018

Hi,

I have the following problem: I would link to make internal link in a data. For example

---
title: Second post
author: paul
---

## Overview
This is the content of the **second** post. 

Go to [First post]( ??? )

The problem is that the url of the first post is defined in the views and generated by statik. Is there a way to access to it in data? It looks like a snake biting its own tail... :-/

@PaulPichaureau PaulPichaureau changed the title How deal with internal link? How to deal with internal link? Jan 7, 2018
@thanethomson
Copy link
Owner

This is definitely a necessary feature, but like you say, quite tricky to implement. The ideal way of implementing this would most likely involve some kind of Markdown pre-processing or post-processing on rendered templates. One idea I've had in this regard is to use a custom, Statik-specific URL schema that would be translated into the relevant relative URL for the target element (called a "reverse URL lookup").

For example, if you had a Post model whose instance is rendered by the view posts.yml, and the path to a post is built up by /{{ post.date|date("%Y/%m/%d") }}/{{ post.slug }} (as it is on my personal blog), and you wanted to refer from one post to another (whose primary key is, for example, first-post), you'd use some kind of URL schema like so:

Go to [first post](statik://posts/first-post) ...

where the URL schema is statik://<view-name>/<primary-key> for a complex view, or just statik://<view-name> if it's a simple view.

This would then be processed to:

Go to <a href="/2018/01/07/first-post/">first post</a> ...

For now, as per my blog, I've hard-coded relative links from one post to another, because the permalink doesn't change.

@thanethomson thanethomson added this to the v0.23.0 milestone Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants