From c00d90d08601655101477c122661b2650808e22e Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 16:08:18 +0100 Subject: [PATCH] feat(ssg): added itemprop headline and subheadline --- content/post.md | 126 +++++++++++++++++++++++++++++++++++++ src/modules/html.rs | 4 +- src/utilities/directory.rs | 12 +++- template/post.html | 105 ++++++++++++------------------- 4 files changed, 178 insertions(+), 69 deletions(-) create mode 100644 content/post.md diff --git a/content/post.md b/content/post.md new file mode 100644 index 00000000..a27c6ab6 --- /dev/null +++ b/content/post.md @@ -0,0 +1,126 @@ +--- + +# Front Matter (YAML) + +author: "Jane Doe" ## The author of the page. (max 64 characters) +banner_alt: "Green And Black Tiled Wall" ## The banner alt of the site. +banner_height: "398" ## The banner height of the site. +banner_width: "1440" ## The banner width of the site. +banner: "https://kura.pro/unsplash/images/banners/ryunosuke-kikuno-G5hYMUoJQf8-unsplash.jpg" ## The banner of the site. +cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. +charset: "utf-8" ## The charset of the site. (default: utf-8) +cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) +copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. +date: "July 12, 2023" +description: "Everything You Need to Build a Stunning Website." ## The description of the site. (max 160 characters) +download: "" ## The download url for the product. +format-detection: "telephone=no" ## The format detection of the site. +hreflang: "en" ## The hreflang of the site. (default: en-gb) +icon: "https://kura.pro/kaishi/images/logos/kaishi.svg" ## The icon of the site in SVG format. +id: "https://kaishi.one" ## The id of the site. +image_alt: "Logo of Kaishi, a starter template for static sites" ## The image alt of the site. +image_height: "630" ## The image height of the site. +image_width: "1200" ## The image width of the site. +image: "https://kura.pro/kaishi/images/banners/banner-kaishi.webp" ## The main image of the site in SVG format. +keywords: "kaishi starter templates, shokunin static site generator, static site generator, starter templates, bootstrap, bootstrap css, bootstrap javascript, content security policy, open graph meta tags, responsive navigation bar, schema.org meta tags" ## The keywords of the site. (max 160 characters) +language: "en-GB" ## The language of the site. (default: en-GB) +layout: "post" ## The layout of the site. +locale: "en_GB" ## The locale of the site. +logo_alt: "Logo of Kaishi, a starter template for static sites" ## The logo alt of the site. +logo_height: "33" ## The logo height of the site. +logo_width: "100" ## The logo width of the site. +logo: "https://kura.pro/kaishi/images/banners/banner-kaishi.webp" ## The logo of the site in SVG format. +name: "Kaishi" ## The name of the website. (max 64 characters) +permalink: "https://kaishi.one/features" ## The url of the site. +rating: "general" ## The rating of the site. +referrer: "no-referrer" ## The referrer of the site. +revisit-after: "7 days" ## The revisit after of the site. +robots: "index, follow" ## The robots of the site. +short_name: "kaishi" ## The short name of the site. (max 12 characters) +subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) +tags: "kaishi starter templates, shokunin static site generator, static site generator, starter templates, bootstrap, bootstrap css, bootstrap javascript, content security policy, open graph meta tags, responsive navigation bar, schema.org meta tags" ## The tags of the site. (max 160 characters) +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. +title: "Features" ## The title of the page. (max 64 characters) +url: "https://kaishi.one" ## The url of the site. +viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. + +# RSS - The RSS feed front matter (YAML). +atom_link: https://kaishi.one/rss.xml +category: "Technology" +docs: https://validator.w3.org/feed/docs/rss2.html +generator: "Shokunin 🦀 (version 0.0.17)" +item_description: RSS feed for the site +item_guid: https://kaishi.one/rss.xml +item_link: https://kaishi.one/rss.xml +item_pub_date: "Thu, 12 Jul 2023 15:15:15 GMT" +item_title: "RSS" +last_build_date: "Thu, 12 Jul 2023 15:15:15 GMT" +managing_editor: jane.doe@kaishi.one +pub_date: "Thu, 12 Jul 2023 15:15:15 GMT" +ttl: "60" +type: "website" +webmaster: jane.doe@kaishi.one + +# Apple - The Apple front matter (YAML). +apple_mobile_web_app_orientations: "portrait" ## The Apple mobile web app orientations of the page. +apple_touch_icon_sizes: "192x192" ## The Apple touch icon sizes of the page. +apple-mobile-web-app-capable: "yes" ## The Apple mobile web app capable of the page. +apple-mobile-web-app-status-bar-inset: "black" ## The Apple mobile web app status bar inset of the page. +apple-mobile-web-app-status-bar-style: "black-translucent" ## The Apple mobile web app status bar style of the page. +apple-mobile-web-app-title: "Kaishi" ## The Apple mobile web app title of the page. +apple-touch-fullscreen: "yes" ## The Apple touch fullscreen of the page. + +# MS Application - The MS Application front matter (YAML). + +msapplication-navbutton-color: "rgb(143, 250, 111)" + +# Twitter Card - The Twitter Card front matter (YAML). + +## twitter_card - The Twitter Card type of the page. +twitter_card: "summary" +## twitter_creator - The Twitter Card creator of the page. +twitter_creator: "janedoe" +## twitter_description - The Twitter Card description of the page. +twitter_description: "Everything You Need to Build a Stunning Website." +## twitter_image - The Twitter Card image of the page. +twitter_image: "https://kura.pro/kaishi/images/logos/kaishi.svg" +## twitter_image:alt - The Twitter Card image alt of the page. +twitter_image_alt: "Logo of Kaishi, a starter template for static sites" +## twitter_site - The Twitter Card site of the page. +twitter_site: "janedoe" +## twitter_title - The Twitter Card title of the page. +twitter_title: "Kaishi, a Shokunin Static Site Generator Starter Template" +## twitter_url - The Twitter Card url of the page. +twitter_url: "https://kaishi.one" + +# Humans.txt - The Humans.txt front matter (YAML). +author_website: "https://kura.pro" ## The author website of the page. +author_twitter: "@wwdseb" ## The author twitter of the page. +author_location: "London, UK" ## The author location of the page. +thanks: "Thanks for reading!" ## The thanks of the page. +site_last_updated: "2023-07-05" ## The last updated of the site. +site_standards: "HTML5, CSS3, RSS, Atom, JSON, XML, YAML, Markdown, TOML" ## The standards of the site. +site_components: "Kaishi, Kaishi Builder, Kaishi CLI, Kaishi Templates, Kaishi Themes" ## The components of the site. +site_software: "Shokunin, Rust" ## The software of the site. + +--- + +![A very tall building that has a lot of holes in it](https://kura.pro/stock/images/banners/johannes-plenio-6XUA5KQ9-1k.webp).class=\"img-fluid clearfix\" + +## Starter Templates + +

