Beginning Azure Static Web Apps 2E – Stacy Cashmore

📥
Total Downloads: 10
 - Unknown book cover

Add the code from Listing 8-12 at the end of the BlogpostSummaries.razor file. Listing 8-12. OnInitializedAsync Code @code { protected override async Task OnInitializedAsync() { await service.LoadBlogpostSummaries(); } } This function is called, as we can see from the name, when the page is initialized. It will fire off a call to the service to fetch the blogposts so that we can use them on the page. While we are waiting for them though, we need to show our users information to let them know something is happening in the background.

12. Add the code from Listing 8-13 after the h1 tags. Listing 8-13. Loading Information for Users @if (service.Summaries is null) {

Loading…

} Think back to our service. The list of blogpost summaries is not set until we get the data from the API. So as long as it remains null, we know we are loading. When it has loaded, we will have a value for summaries, even if it is an empty list – so we can make a distinction between the two.

For now, we will just worry about showing the blogposts when they have loaded. Chapter 8 Displaying Data 13. Add the code from Listing 8-14 underneath the code from Listing 8-13. Listing 8-14. Displaying the Titles of the Blogposts else { foreach (var blogpostSummary in ➥ service.Summaries.OrderByDescending(bps => bps.PublishedDate)) {

@blogpostSummary.Title

} } This code will run through all the blogpost summaries and put the title on the screen, newest first.

Notice that we don’t need to know when the blogpost summary has a value; Blazor handles all of that automatically for us, so the loading text will disappear and be replaced with the titles. Run the app, start the application in Visual Studio and then start the SWA CLI, and navigate to http://localhost:4280/blogposts to see the list of blogpost titles. Display the Whole Summary That’s a great start, but we want to show a bit more information than that and use it to display the whole post.

To do this, we are going to add to the screen: • The summary of the blogpost • The list of tags for the blogpost • Make it a link to navigate to the full blogpost The summary of our blogpost is Markdown, which is not what we want to display on the screen to the user; we need to convert it to HTML so that the headers, links, etc., show up as we intend them to.

This isn’t something that we are going to make ourselves; we are going to use a well-known tool instead: Markdig.

Copyright © 2026 by Stacy Cashmore This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Smriti Srivastava Editorial Project Manager: Jessica Vakili Cover image from Pixabay.com Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004.

Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected]; for reprint, paperback, or audio rights, please e-mail [email protected]. Apress titles may be purchased in bulk for academic, corporate, or promotional use.

eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub https://github.com/Apress/Beginning-Azure-Static-Web-Apps-Second-Edition. For more detailed information, please visit https://www.apress.com/gp/services/source-code.

This is a short excerpt from the opening of “” by Unknown, quoted for review and introduction purposes. All rights belong to the copyright holders.

Book Information

  • Unique ID: 69121a6a13d6a67b
  • File Extension: .pdf
  • File Size: 18,810,244 bytes (17.939 MB)
  • Title:
  • Author: Unknown
  • ISBN: 9798868813207, 9798868813214
  • Pages: 412
  • Language: English (en)

Reading & Word Statistics

  • Estimated Reading Time: 368.23 minutes
  • Total Words: 73,645
  • Total Characters: 493,179
  • Average Words per Page: 178.75
  • Average Characters per Page: 1197.04

Most Frequent Words

azure (632), chapter (621), application (521), code (518), listing (492), figure (478), static (397), web (356), need (349), see (344), app (342), blogpost (337), using (333), github (330), page (322), file (314), add (306), api (297), new (296), data (269), use (260), client (256), create (225), click (222), blogposts (221), now (216), function (212), authentication (211), creating (192), project (190), set (181), swa (179), run (178), also (174), going (169), name (166), resource (165), make (164), open (164), https (162), folder (154), cli (154), repository (151), custom (151), visual (147), studio (146), created (140), environment (137), access (131), used (130), available (129), get (128), request (128), book (125), domain (125), look (123), start (119), workflow (115), functions (114), change (113), one (113), com (112), changes (111), first (111), return (111), class (109), tags (109), user (108), screen (107), running (106), http (105), razor (105), information (104), command (104), microsoft (103), list (102), string (98), configuration (96), builder (93), pull (89), author (87), production (87), next (87), public (87), blazor (86), files (85), want (85), browser (84), setting (83), json (82), check (81), time (80), itself (80), private (80), we’ll (79), button (79), deploy (78), end (78), select (78), div (78).

PDF Download

📖 Read Online (3D Flipbook)

You can start reading by flipping the pages.

Or download it as a PDF: