Skip to content

Commit

Permalink
feat: Make the Article List an Custom Component, remove other fallback
Browse files Browse the repository at this point in the history
That was due to the fact that it broke any installation from NPM (not PNPM). I had to sacrifce it)
  • Loading branch information
GabsEdits committed May 25, 2024
1 parent 6a7e2ef commit f3832b4
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 189 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/weekly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Update CHANGELOG.md
run: |
today=$(date +'%Y-%m-%d')
sed -i "s/unreleased/$today/" CHANGELOG.md
sed -i "s/upcoming/$today/" CHANGELOG.md
- name: Commit changes
run: |
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 2.0.0 (upcoming)

### Breaking Changes

- Make the Blog List an custom component due to it's complexity
- This will allow for more customization and easier maintenance
- **Will require extra effort to implement it again** (example provided in the documentation and package file under `custom/BlogListExample.txt`)

- Remove all fallbacks for the old names
- `blog-*` -> `article-*`
- `no-blog` -> `minimal`
- `simple` -> `minimal` (for the layout)

## 1.6.0 (2024-05-25)

### Feature(s)
Expand Down
12 changes: 3 additions & 9 deletions Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,18 @@ const { site, frontmatter, page } = useData();
<h1>{{ site.title }}</h1>
</div>
<div
v-if="frontmatter.layout === 'article' || frontmatter.layout === 'blog'"
v-if="frontmatter.layout === 'article'"
>
<ArticleHead />
</div>
<NotFound v-if="page.isNotFound" />
<div v-else :class="frontmatter.pageClass">
<Content />
</div>
<ArticleList
v-if="
frontmatter.layout == 'article-list' ||
frontmatter.layout == 'blog-list'
"
/>
<HelpfulLayout
v-if="frontmatter.layout == 'helpful' || frontmatter.layout == 'simple'"
v-if="frontmatter.layout == 'helpful'"
/>
<div v-if="frontmatter.layout == 'article' || frontmatter.layout == 'blog'">
<div v-if="frontmatter.layout == 'article'">
<ArticleFooter />
</div>
</main>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ Now that Aplós is an NPM Package, a release cycle is required. There is a new v

Aplós uses [Semantic Versioning](https://semver.org/), so you can understand the changes by looking at the version number (using the `major.minor.patch` format).

It might be possible that the pre-release versions start as a patch version and end up becoming a minor version (e.g: `2.1.3-1` -> `2.2.0-2`).
It might be possible that the pre-release versions start as a patch version and end up becoming a minor/major version (e.g: `2.1.3-1` -> `2.2.0-0`) if there are significant changes or breaking changes.

### 'Next' Tag

The 'next' tag is an nightly version of Aplós, used to test the next version before it is released. Use the 'next' tag if you want to test the next version of Aplós.
The 'next' tag is version of Aplós, used to test the next version before it is released. Use the 'next' tag if you want to test the next version of Aplós.

You can install the 'next' tag with the following command:

Expand Down
92 changes: 92 additions & 0 deletions custom/ArticleList.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.article-list {
margin: 0 auto;
}

.post-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
gap: 15px;

@media screen and (max-width: 600px) {
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.post {
transition: transform 0.3s ease;
border-radius: 8px;
background-color: var(--color-background-second);
padding: 20px;

&:first-child {
background-color: var(--color-background-mute);
}

h3 {
margin: 0 !important;
font-size: 24px;

a {
font-weight: 900;
}
}

p {
margin: 0;
color: var(--color-text);
font-weight: 500;
text-decoration: none;
}

.date {
font-feature-settings: "zero", "tnum", "cv03", "cv02";
margin: 5px 0;
color: var(--color-text-secondary);
font-weight: 600;
font-size: 0.9rem;
}
}
}

.filter-tags {
margin-bottom: 20px;

#all-tags {
background-color: var(--color-accent-alpha);
color: var(--color-accent);
}

button {
transition: all 0.3s ease;
cursor: pointer;
margin-right: 10px;
margin-bottom: 3px;
border-radius: 20px;
background-color: var(--color-background-second);
padding: 0.25rem 0.75rem;
font-size: 0.8rem;

&:hover {
background-color: var(--color-accent-alpha);
color: var(--color-accent);
}

&:active {
transform: scale(0.8);
}
}
}

.tags {
margin-top: 10px;
text-align: right;

span {
margin-right: 5px;
border-radius: 20px;
background-color: var(--color-background);
padding: 0.15rem 0.45rem;
color: var(--color-text-accent);
font-weight: 500;
font-size: 12px;
}
}
66 changes: 66 additions & 0 deletions custom/ArticleListExample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<div class="article-list">
<noscript>
<small>To use the filter you need JavaScript to be enabled.</small>
</noscript>
<div class="filter-tags">
<button @click="filterPosts('')" id="all-tags">All</button>
<button v-for="tag in uniqueTags" :key="tag" @click="filterPosts(tag)">
<span class="hashtag">#</span>{{ tag }}
</button>
</div>
<div class="post-container">
<article v-for="post in filteredPosts" :key="post.title" class="post">
<h3>
<a
:href="`posts/${post.title
.toLowerCase()
.replace(/\s+/g, '-')}.html`"
>{{ post.title }}</a
>
</h3>
<p class="date">{{ post.date }}</p>
<p>{{ post.description }}</p>
<div class="tags">
<span v-if="typeof post.tags === 'string'" :key="post.tags"
>#{{ post.tags }}</span
>
<span v-else v-for="tag in post.tags" :key="tag">#{{ tag }}</span>
</div>
</article>
</div>
</div>
</template>

<script setup lang="ts">
import "aplos/custom/ArticleList.scss";
import { data as posts } from "./posts.data";
import { computed, ref } from "vue";

const selectedTag = ref(null);

const allTags = computed(() => {
return posts.reduce((tags, post) => {
return tags.concat(Array.isArray(post.tags) ? post.tags : [post.tags]);
}, []);
});

const uniqueTags = computed(() => {
const tags = [...new Set(allTags.value)];
return tags.filter((tag) => tag !== "");
});

const filteredPosts = computed(() => {
return selectedTag.value === null
? posts
: posts.filter((post) =>
Array.isArray(post.tags)
? post.tags.includes(selectedTag.value)
: post.tags === selectedTag.value
);
});

function filterPosts(tag: string) {
selectedTag.value = tag === "" ? null : tag;
}
</script>
Loading

0 comments on commit f3832b4

Please sign in to comment.