Skip to content

Commit

Permalink
Feat/style: landing page (#7)
Browse files Browse the repository at this point in the history
* build: install bdp-ui icons

* build: set config requirements

* style: add assets and icons

* chore: remove redundant styles, add menu data

* chore: add landing page components

* chore: create landing page with responsive styles

* fix: build error

* replace image assets

* add mobile menu and app menu

* install bdp-ui from npm

* complete landing page requirements

* remove search icon, change image path and add priority prop
  • Loading branch information
IgboPharaoh authored Sep 5, 2024
1 parent 51eb777 commit 0c7db98
Show file tree
Hide file tree
Showing 41 changed files with 1,566 additions and 248 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

# production
/build
/public/categories.json
/public/types-data.json
/public/tag-data.json

# misc
.DS_Store
Expand Down
81 changes: 76 additions & 5 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {
defineDocumentType,
defineNestedType,
makeSource,
} from "contentlayer2/source-files";
import { createSlug } from "./src/utils";
import { defineDocumentType, defineNestedType, makeSource } from "contentlayer2/source-files";
import { writeFileSync } from "fs";
import path from "path";
import { Transcript as ContentTranscriptType } from "./.contentlayer/generated/types";

const Resources = defineNestedType(() => ({
name: "Resources",
Expand All @@ -13,6 +12,63 @@ const Resources = defineNestedType(() => ({
},
}));

/**
* Count the occurrences of all tags across transcripts and write to json file
*/
function createTagCount(allTranscripts: ContentTranscriptType[]) {
const tagCount: Record<string, number> = {};
allTranscripts.forEach((file) => {
if (file.tags) {
file.tags.forEach((tag: string) => {
const formattedTag = createSlug(tag);
if (formattedTag in tagCount) {
tagCount[formattedTag] += 1;
} else {
tagCount[formattedTag] = 1;
}
});
}
});
writeFileSync("./public/tag-data.json", JSON.stringify(tagCount));
}

/**
* Count the occurrences of all types across transcripts and write to json file
*/
const createTypesCount = (allTranscripts: ContentTranscriptType[]) => {
const typesAndCount: Record<string, number> = {};
const relevantTypes = [
"video",
"core-dev-tech",
"podcast",
"conference",
"meeting",
"club",
"meetup",
"hackathon",
"workshop",
"residency",
"developer-tools",
];

allTranscripts.forEach((transcript) => {
if (transcript.categories) {
transcript.categories.forEach((type: string) => {
const formattedType = createSlug(type);
if (relevantTypes.includes(formattedType)) {
if (formattedType in typesAndCount) {
typesAndCount[formattedType] += 1;
} else {
typesAndCount[formattedType] = 1;
}
}
});
}
});

writeFileSync("./public/types-data.json", JSON.stringify(typesAndCount));
};

export const Transcript = defineDocumentType(() => ({
name: "Transcript",
filePathPattern: `**/*.md`,
Expand Down Expand Up @@ -55,4 +111,19 @@ export const Transcript = defineDocumentType(() => ({
export default makeSource({
contentDirPath: path.join(process.cwd(), "public", "bitcoin-transcript"),
documentTypes: [Transcript],
contentDirExclude: [
".github",
".gitignore",
"LICENSE.md",
"README.md",
"STYLE.md",
"twitter_handles.json",
".json",
"2018-08-17-richard-bondi-bitcoin-cli-regtest.es.md",
],
onSuccess: async (importData) => {
const { allDocuments } = await importData();
createTagCount(allDocuments);
createTypesCount(allDocuments);
},
});
Loading

0 comments on commit 0c7db98

Please sign in to comment.