如果您平常喜歡使用 Notion 來做內容,那麼只需一個動作,就可以輕鬆導入 Notion 的頁面成為 SlimWeb 的頁面或是首頁區塊

1. 設定 Notion 的頁面

在您建立好 Notion 頁面後,請選擇右上角・・・下拉清單內的 全寬

image.png

然後再選擇右上角的 分享

image.png

2. 輸出到網頁

點選 發布 後 Notion 就會將目前頁面製作成網頁,按下 嵌入此頁面

image.png

Notion 將顯示嵌入此頁面的原始碼,但我們不需要完整的程式碼,只需要將這個頁面的網址複製出來即可

3. 建立 SlimWeb 頁面

在 SlimWeb 後台的 區塊管理/頁面管理 內點選 ***新增頁面,***點進入編輯器後,進入編輯器後,按右鍵選擇 插入iFrame

image.png

貼上網址,設定 iFrame 高度,預設值為 0,如果勾選不顯示Notion連結,那麼看起來就更像是網站原生內容

image.png

<aside>

🔔 什麼情況下需要設定長度?

如果是 Notion 頁面的話幾乎都需要,其他像是 Youtube, Tiktok 等就不需要

</aside>

取得 Notion 頁面長度需要用到 Chrome 的開發者工具並用 Console 執行下面的程式碼

function get_content_height() {
  let viewportHeight = window.innerHeight;
  let contentHeight = 0;
  document.querySelectorAll(".layout-content").forEach((el) => {
    contentHeight += el.offsetHeight;
  });
  if (contentHeight === 0) {
    console.warn("無法取得 layout-content 資訊");
    return;
  }
  if (contentHeight > viewportHeight) {
    console.info("高度建議值為: " + contentHeight);
    return;
  }
  let blocks = document.querySelectorAll("div[data-block-id]");
  if (!blocks.length) {
    console.warn("找不到任何 data-block-id 的元素");
    return;
  }
  const last = blocks[blocks.length - 1];
  const top = last.offsetTop;
  let total = top + last.offsetHeight;

  if (total < contentHeight) {
    total = contentHeight;
  }

  console.info("長度建議值為: " + total);
}
get_content_height();