Magazine Blog

Last updated


Magazine-style blog template using PDRenderKit 1.2.0 declarative templates: ?page= routing with :if, :path partial views, :for loops and a Markdown post body.

Overview


ItemValue
Created2023-07-19
Last updated2024-12-22
CategoryBlog Examples
HTML filesindex.html, views/top-nav.html, views/right-tab.html, views/default-header.html, views/body-home.html, views/body-list-1.html, views/body-list-2.html, views/body-grid-1.html, views/body-grid-2.html, views/body-post-1.html, views/body-post-2.html, views/body-author.html, views/body-contact.html, views/body-404.html, views/right.html, views/bottom-footer.html
Sourcetarget/20230719

Preview


Magazine Blog screenshot
Open the example in a new tab

Page Sections


SectionDescription
Top nav (views/top-nav.html)Logo text, dropdown menus Home/List/Post plus Author, Contact, 404; Home dropdown links to the sibling templates 20230720-20230723 on demo-web.pardn.io; social icons, search button and menu button.
Home (views/body-home.html)Featured hero figure, blog block (one large article + 4 small links), sponsored ad image, further post groups; right sidebar from views/right.html.
Default header (views/default-header.html)Simple header with h1 used by list, grid and contact pages.
List 1 / List 2 (views/body-list-*.html)Two article-list layouts (10 items via :for): List 1 ends with 'Load More', List 2 with prev/next pager; both with right sidebar.
Grid 1 / Grid 2 (views/body-grid-*.html)Image grid of 20 figures, and a card grid of 10 articles with excerpt; both with pager and right sidebar.
Post 1 / Post 2 (views/body-post-*.html)Breadcrumb header, title/author meta, Markdown body (section.md), share icons, tags, author box, comments and a 'Leave a Reply' form; Post 2 puts the title and meta in a header with a cover image.
Author (views/body-author.html)User header (#user-header) and the author's article list with 'Load More'.
Contact (views/body-contact.html)Contact info, embedded Google Maps iframe and a 'Send Message' form.
404 (views/body-404.html)'404 Not Found' message for any unknown ?page value.
Right sidebar (views/right.html)Popular/Recent tabs (home only), About box with earth background, popular posts, topics, newsletter and tags.
Footer and mobile menu (views/bottom-footer.html, views/right-tab.html)Footer with a 6-image Instagram strip, copyright, social icons and back-to-top button; off-canvas #right-tab menu mirroring the nav.

Interactions


  • js/index.js: reads ?page= with location.href.$query("page") (default 'home') and computes nav.index/subIndex to highlight the active menu item.
  • event.rightTab (@click) toggles #right-tab display with a 300ms 'hide' class transition; event.scrollTop smooth-scrolls body to top.
  • next(): after 500ms removes the body ft class and, when section.md exists, mounts the viewer; a body scroll listener adds/removes 'show' on #top-nav, writes a scroll percent attribute (0-1000) for a progress indicator, and repositions #section-right as a sticky-like sidebar.
  • On load it fetches the PDMarkdownKit README.md from jsDelivr before creating the PD instance; on post pages it is rendered into section.md with PDMarkdownKit viewer (hashtag links to ?keyword=).

Dependencies



Styling


ItemValue
SCSS entrysass/index.scss
Output 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

index.scss holds reset, shared components and the #right-tab off-canvas keyframes, then imports top-nav, bottom-footer, header and the left (main column blocks: blog, lists, grids, post, comment, form, ads) and right (sidebar) partial groups. Color tokens (--color-dark-*, --color-light-*, --color-brand-*, --width-max, --bgcolor) are defined in an inline <style> in index.html.
  1. cd target/20230719
  2. npx sass sass/index.scss css/index.css --no-source-map || exit 1

Techniques


  • PDRenderKit template directives in plain HTML: :path (load partial HTML), :if / :else-if / :else routing, :for="e in item_10", @click, :index/:sub-index attribute binding, :bg-image.
  • new PD({ id, data, event, next }) instance bound to body#app; placeholder arrays item_2..item_20 drive repeated cards.
  • img.lazyload with data-src and span.svg[src] inline-SVG placeholders handled by PDRenderKit.
  • CSS custom properties for a color scale, multi-line clamp classes (.line.r1-.r8 from @for), keyframe slide-in menu, breakpoints 480/640/800/1024/1140px, flexbox layouts (no CSS grid), backdrop-filter, position: sticky in right/_index.

External Assets




中文