+ by + +

+

+ +All the starter templates, whether pages or websites are built from scratch +using the same principles and features. This means that you can easily mix and +match them together to create your own custom layouts and content. + +Get started with Shokunin using any of our Starter Templates for building +your website or web application. diff --git a/src/modules/html.rs b/src/modules/html.rs index 31a85193..3874e862 100644 --- a/src/modules/html.rs +++ b/src/modules/html.rs @@ -41,7 +41,7 @@ use crate::utilities::directory::{ /// let html = generate_html(content, title, description, None); /// let html_str = html.unwrap_or_else(|e| panic!("Error: {:?}", e)); /// -/// assert_eq!(html_str, "

My Page

This is a test page

Hello, world!

\n

This is a test.

\n"); +/// assert_eq!(html_str, "

My Page

This is a test page

Hello, world!

\n

This is a test.

\n"); /// /// ``` // @@ -126,7 +126,7 @@ fn generate_header(title: &str, id_regex: &Regex) -> String { if title.is_empty() { return String::new(); } - let header_str = format!("

{}

", title); + let header_str = format!("

{}

", title); format_header_with_id_class(&header_str, id_regex) } diff --git a/src/utilities/directory.rs b/src/utilities/directory.rs index 41fe372d..e61142e7 100644 --- a/src/utilities/directory.rs +++ b/src/utilities/directory.rs @@ -278,11 +278,17 @@ pub fn format_header_with_id_class( if !id_attribute_added && (c == ' ' || c == '>') { formatted_header_str.push_str(&format!( - " id=\"{}-{}\" tabindex=\"0\"", + " id=\"{}-{}\" tabindex=\"0\" {}", header_type, - id_regex - .replace_all(&first_word, "-"), + id_regex.replace_all(&first_word, "-"), + if header_type == "h1" { + "itemprop=\"headline\"" + } else { + "itemprop=\"subheadline\"" + } )); + + print!("header_type={:?}", header_type); id_attribute_added = true; } diff --git a/template/post.html b/template/post.html index 3b61d4eb..7e140616 100644 --- a/template/post.html +++ b/template/post.html @@ -24,13 +24,7 @@ - + @@ -42,20 +36,15 @@ + + + - - - - + - @@ -155,21 +144,20 @@
@@ -178,14 +166,8 @@
-

- by - -

-

-

Tags: {{tags}}

+ + {{content}}
@@ -204,36 +186,31 @@ Terms of Use - - +