封面式個人部落格

最後更新


部落格「Personal Alt」版本(PDRenderKit 1.0.1 純 JS 渲染):含自介與動態 SVG 波浪的主視覺、淺色頁首、附分頁的卡片格。

概要


項目內容
製作日期2023-07-21
分類個人頁範例
HTML 檔案index.html
原始碼target/20230721

預覽


封面式個人部落格 截圖
在新分頁開啟範例

頁面區塊


區塊說明
頂部頁首淺色社群圖示列(.contact.light.large)、Logo 區與搜尋/選單按鈕;選單按鈕開啟 #right-tab。
導覽列下拉選單 Home(Magazine、Personal、Classic、Minimal 開啟 demo-web.pardn.io 上的 20230719、20230720、20230722、20230723 範例;Personal Alt 呼叫 setHome)、List(List 1/2、Grid 1/2)、Post(1/2),以及 Author、contact、404。
首頁主視覺#default-header.home 以 fakeimg 為背景的主視覺:「I'm Pardn Chiu.」標題、簡介、GitHub/Email 按鈕,以及依視窗寬度計算貝茲曲線的內嵌 SVG 波浪。
首頁主欄2 則精選格狀(.grid-1)、部落格區塊、贊助廣告(image/left-ads.jpg 連到 joball.tw)與 4 張 .grid-2 卡片(標籤、摘要、分享、More 按鈕)及 1/2/3 分頁。
右側欄Popular/Recent 頁籤(僅首頁)、地球背景與波浪 SVG 的 About、熱門文章、主題、電子報輸入、熱門標籤。
內頁setList1/setList2/setGrid1/setGrid2(背景圖 #default-header 下的列表與格狀)、setPost(1|2)(文章、分享、標籤、作者卡、留言與表單;Post 1 用 #default-header、Post 2 用 #post-header)、setAuthor(#user-header + 6 張 .grid-2 卡片)、setContact(資訊、Google Maps iframe、表單)、set404。
頁尾6 張 Instagram 圖片列、版權、社群圖示與「Back to Top」按鈕。

互動行為


  • js/index.js:setHome/setList1/setList2/setGrid1/setGrid2/setPost/setAuthor/setContact/set404 以 body.__child() 重建 body 並重置 scrollTop(純 JS 切頁,不改變網址)。
  • _RIGHT_TAB 附加側滑選單 #right-tab;關閉鈕加上 hide 並於 300ms 後移除;子選單點擊切換 show。
  • done():body 捲動監聽在捲過頁首(#post-header 高度減 80px,或 #default-header 高度減 136px(首頁)/80px(其他頁))後顯示 #top-nav,並寫入 percent 屬性(0-1000)作為閱讀進度;依視窗與側欄高度設定 #section-right 的 top。
  • DOMContentLoaded 時呼叫 _SVGListener() 內嵌 span.svg[src] 圖片;500ms 後移除 body 的 ft class。
  • setHome 以 body.clientWidth 計算 p1-p5,產生三層 SVG 波浪 <path> 作為主視覺底緣。

相依資源


名稱版本來源
Font Awesome Free6.5.2https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css
PDRenderKit1.0.1https://cdn.jsdelivr.net/npm/pdrenderkit@1.0.1/dist/PDRenderKit.js
Noto Sans TC (font-family only)-declared in SCSS; no font stylesheet is linked, so it relies on a locally installed font or the sans-serif fallback

樣式


項目內容
SCSS 入口sass/index.scss
輸出 CSScss/index.css
Partials_top-nav.scss, _bottom-footer.scss, _header.scss, left/_index.scss, left/_topest.scss, left/_blog.scss, left/_list-1.scss, left/_list-2.scss, left/_grid-1.scss, left/_grid-2.scss, left/_post.scss, left/_comment.scss, left/_form.scss, left/_ads.scss, right/_index.scss, right/_button.scss, right/_list.scss, right/_topic.scss, right/_tag.scss (empty), right/_contact.scss (empty)

index.scss 含 reset、共用元件(含 .contact.light、.path.light 變體)與 #right-tab keyframes,並引入 _top-nav、_bottom-footer、_header 與 left(主欄:topest、blog、列表、格狀、文章、留言、表單、廣告)、right(側欄:button、list、topic)兩組 partial;right/_tag.scss 與 right/_contact.scss 未被引入。 _header 負責背景圖 #default-header(含 .home 首頁主視覺變體)、#user-header 與 #post-header。 var(--color-dark-*)、var(--color-light-*)、var(--color-brand-*)、var(--width-max)、var(--bgcolor) 定義於 index.html 的 inline <style> :root 區塊(品牌色 #E75480、#F67280、#F88158;--width-max 1280px)。
  1. cd target/20230721
  2. npx sass sass/index.scss css/index.css --no-source-map || exit 1

使用技巧


  • 整頁以 PDRenderKit 字串標籤語法於 JS 建構(('section' + '#id')._([...])、._$()、._click()、._open()、'fa-...'._fa),標籤名稱由傳入 IIFE 的單字母全域變數組合。
  • 以屬性驅動狀態:ul[index][sub-index] 標示選單、[percent] 驅動捲動進度條、分頁的 ul[page] 透過 SCSS @for 標示目前頁碼。
  • Flexbox 版型(未使用 CSS grid)、_top-nav 與 right/_index 使用 position: sticky、backdrop-filter、多行截斷 .line.r2/.r3、keyframes 側滑選單。
  • 以 ._({ style: $bg }) 設定背景;執行期產生 SVG 路徑;斷點 640/800/1024/1140px。

外部資源



相關頁面


EN