Skip to content

Commit 2b2d151

Browse files
committedApr 12, 2021
fixed infinite scroll for ipfs
1 parent b098b71 commit 2b2d151

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed
 

‎_posts/2021-03-24-starting-the-adventure.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ You can use the modified template yourself by [forking my repository](https://gi
108108
Since I decided on Jekyll to generate my site, the choice for hosting was quite obvious, **[Github Pages](https://pages.github.com)** is very nicely integrated with it, it is free, and it has no ads! Plus the domain name isn't too terrible ([the-mvm.github.io](https://the-mvm.github.io)).
109109

110110
##### Interplanetary File System
111-
To contribute to and test [IPFS](https://github.com/ipfs/ipfs#quick-summary) I also set up a [mirror](https://weathered-bread-8229.on.fleek.co/) in IPFS by using [fleek.co](https://fleek.co). I must confess that it was more troublesome than I imagined, it was definetively not plug and play because of the paths used to fetch resources. The nature of IPFS makes short absolute paths for website resources (like images, css and javascript files) innoperative; the easiest fix for this is to use relative paths, however the same relative path that works for the root directory (i.e. /index.html) does not work for links inside directories (i.e. /tags/), and since the site is static, while generating it, one must make the distintion between the different directory levels for the page to be rendered correctly.
111+
To contribute to and test [IPFS](https://github.com/ipfs/ipfs#quick-summary) I also set up a [mirror](https://weathered-bread-8229.on.fleek.co/) in IPFS by using [fleek.co](https://fleek.co). I must confess that it was more troublesome than I imagined, it was definetively not plug and play because of the paths used to fetch resources. The nature of IPFS makes short absolute paths for website resources (like images, css and javascript files) inoperative; the easiest fix for this is to use relative paths, however the same relative path that works for the root directory (i.e. /index.html) does not work for links inside directories (i.e. /tags/), and since the site is static, while generating it, one must make the distinction between the different directory levels for the page to be rendered correctly.
112112

113113
At first I tried a simple (but brute force solution):
114114
```jekyll
@@ -120,12 +120,12 @@ At first I tried a simple (but brute force solution):
120120
{% assign relativebase = './' %}
121121
{% endif %}
122122
...
123-
# Eliminate unnecesary double backslashes
123+
# Eliminate unecesary double backslashes
124124
{% capture post_url %}{{ relativebase }}{{ post.url }}{% endcapture %}
125125
{% assign post_url = post_url | replace: "//", "/" %}
126126
```
127127
This `jekyll/liquid` code was executed in every page (or include) that needed to reference a resource hosted in the same server.
128128

129-
But this fix did not work for the search function, because it relies on a `search.json` file (also generated programatically to be served as a static file), therefore when generating this file one either use the relative path for the `root` directory or for a nested directory, thus the search results will only link correctly the corresponding pages if the page where the user searched for something is in the corresponding scope.
129+
But this fix did not work for the search function, because it relies on a `search.json` file (also generated programmatically to be served as a static file), therefore when generating this file one either use the relative path for the `root` directory or for a nested directory, thus the search results will only link correctly the corresponding pages if the page where the user searched for something is in the corresponding scope.
130130

131131
So the final solution was to make the whole site flat, meaning to live in a single directory. All pages and posts will live under the root directory, and by doing so, I can control how to address the relative paths for resources.

‎all-posts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layout: null
44
{
55
"posts" : [
66
{% for post in site.posts %}
7-
"{{ post.url }}"{% unless forloop.last %},{% endunless %}
7+
".{{ post.url }}"{% unless forloop.last %},{% endunless %}
88
{% endfor %}
99
]
1010
}

‎posts-by-tag.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ layout: null
88
"tag" : "{{ this_word }}",
99
"posts" : [
1010
{% for post in site.tags[this_word] %}
11-
"{{ post.url }}"{% unless forloop.last %},{% endunless %}
11+
".{{ post.url }}"{% unless forloop.last %},{% endunless %}
1212
{% endfor %}
1313
]
1414
} {% unless forloop.rindex == 2 %},{% endunless %}

0 commit comments

Comments
 (0)
Please sign in to comment.