-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/authors-articles-viewcount/draft/0 (#2309)
* build(scores-lib): update to 4.1.1 * feat(endpoint): update [1] ──── Update 'endpoint/author.article.ts' for a new logic for increment of target article viewcount. Logic available in 'scores-lib:4.1.1'. * feat(store,types): update [1] ──── Update 'store/session.ts' for new data value of 'userAgent' that contains incoming (a.k.a original) user data. [2] ──── Update respective 'types.session.d.ts' values. * feat(utils,layout): update [1] ──── Update 'utils/device.ts' for new logic 'isUserAgentBot(..)' for identifying target user-agent of type bot/crawler. [2] ──── Update 'layout.server.ts' + 'layout.svelte' for update in the use of the 'user-agent' cascading data and value set. * feat(author): update [1] ──── Initialize new '_helpers.ts' for the 'page/author' path, containing respective related logic used in target webpage. [2] ──── Update respective 'page/author' path 'Layout.svelte' for use of the new '_helpers.ts' logic. * fix(author): update [1] ──── Update 'page/author' Layout.svelte for removal of unwanted 'console.log(..)' entry.
- Loading branch information
Showing
10 changed files
with
224 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/lib/components/section/authors/page/author/_helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// ╭──────────────────────────────────────────────────────────────────────────────────╮ | ||
// │ 📌 High Order Overview │ | ||
// ┣──────────────────────────────────────────────────────────────────────────────────┫ | ||
// │ ➤ Code Format // V.8.0 │ | ||
// │ ➤ Status // 🔒 LOCKED │ | ||
// │ ➤ Author(s) // @migbash │ | ||
// │ ➤ Maintainer(s) // @migbash │ | ||
// │ ➤ Created on // 2025-01-19 │ | ||
// ┣──────────────────────────────────────────────────────────────────────────────────┫ | ||
// │ 📝 Description │ | ||
// ┣──────────────────────────────────────────────────────────────────────────────────┫ | ||
// │ BETARENA (Module) | ||
// │ |: <insert-module-summary-here> | ||
// ╰──────────────────────────────────────────────────────────────────────────────────╯ | ||
|
||
// #region ➤ 📦 Package Imports | ||
|
||
import { browser } from '$app/environment'; | ||
|
||
import { get } from '$lib/api/utils.js'; | ||
import session from '$lib/store/session.js'; | ||
|
||
import type { Page } from '@sveltejs/kit'; | ||
|
||
// #endregion ➤ 📦 Package Imports | ||
|
||
/** | ||
* @author | ||
* @migbash | ||
* @description | ||
* 📝 Data Response | ||
* @returns { void } | ||
*/ | ||
export function startArticleViewIncrement | ||
( | ||
): void | ||
{ | ||
// [🐞] | ||
// console.log | ||
// ( | ||
// '🚏 checkpoint ➤ startArticleViewIncrement(..)' | ||
// ); | ||
|
||
window.addEventListener | ||
( | ||
'scroll', | ||
checkArticleViewIncrement | ||
); | ||
|
||
return; | ||
} | ||
|
||
/** | ||
* @author | ||
* @migbash | ||
* @description | ||
* 📝 Data Response | ||
* @return { Promise < void > } | ||
*/ | ||
export async function checkArticleViewIncrement | ||
( | ||
): Promise < void > | ||
{ | ||
if (!browser) return; | ||
|
||
// [🐞] | ||
// console.log | ||
// ( | ||
// '🚏 checkpoint ➤ checkArticleView(..)' | ||
// ); | ||
|
||
const | ||
/** | ||
* @description | ||
* 📣 `articleId` from `sessionStore`. | ||
*/ | ||
articleId = (session.extract<Page>('page'))?.data.dataArticle?.article?.id | ||
; | ||
|
||
// [🐞] | ||
// console.log('articleId', articleId); | ||
|
||
if (!articleId) return; | ||
|
||
window.removeEventListener | ||
( | ||
'scroll', | ||
checkArticleViewIncrement | ||
); | ||
|
||
await get | ||
( | ||
`/api/data/author/article?articleId=${articleId}` | ||
); | ||
|
||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters