diff --git a/categories/marketing-and-video/rules-to-better-social-media-for-business.md b/categories/marketing-and-video/rules-to-better-social-media-for-business.md index 864d442b1a6..8eedbec802a 100644 --- a/categories/marketing-and-video/rules-to-better-social-media-for-business.md +++ b/categories/marketing-and-video/rules-to-better-social-media-for-business.md @@ -22,6 +22,7 @@ index: - create-friendly-short-urls - share-every-blog-post - post-using-social-media-management-tools +- google-maps-profile - do-your-presentations-promote-online-discussion - do-you-share-when-you-upgrade-an-application - weed-out-spammers diff --git a/categories/others/rules-to-better-offices.md b/categories/others/rules-to-better-offices.md index c84d6b9fb9f..999e9c4cd69 100644 --- a/categories/others/rules-to-better-offices.md +++ b/categories/others/rules-to-better-offices.md @@ -12,6 +12,7 @@ index: - bring-water-to-guests - cultural-exchange - desk-setups +- google-maps-profile --- diff --git a/categories/websites/rules-to-better-nextjs.md b/categories/websites/rules-to-better-nextjs.md index f035329d5d0..5f4f8ab30fc 100644 --- a/categories/websites/rules-to-better-nextjs.md +++ b/categories/websites/rules-to-better-nextjs.md @@ -6,6 +6,7 @@ uri: rules-to-better-nextjs index: - use-nextjs - the-best-package-manager-for-react +- fetch-data-nextjs - dynamically-load-components - use-typescript - do-you-use-these-useful-react-hooks diff --git a/categories/websites/rules-to-better-website-development-asp-net.md b/categories/websites/rules-to-better-website-development-asp-net.md index be04ee2392e..0c83e337300 100644 --- a/categories/websites/rules-to-better-website-development-asp-net.md +++ b/categories/websites/rules-to-better-website-development-asp-net.md @@ -40,6 +40,7 @@ index: - do-you-use-the-best-web-ui-libraries - use-windows-integrated-authentication - do-you-log-usage +- do-you-know-how-to-render-html-strings --- If you still need help, [visit our Web Application Development consulting page](https://www.ssw.com.au/ssw/Consulting/Web-Applications.aspx) and book in a consultant. diff --git a/rules/chatgpt-for-powerpoint/rule.md b/rules/chatgpt-for-powerpoint/rule.md index 75d730aaef4..3224779ca5f 100644 --- a/rules/chatgpt-for-powerpoint/rule.md +++ b/rules/chatgpt-for-powerpoint/rule.md @@ -19,12 +19,19 @@ Here’s a great prompt template for doing both! Feel free to play around with t 1. Select the **Smart Slides** plugin from the plugin store ::: greybox -You are an expert presentation writer and PowerPoint expert.\ -Write a PowerPoint presentation on {TOPIC}.\ -Each slide should have a title. \ -The content on each slide should be in bullet point format.\ -Don't give me advice on what to talk about on each slide, instead give me the actual content I can use.\ -1st, ask for the {TOPIC} +You are an expert presentation writer and PowerPoint expert. +Write a PowerPoint presentation on {TOPIC}. +Each slide should have a title. +The content on each slide should be in bullet point format. +Don't give me advice on what to talk about on each slide, instead give me the actual content I can use. + +Target audience is business stakeholders with some technical background. +Make sure the objective or pain that is being worked on is clear. +Make sure the recommendations and next steps are clear. +End with a Q&A. + +1st, ask for the {TOPIC} +Then, ask any relevant questions to get more context. \ ::: ::: good @@ -34,14 +41,22 @@ Figure: Prompt Template for creating a PowerPoint presentation ### If you're on GPT3 (or you want to add more custom specs) ::: greybox -You are an expert presentation writer and PowerPoint expert.\ -Write a PowerPoint presentation on {TOPIC}.\ -Each slide should have a title that this is colour: RGB(204, 65, 65). \ -The content on each slide should be in bullet point format.\ -Don't give me advice on what to talk about on each slide, instead give me the actual content I can use.\ -Then create a VBA script to create the PPT including slide titles and all content on each slide.\ -Do not save the PPT.\ -1st, ask for the {TOPIC} +You are an expert presentation writer and PowerPoint expert. \ +Write a PowerPoint presentation on {TOPIC}. \ +Each slide should have a title that this is colour: RGB(204, 65, 65). \ +The content on each slide should be in bullet point format. \ +Don't give me advice on what to talk about on each slide, instead give me the actual content I can use. + +Target audience is business stakeholders with some technical background. \ +Make sure the objective or pain that is being worked on is clear. \ +Make sure the recommendations and next steps are clear. \ +End with a Q&A. \ +\ +Then create a VBA script to create the PPT including slide titles and all content on each slide. \ +Do not save the PPT. \ +\ +1st, ask for the {TOPIC} +Then, ask any relevant questions to get more context. ::: ::: good diff --git a/rules/do-you-know-how-to-render-html-strings/rule.md b/rules/do-you-know-how-to-render-html-strings/rule.md index 81778062368..2ca3a879aa5 100644 --- a/rules/do-you-know-how-to-render-html-strings/rule.md +++ b/rules/do-you-know-how-to-render-html-strings/rule.md @@ -8,13 +8,13 @@ authors: created: 2023-07-28T07:23:06.201Z guid: 521afe97-18c3-43bc-8ada-f3782960b10f --- -To prevent cross-site scripting (XSS) attacks, HTML encoding is typically applied to restrain the browser from interpreting HTML strings as code. XSS attacks can occur when untrusted data is rendered on the browser without proper sanitization, thus potentially exposing the system to malicious scripts. +[Cross-site scripting (XSS) attacks](https://en.wikipedia.org/wiki/Cross-site_scripting) occur when untrusted data is rendered on the browser without proper sanitization, thus potentially exposing the system to malicious scripts. To prevent XSS attacks, HTML encoding is typically applied to prevent the browser from interpreting HTML strings as code. -However, this approach can sometimes cause confusion when an application requires to output raw HTML content that is already HTML encoded. +However, this approach can cause confusion when an application needs to output content that is already HTML encoded. -To solve this problem, the `IHtmlString` interface in .NET Core can be used to represent an HTML content that is pre-encoded and should not be encoded again. +To solve this problem, the [`IHtmlString`](https://learn.microsoft.com/en-us/dotnet/api/system.web.ihtmlstring) interface in .NET Core can be used to represent HTML content that is pre-encoded and should not be encoded again. This is to prevent double encoding, which can distort the original HTML content and cause it to display incorrectly on a web page. ```cs @@ -36,7 +36,7 @@ Figure: Good example - HTML tags using IHtmlContent have been treated as safe HT ::: ::: info -You should only use IHtmlString when you are sure that the string doesn't contain any potentially harmful script tags. When dealing with user-provided content or content from an untrusted source, always ensure to sanitize or validate the HTML before rendering it. +You should only use IHtmlString when you are sure that the string doesn't contain any potentially harmful script tags. When dealing with user-provided content or content from an untrusted source, always sanitize or validate the HTML before rendering it. ::: \ No newline at end of file diff --git a/rules/fetch-data-nextjs/rule.md b/rules/fetch-data-nextjs/rule.md new file mode 100644 index 00000000000..7775894ae1e --- /dev/null +++ b/rules/fetch-data-nextjs/rule.md @@ -0,0 +1,165 @@ +--- +type: rule +archivedreason: +title: Do you how to fetch data in Next.js? +guid: df355ce6-47ab-461d-9ddc-d3216dc433b5 +uri: fetch-data-nextjs +created: 2023-07-28T06:34:51Z +authors: +- title: Harry Ross + url: https://www.ssw.com.au/people/harry-ross +related: +- use-nextjs +--- + +Next.js is great, as it gives you the ability to run code on the server-side. This means there are now new ways to fetch data via the server to be passed to Next.js app. Next.js also handles the automatic splitting of code that runs on the server and the client, meaning you don't have to worry about bloating your JavaScript bundle when you add code that only runs on the server. + + + +## Server Side Fetching + +There are three primary ways with the Next.js Pages Router to fetch data on the server: + +1. Static site generation (SSG) with `getStaticProps` +2. Hybrid static site generation with incremental static regeneration (ISR) enabled in `getStaticProps` +3. Server-side data fetching with `getServerSideProps` + +### getStaticProps + +We can develop a staticly generated site in Next.js by using `getStaticProps`. Having a statically generated site is great for SEO, as it makes it much easier for Google to index your site compared to a site with complex JavaScript logic, which is harder for web crawlers to understand. Next.js will run the code inside the `getStaticProps` method when you run `npm build`, and generate associated static HTML or JSON data. + +For example, using dynamic routing we can create a static page to show post data based on the URL: + +```tsx +// pages/[slug].tsx + +export const getStaticProps = ({ params }) => { + const id = params.slug; + const res = await fetch(`https://jsonplaceholder.typicode.com/posts/${id}`); + const post = await res.json(); + + return { + props: { post } + }; +} + +export default function Page(props) { + return ( +
{props.post.body}
+{post.body}
+