Skip to content

Commit

Permalink
chore: linting and final steals
Browse files Browse the repository at this point in the history
  • Loading branch information
ViorelMocanu committed Aug 12, 2024
1 parent 15b5625 commit e566ed2
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
import { Taxonomy, db, eq } from 'astro:db';
import Avatar from '@components/Avatar.astro';
import { type BreadcrumbItem } from '@config';
import Breadcrumbs from '@components/Breadcrumbs.astro';
import Avatar from '@components/Avatar.astro';
import { highlightUrl } from '@utils/urlHelpers';
export interface Props {
breadcrumbArray?: BreadcrumbItem[] | undefined;
Expand Down
63 changes: 54 additions & 9 deletions src/components/Pagination.astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,68 @@ const pagePrototype = next ? next.replace(`/${currentPage + 1}`, '') : prev ? pr
&laquo; Precedenta<span class="HideLowRes"> Pagină</span>
</a>
) : (
<span class="PaginationUnavailable">&laquo; Pagina Precedentă</span>
<span class="PaginationUnavailable">Ești pe prima pagină</span>
)}
</li>
{paginationList.map((num) => (
<li class:list={num == currentPage ? ['PaginationItem', 'PaginationCurrent'] : ['PaginationItem']}>
<a class="PaginationLink" href={`${pagePrototype}/${num == 1 ? '' : num}`} title={`Mergi la pagina ${num} din ${lastPage}`}>
{num}
</a>
</li>
))}
{lastPage > 15 && (currentPage < 4 || currentPage > lastPage - 3) && (
<>
{paginationList.slice(0, 4).map((num) => (
<li class:list={num == currentPage ? ['PaginationItem', 'PaginationCurrent'] : ['PaginationItem']}>
<a class="PaginationLink" href={`${pagePrototype}/${num == 1 ? '' : num}`} title={`Mergi la pagina ${num} din ${lastPage}`}>
{num}
</a>
</li>
))}
<li class="PaginationItem PaginationEllipsis">
<span class="SpacerSymbol">...</span>
</li>
{paginationList.slice(-4).map((num) => (
<li class:list={num == currentPage ? ['PaginationItem', 'PaginationCurrent'] : ['PaginationItem']}>
<a class="PaginationLink" href={`${pagePrototype}/${num}`} title={`Mergi la pagina ${num} din ${lastPage}`}>
{num}
</a>
</li>
))}
</>
)}
{lastPage > 15 && currentPage >= 4 && currentPage <= lastPage - 3 && (
<>
{paginationList.slice(0, 2).map((num) => (
<li class:list={['PaginationItem']}>
<a class="PaginationLink" href={`${pagePrototype}/${num == 1 ? '' : num}`} title={`Mergi la pagina ${num} din ${lastPage}`}>
{num}
</a>
</li>
))}
<li class="PaginationItem PaginationEllipsis">
<span class="SpacerSymbol">...</span>
</li>
{paginationList.slice(currentPage - 2, currentPage + 1).map((num) => (
<li class:list={num == currentPage ? ['PaginationItem', 'PaginationCurrent'] : ['PaginationItem']}>
<a class="PaginationLink" href={`${pagePrototype}/${num}`} title={`Mergi la pagina ${num} din ${lastPage}`}>
{num}
</a>
</li>
))}
<li class="PaginationItem PaginationEllipsis">
<span class="SpacerSymbol">...</span>
</li>
{paginationList.slice(-2).map((num) => (
<li class:list={['PaginationItem']}>
<a class="PaginationLink" href={`${pagePrototype}/${num}`} title={`Mergi la pagina ${num} din ${lastPage}`}>
{num}
</a>
</li>
))}
</>
)}
<li class="PaginationItem PaginationNext">
{currentPage < lastPage ? (
<a class="PaginationLink" href={next} title="Mergi la pagina următoare">
Următoarea<span class="HideLowRes"> Pagină</span> &raquo;
</a>
) : (
<span class="PaginationUnavailable">Pagina Următoare &raquo;</span>
<span class="PaginationUnavailable">Ești pe ultima pagină</span>
)}
</li>
</ol>
Expand Down
15 changes: 12 additions & 3 deletions src/components/ResourceList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export interface Props {
};
};
pageTitle?: string | undefined;
error?: Error | null;
}
const { resources, page, pageTitle } = Astro.props satisfies Props;
const { resources, page, pageTitle, error } = Astro.props satisfies Props;
let r = resources as unknown as ExtendedResource[];
const allTags = await getCollection('tags');
Expand Down Expand Up @@ -164,7 +165,7 @@ if (resources) {
</span>
<span class="InfoItemText">Timp necesar</span>
</div>
<strong class="InfoItemValue">{resource.data.requiredTime}h</strong>
<strong class="InfoItemValue">{/*resource.requiredTime || '? '*/}h</strong>
</li>
)}
</ul>
Expand All @@ -173,7 +174,7 @@ if (resources) {
<ResourceLocationList res={resource} />
{resource.data.description && (
<p class="ResourceP" transition:name={`${resource.slug} description`}>
{resource.data.description}
{/*resource.description && resource.description.length > 160 ? resource.description?.substring(0, 160) : resource.description*/}
</p>
)}
{resource.data.tags && <ResourceTagList taglist={resource.tagData} resslug={resource.slug} />}
Expand All @@ -189,5 +190,13 @@ if (resources) {
)
}

{
error && (
<Message title="Am întâmpinat o problemă cu baza de date." type="error">
<HelpfulLinks />
</Message>
)
}

{page && <Pagination currentPage={page.currentPage} lastPage={page.lastPage} next={page.url.next} prev={page.url.prev} boxHeader={true} pageTitle={pageTitle} />}
</div>
3 changes: 3 additions & 0 deletions src/components/ResourceLocationList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const shouldRenderSubcategoriesFromCat = subcategories && categories && resource
---

<ul class="ResourceLocationList" transition:name={`${res?.slug} location`}>
<li class="DesktopOnlyBlock">
<span class="ResourceLocationText">Găsești resursa în:</span>
</li>
{
resourceSection && (
<li class="ResourceLocationItem Classification">
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { CollectionEntry, CollectionKey } from 'astro:content';
const PUBLIC_APP_ENV = import.meta.env.PUBLIC_APP_ENV;
const PUBLIC_APP_DEBUG = import.meta.env.PUBLIC_APP_DEBUG;

let u: string = import.meta.env.BASE_URL;
let u: string = import.meta.env.BASE_URL || import.meta.env.VERCEL_URL;
if (PUBLIC_APP_ENV === 'local' || PUBLIC_APP_ENV === 'development') {
// we are in a local or development environment
u = import.meta.env.PUBLIC_APP_URL_LOCAL;
Expand All @@ -22,7 +22,7 @@ const PUBLIC_APP_URL = u;
// @TODO: make variables below asynchronous

// My static config variables
export const ENV = PUBLIC_APP_ENV;
export const ENV = PUBLIC_APP_ENV || import.meta.env.VERCEL_ENV;
export const DEBUG = PUBLIC_APP_DEBUG;
export const URL = PUBLIC_APP_URL;
export const SITE_TITLE = 'Centralizator de resurse digitale gratuite pentru învățare';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
import { Taxonomy, db, eq } from 'astro:db';
import { DEFAULT_DESCRIPTION, DEFAULT_MENULABEL, DEFAULT_TITLE, DEFAULT_URL, PAGE_SIZE, resourceTypeIcon } from '@config';
import { taxonomiesFlat } from '@utils/getSortedItems';
import { Taxonomy, db, eq } from 'astro:db';
import CommentList from '@components/CommentList.astro';
import Layout from '@layouts/Layout.astro';
import ResourceFilter from '@components/ResourceFilter.astro';
// import ResourceList from '@components/ResourceList.astro';
import ResourceTOC from '@components/ResourceTOC.astro';
import { taxonomiesFlat } from '@utils/getSortedItems';
// @TODO: paginate this according to the number of resources on each taxonomy
export async function getStaticPaths() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { Tweet, Vimeo, YouTube } from 'astro-embed';
import { SocialShare } from 'astro-social-share';
import { Content as Readme } from '../../README.md';
import { SocialShare } from 'astro-social-share';
import Layout from '@layouts/Layout.astro';
import ResourceTOC from '@components/ResourceTOC.astro';
//import ResponsiveImage from '@components/ResponsiveImage.astro';
Expand Down

0 comments on commit e566ed2

Please sign in to comment.