Html

Add Contact Form in Hugo Site

Create a lambda function to send the contact message Setup SES and verify sender email address Create an IAM role for lambda with policy details below { "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "ses:SendEmail", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": "*" } ] } Create the lambda function const aws = require("aws-sdk"); const ses = new aws.SES({ region: "ap-southeast-2" }); exports.handler = async function (event) { console.log('EVENT: ', event) // Extract the properties from the event body try { const { senderEmail, senderName, message } = JSON.

Enable Raw Html in Hugo

Enable support of raw html Hugo disables html element rendering by default, we need to enable it. Enable for an entire site Add below in the config file [markup.goldmark.renderer] unsafe= true Enable for a single page Create layout/shortcodes/unsafe.html with the following content: {{ .Inner }} In the markdown page, use it like this, {{< unsafe >}} <ul> <li>First item</li> <li>Second item <li>Third item</li> </ul> {{< /unsafe >}} above will be rendered like this, First item Second item Third item Reference How To Escape Shortcode In Hugo Template Configure Markup Create Your Own Shortcodes Enable unsafe=true for a single page

How to Find the Size of LocalStorage

Sometimes, an error occurred (Failed to execute ‘setItem’ on ‘Storage’: Setting the value of ‘xxxxx’ exceeded the quota Vue) when adding data to local storage due to storage being full, but not sure which one uses more and how much it is, Found below code which is very helpful. one line version var _lsTotal=0,_xLen,_x;for(_x in localStorage){ if(!localStorage.hasOwnProperty(_x)){continue;} _xLen= ((localStorage[_x].length + _x.length)* 2);_lsTotal+=_xLen; console.log(_x.substr(0,50)+" = "+ (_xLen/1024).toFixed(2)+" KB")};console.log("Total = " + (_lsTotal / 1024).