2024-04-23 13:21:26 +00:00
+++
date = "2017-05-28"
tags = ["blog"]
title = "middleman-auto-scroll"
slug = "blog"
+++
middlemanの場合、`/page/3`のところを`../3`とかなってハマる。
https://github.com/gilbitron/Infiniscroll
> layout.slim
```js
- paginate = current_page.metadata[:locals]["paginate"]
- num_pages = current_page.metadata[:locals]["num_pages"]
- page_number = current_page.metadata[:locals]["page_number"]
- prev_page = current_page.metadata[:locals]["prev_page"]
- next_page = current_page.metadata[:locals]["next_page"]
.content
- if paginate && num_pages > 1
.pager
- if prev_page
= link_to "./page/#{page_number-1}", class: "prev"
|前のページ
//= link_to prev_page, class: "prev"
// |前のページ
- else
.pager__prev
- if next_page
= link_to "./page/#{page_number+1}", class: "next"
| 次のページ
//= link_to next_page, class: "next"
// | 次のページ
- else
.pager__next
.loading
```
Ref :
http://memo.brdr.jp/post/90340762216/middleman-blog%E3%81%A7%E6%AC%A1%E3%81%AE%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92ajax%E3%81%A7%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%82%80
これでもscroll.jsのread時にhttpsではないので`http://example.com/page/2/`とかなってハマる。`set :relative_links, true`をsetしている場合は`false`にするといい。
```
2024-12-21 06:52:52 +00:00
Mixed Content: The page at 'https://blogm.syui.ai/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://blogm.syui.ai/page/2/'. This request has been blocked; the content must be served over HTTPS.
2024-04-23 13:21:26 +00:00
```
> config.rb
```
configure :build do
activate :asset_host, :host => 'https://example.com'
activate :asset_hash
#set :relative_links, true
end
```
```
- "./page/#{page_number+1}"
+ "/page/#{page_number+1}"
```