File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public IActionResult Index(string key)
4141
4242 ViewBag . PageTitle = siteMapping . IndentLevel is 0 ? siteMapping . ChapterTitle + " " + siteMapping . RawHeading : siteMapping . RawHeading ;
4343 ViewBag . NextPage = FlipPage ( siteMapping ! . ChapterNumber , siteMapping . PageNumber , true ) ;
44+ ViewBag . CurrentPageKey = siteMapping . Key ;
4445 ViewBag . PreviousPage = FlipPage ( siteMapping . ChapterNumber , siteMapping . PageNumber , false ) ;
4546 ViewBag . HeadContents = headHtml ;
4647 ViewBag . Contents = html ;
Original file line number Diff line number Diff line change 123123 <a v-if =" chapterParentPage" :href =" chapterParentPage.href" class =" menu-chapter-title text-light" >
124124 <span v-cloak >{{ chapterParentPage .title }} </span >
125125 </a >
126+ <div class =" menu-chapter-title text-light" >
127+ {{ currentPageCount }} / {{ totalPageCount }}
128+ </div >
126129
127130 <div class =" d-flex align-items-center" >
128131 <div class =" border-end pe-3 d-none d-md-block" >
292295 Title = $" Chapter {x.Key}: {x.First().ChapterTitle}" ,
293296 Items = GetItems (x, 1 )
294297 });
298+ var groupedTocData = _SiteMappings .SiteMappings .GroupBy (x => x .ChapterNumber ).OrderBy (x => x .Key );
299+ int currentPageCount = 0 ;
300+ int overallCount = 0 ;
301+ bool currentPageFound = false ;
302+ foreach (IGrouping< int, SiteMapping> group in groupedTocData)
303+ {
304+ var orderedGroup = group .OrderBy (x => x .PageNumber );
305+ foreach (SiteMapping siteMapping in orderedGroup)
306+ {
307+ if (siteMapping .Key == ViewBag .CurrentPageKey )
308+ {
309+ currentPageFound = true ;
310+ }
311+ if (! currentPageFound)
312+ {
313+ currentPageCount++ ;
314+ }
315+ overallCount++ ;
316+ }
317+ }
295318 }
296-
319+ CURRENT_PAGE_COUNT = @Json .Serialize (currentPageCount)
320+ TOTAL_PAGE_COUNT = @Json .Serialize (overallCount)
297321 PREVIOUS_PAGE = @Json .Serialize (ViewBag .PreviousPage )
298322 NEXT_PAGE = @Json .Serialize (ViewBag .NextPage )
299323 TOC_DATA = @Json .Serialize (tocData)
343367 </li >
344368 </template >
345369 <script src =" ~/js/site.js" type =" module" asp-append-version =" true" ></script >
346-
347370</body >
348371</html >
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { useWindowSize } from "vue-window-size";
1818 * @prop {TocItem[] } [items]
1919 */
2020/** @type {TocItem } */
21+ debugger ;
2122const tocData = markRaw ( TOC_DATA ) ;
2223
2324//Add new content or features here:
@@ -194,6 +195,9 @@ const app = createApp({
194195
195196 const currentPage = findCurrentPage ( [ ] , tocData ) ?? [ ] ;
196197
198+ const currentPageCount = CURRENT_PAGE_COUNT ;
199+ const totalPageCount = TOTAL_PAGE_COUNT ;
200+
197201 const chapterParentPage = currentPage . find ( ( parent ) => parent . level === 0 ) ;
198202
199203 const sectionTitle = ref ( currentPage ?. [ 0 ] ?. title || "Essential C#" ) ;
@@ -311,6 +315,8 @@ const app = createApp({
311315 tocData,
312316 expandedTocs,
313317 currentPage,
318+ currentPageCount,
319+ totalPageCount,
314320 chapterParentPage,
315321
316322 searchQuery,
You can’t perform that action at this time.
0 commit comments