blazed-past-us 0.3.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/build.js CHANGED
@@ -29,7 +29,7 @@ function initPaths(root) {
29
29
  /**
30
30
  * Processes all post files:
31
31
  *
32
- * parses Markdown to HTML, generates metadata,
32
+ * Parses Markdown to HTML, generates metadata,
33
33
  * writes transformed files, and emits a JSON index.
34
34
  */
35
35
  async function buildBundle(paths) {
@@ -37,7 +37,6 @@ async function buildBundle(paths) {
37
37
  const data = [];
38
38
  for (const filename of postsFiles) {
39
39
  const filePath = path.join(paths.input, filename);
40
- // const postHtmlContent = await parseMarkdown(filePath);
41
40
  const parsedPostData = await parseMarkdown(filePath);
42
41
  const htmlFilename = filename.replace('.md', '.html');
43
42
  await generatePostMetadata(data, filePath, htmlFilename, parsedPostData.tags);
@@ -1,13 +1,13 @@
1
- import type { PostData, Config, PostDataType, ConsumerConfig } from '../types';
2
- declare function getPostData(postsMetaData: PostData[], slug: string, option: PostDataType): string | Date | undefined;
3
- declare function getAllPostsHTML(postsMetaData: PostData[], baseURL: string): Promise<{
1
+ import type { PostMetaData, Config, PostDataType } from '../types';
2
+ declare function getPostData(postsMetaData: PostMetaData[], slug: string, option: PostDataType): string | Date | undefined;
3
+ declare function getAllPostsHTML(postsMetaData: PostMetaData[], baseURL: string): Promise<{
4
4
  slug: string;
5
5
  html: string | void;
6
6
  }[]>;
7
- declare function getPostsMetaData(baseURL: string, config: Config): Promise<PostData[]>;
7
+ declare function getPostsMetaData(baseURL: string, config: Config): Promise<PostMetaData[]>;
8
8
  declare function getSlug(htmlFilename: string): string;
9
9
  declare function getTitle(htmlFilename: string): string;
10
10
  declare function getBrief(fileContent: string, lines: number): string;
11
11
  declare function getTags(fileContent: string): string[];
12
- declare function getColoredTagsHTML(tags: string, consumerConfig: ConsumerConfig): string;
12
+ declare function getColoredTagsHTML(tags: string, config: Config): string;
13
13
  export { getPostData, getAllPostsHTML, getPostsMetaData, getTitle, getTags, getBrief, getColoredTagsHTML, getSlug, };
@@ -54,13 +54,13 @@ function getTags(fileContent) {
54
54
  ?.split(',')
55
55
  .map((str) => str.trim()) || []);
56
56
  }
57
- function getColoredTagsHTML(tags, consumerConfig) {
57
+ function getColoredTagsHTML(tags, config) {
58
58
  return tags
59
59
  .replace(/\s/g, '')
60
60
  .toLowerCase()
61
61
  .split(',')
62
62
  .map((key) => {
63
- const tagColor = consumerConfig.tags[key]?.color ?? consumerConfig.tags.default.color;
63
+ const tagColor = config.tags[key]?.color ?? config.tags.default.color;
64
64
  return `
65
65
  <span class="tag" style="--tag-color: ${tagColor}">
66
66
  ${key}
@@ -1,3 +1,3 @@
1
- import { View, Views, PostData } from '../types.js';
2
- declare function render(view: View, root: HTMLElement, views: Views, postsMetaData: PostData[], postTagFilter?: string, postSlug?: string): void;
1
+ import { Views, PostMetaData } from '../types.js';
2
+ declare function render(view: string, root: HTMLElement, views: Views, postsMetaData: PostMetaData[], postTagsFilter?: string, postSlug?: string): void;
3
3
  export { render };
@@ -1,10 +1,10 @@
1
1
  import { postExists, inject } from './utils.js';
2
- function render(view, root, views, postsMetaData, postTagFilter, postSlug) {
2
+ function render(view, root, views, postsMetaData, postTagsFilter, postSlug) {
3
3
  const r = root;
4
4
  const { home, post, notFound } = views;
5
5
  switch (view) {
6
6
  case 'home':
7
- inject(r, home(postTagFilter));
7
+ inject(r, home(postTagsFilter?.split(',')));
8
8
  break;
9
9
  case 'post':
10
10
  if (postSlug && postExists(postsMetaData, postSlug)) {
@@ -1,4 +1,4 @@
1
- import { PostData } from '../types';
1
+ import { PostMetaData } from '../types';
2
2
  declare function writeTransformedPostFile(outputPath: string, postHtmlContent: string, filename: string): Promise<void>;
3
- declare function generatePostMetadata(data: Array<PostData>, filePath: string, htmlFilename: string, postTags: string[]): Promise<void>;
3
+ declare function generatePostMetadata(data: Array<PostMetaData>, filePath: string, htmlFilename: string, postTags: string[]): Promise<void>;
4
4
  export { generatePostMetadata, writeTransformedPostFile };
@@ -18,12 +18,14 @@ export default function initRouter(root, postsMetaData) {
18
18
  * This is the reason why we use hash routing.
19
19
  */
20
20
  async function handleRoute(root, postsMetaData) {
21
- const pathname = removeHash(window.location.hash);
22
- const urlParams = new URLSearchParams(window.location.search);
21
+ const hashRoute = window.location.hash;
22
+ const pathname = getPathname(hashRoute);
23
+ const queryString = hashRoute.split('?')[1] || '';
24
+ const urlParams = new URLSearchParams(queryString);
23
25
  const views = { home, post, notFound };
24
26
 
25
- if (pathname === '' || pathname === 'home') {
26
- render('home', root, views, postsMetaData, urlParams.get('tag'));
27
+ if (pathname === '' || pathname === 'home' || queryString) {
28
+ render('home', root, views, postsMetaData, urlParams.get('tags'));
27
29
  return;
28
30
  }
29
31
 
@@ -36,6 +38,6 @@ async function handleRoute(root, postsMetaData) {
36
38
  }
37
39
 
38
40
  // Removes "#/" from the location hash.
39
- function removeHash(locationHash) {
41
+ function getPathname(locationHash) {
40
42
  return locationHash.split('/').splice(1).join('/');
41
43
  }
@@ -158,7 +158,7 @@ function handleResize(renderer, camera) {
158
158
  });
159
159
  }
160
160
 
161
- // This avoids stars to twinkle together.
161
+ // This avoids stars twinkling together.
162
162
  function createRandomStarPhases(n, max) {
163
163
  const pauses = new Float32Array(n);
164
164
  pauses.forEach((_el, i) => (pauses[i] = Math.random() * max + 1));
@@ -1,11 +1,11 @@
1
1
  import { postsMetaData } from '../main';
2
2
  import { beautifyDate } from 'blazed-past-us';
3
3
 
4
- export default function home(tag) {
4
+ export default function home(tags) {
5
5
  const baseURL = import.meta.env.BASE_URL;
6
6
 
7
7
  const postsHtmlArray = postsMetaData
8
- .filter((post) => (tag ? post.tags.includes(tag) : true))
8
+ .filter((post) => (tags ? tags.some((tag) => post.tags.includes(tag)) : true))
9
9
  .map(
10
10
  (post) => `
11
11
  <a href="${baseURL}#/${post.slug}">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blazed-past-us",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "description": "A static blog framework made for developers that allows content to be written in Markdown directly from the IDE.",
5
5
  "license": "MIT",
6
6
  "author": "gass-git",