From f070ffe97d418f42900a4935ac4e9d9e499f0bba Mon Sep 17 00:00:00 2001 From: skidoodle Date: Fri, 12 Jul 2024 10:27:28 +0200 Subject: [PATCH] init gitbiome --- .eslintrc.js | 39 + .gitignore | 38 + license | 674 ++++++++ next.config.js | 62 + package.json | 50 + postcss.config.mjs | 7 + public/favicon.ico | Bin 0 -> 1011 bytes readme.md | 105 ++ src/app/[username]/page.tsx | 131 ++ src/app/globals.css | 68 + src/app/layout.tsx | 38 + src/app/page.tsx | 82 + src/components/mixed/alert-container.tsx | 21 + src/components/mixed/icon-wrapper.tsx | 40 + src/components/mixed/markdown.tsx | 49 + src/components/mixed/profile-card.tsx | 118 ++ src/components/mixed/repository-card.tsx | 59 + src/components/mixed/spotify.tsx | 89 + src/components/ui/alert.tsx | 39 + src/components/ui/avatar.tsx | 38 + src/components/ui/background.tsx | 10 + src/components/ui/badge.tsx | 26 + src/components/ui/button.tsx | 43 + src/components/ui/card.tsx | 65 + src/components/ui/icon.tsx | 18 + src/components/ui/progress.tsx | 23 + src/components/ui/separator.tsx | 18 + src/components/ui/skeleton.tsx | 11 + src/components/ui/tooltip.tsx | 22 + src/lib/constants.ts | 115 ++ src/lib/fetcher.ts | 13 + src/lib/platform.ts | 37 + src/lib/services/content.ts | 32 + src/lib/services/database.ts | 22 + src/lib/services/github.ts | 51 + src/lib/utils/colors.json | 1919 ++++++++++++++++++++++ src/lib/utils/icons.tsx | 25 + src/lib/utils/index.ts | 23 + src/middleware.ts | 20 + tailwind.config.ts | 43 + tsconfig.json | 45 + 41 files changed, 4328 insertions(+) create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 license create mode 100644 next.config.js create mode 100644 package.json create mode 100644 postcss.config.mjs create mode 100644 public/favicon.ico create mode 100644 readme.md create mode 100644 src/app/[username]/page.tsx create mode 100644 src/app/globals.css create mode 100644 src/app/layout.tsx create mode 100644 src/app/page.tsx create mode 100644 src/components/mixed/alert-container.tsx create mode 100644 src/components/mixed/icon-wrapper.tsx create mode 100644 src/components/mixed/markdown.tsx create mode 100644 src/components/mixed/profile-card.tsx create mode 100644 src/components/mixed/repository-card.tsx create mode 100644 src/components/mixed/spotify.tsx create mode 100644 src/components/ui/alert.tsx create mode 100644 src/components/ui/avatar.tsx create mode 100644 src/components/ui/background.tsx create mode 100644 src/components/ui/badge.tsx create mode 100644 src/components/ui/button.tsx create mode 100644 src/components/ui/card.tsx create mode 100644 src/components/ui/icon.tsx create mode 100644 src/components/ui/progress.tsx create mode 100644 src/components/ui/separator.tsx create mode 100644 src/components/ui/skeleton.tsx create mode 100644 src/components/ui/tooltip.tsx create mode 100644 src/lib/constants.ts create mode 100644 src/lib/fetcher.ts create mode 100644 src/lib/platform.ts create mode 100644 src/lib/services/content.ts create mode 100644 src/lib/services/database.ts create mode 100644 src/lib/services/github.ts create mode 100644 src/lib/utils/colors.json create mode 100644 src/lib/utils/icons.tsx create mode 100644 src/lib/utils/index.ts create mode 100644 src/middleware.ts create mode 100644 tailwind.config.ts create mode 100644 tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..3e0d611 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,39 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + project: true, + }, + plugins: ['@typescript-eslint'], + extends: [ + 'plugin:@next/next/recommended', + 'plugin:@typescript-eslint/recommended-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked', + ], + ignorePatterns: ['.eslintrc.js'], + rules: { + '@typescript@typescript-eslint/array-type': 'off', + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/consistent-type-definitions': 'off', + '@typescript-eslint/consistent-type-imports': [ + 'warn', + { + prefer: 'type-imports', + fixStyle: 'inline-type-imports', + }, + ], + '@typescript-eslint/no-unused-vars': [ + 'warn', + { + argsIgnorePattern: '^_', + }, + ], + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/no-misused-promises': [ + 'error', + { + checksVoidReturn: { attributes: false }, + }, + ], + }, +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b17f3f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz +pnpm-lock.yaml +bun.lockb + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env** + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/license b/license new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/license @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/next.config.js b/next.config.js new file mode 100644 index 0000000..a198356 --- /dev/null +++ b/next.config.js @@ -0,0 +1,62 @@ +// @ts-check + +const securityHeaders = [ + { + key: 'X-DNS-Prefetch-Control', + value: 'on' + }, + { + key: 'X-XSS-Protection', + value: '1; mode=block' + }, + { + key: 'X-Content-Type-Options', + value: 'nosniff' + }, + { + key: 'Referrer-Policy', + value: 'strict-origin' + }, + { + key: 'Content-Security-Policy', + value: `frame-ancestors 'self';` + }, + { + key: 'X-Frame-Options', + value: 'SAMEORIGIN' + }, + { + key: 'Strict-Transport-Security', + value: 'max-age=31536000; includeSubDomains; preload' + }, + { + key: 'Permissions-Policy', + value: 'camera=(), microphone=(), geolocation=()' + } +] + + /** @type {import('next').NextConfig} */ +const nextConfig = { + async headers() { + return [{ + source: '/:path*', + headers: securityHeaders + } + ]}, + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'i.scdn.co' + }, + { + protocol: 'https', + hostname: 'placehold.co' + } + ] + }, + reactStrictMode: true, + swcMinify: true +} + +module.exports = nextConfig diff --git a/package.json b/package.json new file mode 100644 index 0000000..f84511a --- /dev/null +++ b/package.json @@ -0,0 +1,50 @@ +{ + "name": "gitbiome", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev --turbo", + "build": "next build", + "start": "next start", + "lint": "next lint" + }, + "dependencies": { + "next": "14.2.2", + "react": "^18", + "react-dom": "^18" + }, + "devDependencies": { + "@radix-ui/react-avatar": "^1.0.4", + "@radix-ui/react-progress": "^1.0.3", + "@radix-ui/react-separator": "^1.0.3", + "@radix-ui/react-slot": "^1.0.2", + "@radix-ui/react-tooltip": "^1.0.7", + "@types/node": "^20", + "@types/react": "^18", + "@types/react-dom": "^18", + "@typescript-eslint/eslint-plugin": "^7.7.1", + "@typescript-eslint/parser": "^7.7.1", + "@upstash/redis": "^1.31.5", + "class-variance-authority": "^0.7.0", + "clsx": "^2.1.1", + "eslint": "^8", + "eslint-config-next": "14.2.2", + "eslint-plugin-react": "^7.34.1", + "jose": "^5.3.0", + "lucide-react": "^0.378.0", + "next-themes": "^0.3.0", + "postcss": "^8", + "react-icons": "^5.1.0", + "rehype-pretty-code": "^0.13.2", + "rehype-sanitize": "^6.0.0", + "rehype-stringify": "^10.0.0", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.1.0", + "swr": "^2.2.5", + "tailwind-merge": "^2.3.0", + "tailwindcss": "^3.4.1", + "tailwindcss-animate": "^1.0.7", + "typescript": "^5", + "unified": "^11.0.4" + } +} diff --git a/postcss.config.mjs b/postcss.config.mjs new file mode 100644 index 0000000..05cbc49 --- /dev/null +++ b/postcss.config.mjs @@ -0,0 +1,7 @@ +const config = { + plugins: { + tailwindcss: {}, + }, +} + +export default config diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..144523f652147c5284ca6ab5ef48e7b37202ae19 GIT binary patch literal 1011 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGqB>(^xB>_oNB=7(L1BgjPK~!i%?U_x8 zO<@?v=Nut1j3ys3#9}5{Sz$5klqph@4arQhLTV&ovay+(Qg#+3%EC<+BQ`=!7Nm)l z#h5P>F*Bx67DjXZ{&SwW8SeSGbI!Tvs{5;d@AE$AeV^xj&b{}X^PXE%rAh@bH8s^L zSvQnY#|PnB8<(A?sFXV1m!t~FjA{W{Q!OBCA{W4AuOXk$AE&*C?x5@FEWS-PBoiVP zz(PA5#~ER<9dy5-Z}jKU9zk!>UiuqpD+?CB5IsPnEdHpuXMukU$6uhQ<_d*5cNu@n zy0P&61W2%w<}q4>wsD4U%Kta`U!zBudCwCL1+1Xy_j>UtS^x=}X|(uXXqW4{gYx^q z_;DI7Dk>T~=9%%BRRCwbmBl>6>_M+Mvs%2q^I>Q)r4*n~choZzL`*B6bU;B(fEP2~H4A1r7o+K#EOQ9bsB=>tXJSUXL< zelwb*x!#csAbA@aU@_BR52ATf`)~gywW6HOJ;E zhGHpZiyck}66EZxT|?{49UH|`OpBc}cd`&$ch7#b)m(|A*vg??=1K;FcA+7(*<7ii z9G0ugT=C#+G}}kJ-(0DqT*?W0B8UgU^!S{}gI6gir*d0&Zg2+bbQ%b>$6RGYIh7mg z%vCxBIfOo2x9ljl)?nSDgx!f7(2!?lf^usOzJwK^UDgNB%mn3L>zTy~E8r)JyirL3 zWXe%#}LIrJN{qiy8?6eMD!hn>xycMywl1*l%ElmniUtk}%q91YUh+h+2SdXyv>k z>*c^Q&kQDN0UJ=@%dLcYkJfu;Fpjmp@Pk@TGl32|jx%e!$M^IUO(W6+-zU?w%~)v? zTQTON)tJ&MYiH~}*LAPb79egbb8lcSrv2f0V?e;KXrFb}*RDx#Aha3Jp&q2m?ROSh zfWEFIx`GwZ7#piOl42-UVYi2U0O@sQG7#(yI*l4or!Ax#HQA5?_-auj+JUqXNw$2o zHmm@?Ce&>)JCSmlAA&tWLzbi$CGsEdpD3ncTaICL-wwrxV8_rElQP!4ok hIn7n2N_y1P{08n0@wLf9f(8Hp002ovPDHLkV1i1B#hw5F literal 0 HcmV?d00001 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..4aa069a --- /dev/null +++ b/readme.md @@ -0,0 +1,105 @@ + +# gitbiome + +Aggregate your online presences with the help of GitHub! + +- ✅ **Customization**: Choose how your profile is displayed with various theming options +- ✅ **Responsivity**: Your landing page will look great on any device +- ✅ **Easy setup**: Signing up has never been easier as it is unnecessary with our service +- ✅ **Auto-updated data**: Data is dynamically pulled from your GitHub profile + +Check out [our website](https://gitbio.me) to see it yourself. + +## Creating your profile + +### Prerequisites +You must publish a GitHub repository named **`gitbio`**, that contains the following files: +- `page.json` +- `readme.md` (optional) + + +Structurally should look like this: +```bash +├── gitbio (repository) +│ ├── page.json +│ ├── readme.md # optional +``` + +**⚠️ The file names are case-sensitive!** + + +### page.json +This file holds your page configuration, but it must follow a defined convention + +- **`display_name (string)`**: Displayed above your GitHub username +- **`bio (string)`** +- **`platforms (url[])`**: A collection of your social media +- **`showcased_repos (string[])`**: Max. 3 of your repositories to be displayed +- **`show views (boolean)`**: Whether or not to display the views on your gitbio profile. Default is `true` +- **`theme ('light' | 'dark')`**: Theme of your landing profile. Default value is `dark` +- **`background_color (css color)`**: A blurred circle in the background, colored of your choosing +- **`spotify_ws (url)`**: A websocket application endpoint for providing real-time Spotify data. Learn more [here](https://github.com/csehviktor/now-playing?tab=readme-ov-file#now-playing) + + +An example: +```json +{ + "display_name": "john doe", + "bio": "use gitbio.me 😍😘", + "platforms": [ + "https://instagram.com/therock", + "https://yoursit.ee/", + "https://twitter.com/elonmusk", + "random string" // (will not be shown) + ], + "showcased_repos": [ + "gitbio", + "my-repository", + "hello world", // (invalid repo name, therefore will not be shown) + ], + "show_views": true, + "theme": "dark", + "background_color": "#8040ee" +} +``` + +**Keep in mind!** All of the config keys shown above are optional. Customize your page to your liking. + +### readme.md +No strict convention, other than file's name being case-sensitive. + +- `README.md` ❌ +- `rEaDmE.md` ❌ +- `readme.MD` ❌ +- `readme.md` ✅ + +### Your profile + +After creating the repository with the corresponding file(s), your profile will be accessible on `gitbio.me/[username]` or `[username].gitbio.me` + +**Your gitbio username is equivalent to the one on Github** + +## FAQ + +### How do I set an avatar and username? + +>You can't. Your avatar and username will be equivalent to the ones on GitHub. + +### How can I set an icon for my social platform? + +>You can't. Icons are automatically loaded from a preset, according to the origin of your url. External urls are provided with an "external website" icon. + +### I updated my profile but it won't change on the website. Why? + +>Our service uses cache on loaded values in order to improve load time. It might take a minute or two for changes to take place. In case an error occurs while reading data, it will be shown on your profile page. + +### How do I delete my profile? + +>You simply delete the repository. + +### My profile is not working properly in terms of functionality or responsivity. + +>Our service might not be 100%. Issues, pull requests, or even ideas are welcome! + +## License +[GPL-3.0](https://github.com/csehviktor/gitbiome/blob/main/license) \ No newline at end of file diff --git a/src/app/[username]/page.tsx b/src/app/[username]/page.tsx new file mode 100644 index 0000000..231cb8d --- /dev/null +++ b/src/app/[username]/page.tsx @@ -0,0 +1,131 @@ +import type { GithubProfileModel, RepositoryModel } from '@/lib/services/github' +import type { ProfileModelDraft } from '@/app/page' +import { type JsonProfileModel, Service } from '@/lib/services/content' +import { AlertContainer } from '@/components/mixed/alert-container' +import { RepositoryCard } from '@/components/mixed/repository-card' +import { ProfileCard } from '@/components/mixed/profile-card' +import { Spotify } from '@/components/mixed/spotify' +import { Markdown } from '@/components/mixed/markdown' +import { Background } from '@/components/ui/background' +import { Constants } from '@/lib/constants' +import { randomize, truncate } from '@/lib/utils' +import { headers } from 'next/headers' +import { ThemeProvider } from 'next-themes' +import { DatabaseService } from '@/lib/services/database' + +export interface ProfileModel extends ProfileModelDraft { + ok: boolean + views: number + profile: GithubProfileModel + repository: RepositoryModel + json: JsonProfileModel + readme: string +} + +interface ErrorResponse { + ok: boolean + error: string +} + + +async function getProfileData(username: string): Promise { + const repoName = Constants.WANTED_REPO_NAME + const jsonFile = Constants.PAGE_FILE + + const service = new Service(username, repoName) + + try { + const views = await DatabaseService.getViews(username) + + const repository = await service.getRepository(repoName) + const profile = await service.getGithubProfile() + const readme = await service.readFileByModel('readme.md', false) + const json = await service.readFileByModel(jsonFile, true) as JsonProfileModel + + if(json.showcased_repos) + json.showcased_repos = await Promise.all(json.showcased_repos.slice(0, 3) + .map(async repo => + await service.getRepository(repo as string) + ) + ) + + await DatabaseService.incrementViews( + username, + (headers().get('x-forwarded-for') ?? '127.0.0.1').split(',')[0]! + ) + + return { ok: true, views, profile, repository, json, readme } + } catch(error: unknown) { + return { ok: false, error: (error as Error).message } + } +} + +export default async function ProfilePage({ params }: { params: { username: string }}) { + const { username } = params + + const data = await getProfileData(username) + + const errorData = data as ErrorResponse || { } + const profileData = data as ProfileModel || { } + + const { + repository: { + latest_commit = '?' + } = { }, + json: { + theme = 'dark', + background_color = '', + showcased_repos: repos = [], + spotify_ws = '' + } = {}, + readme + } = profileData || { } + + return( + + +
+ { (!data?.ok) && } + +
+
0 && 'lg:flex-row lg:space-x-10'}`}> +
+ + { spotify_ws && } +
+ +
+ { readme && + + } + { (repos as RepositoryModel[]).map(repo => { + return ( + + ) + })} +
+
+
+

+ {'build id: '} + + { truncate(latest_commit, 8, false) } + +

+
+
+ ) +} + +export const revalidate = 0 \ No newline at end of file diff --git a/src/app/globals.css b/src/app/globals.css new file mode 100644 index 0000000..cdcce4f --- /dev/null +++ b/src/app/globals.css @@ -0,0 +1,68 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +:root { + --border: 240 6% 8%; + + --background: 136 0% 0%; + --foreground: 213 31% 92%; + + --card: 240 20% 2%; + --card-foreground: 213 31% 91%; + + --muted: 240 20% 6%; + --muted-foreground: 215.4 16.3% 56.9%; + + --destructive: 0 100% 50%; + --destructive-foreground: 0 86% 51%; + + --badge: 261 100% 74%; + --badge-foreground: 0 0% 100%; +} + +.light { + --border: 240 1% 90%; + + --background: 0 0% 100%;; + --foreground: 240 10% 3.9%; + + --card: 0 0% 100%; + --card-foreground: 240 10% 3.9%; + + --muted: 240 4.8% 95.9%; + --muted-foreground: 240 3.8% 46.1%; + + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 0 0% 98%; + + --badge: 261 100% 74%; + --badge-foreground: 0 0% 100%; +} + +@layer base { + ::-webkit-scrollbar { + width: 3px; + height: 3px; + } + + ::-webkit-scrollbar-thumb { + background-color: #5c5c5c; + border-radius: 10px; + } + + * { + @apply border-border; + } + + body { + @apply bg-background text-foreground; + font-feature-settings: "rlig" 1, "calt" 1; + } + + h1 { @apply font-semibold text-4xl lg:text-3xl } + + h2 { @apply font-semibold text-3xl lg:text-2xl } + + h3 { @apply text-lg } +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx new file mode 100644 index 0000000..35137b8 --- /dev/null +++ b/src/app/layout.tsx @@ -0,0 +1,38 @@ +import type { Metadata } from 'next' +import type { ReactNode } from 'react' +import { Inter } from 'next/font/google' +import '@/app/globals.css' + +import { Constants } from '@/lib/constants' + +const inter = Inter({ subsets: ['latin'], preload: false }) + + +const { META_TITLE, META_DESC, META_LOGO } = Constants + +export const metadata: Metadata = { + title: META_TITLE, + description: META_DESC, + openGraph: { + url: process.env.NEXT_BASE_URL, + title: META_TITLE, + description: META_DESC, + images: [ META_LOGO ] + }, + twitter: { + card: 'summary', + title: META_TITLE, + description: META_DESC, + images: [ META_LOGO ] + } +} + +export default function RootLayout({ children }: Readonly<{children: ReactNode}>) { + return( + + + { children } + + + ) +} \ No newline at end of file diff --git a/src/app/page.tsx b/src/app/page.tsx new file mode 100644 index 0000000..7f0f281 --- /dev/null +++ b/src/app/page.tsx @@ -0,0 +1,82 @@ +import type { GithubProfileModel, RepositoryModel } from '@/lib/services/github' +import type { JsonProfileModel } from '@/lib/services/content' +import { ProfileCard } from '@/components/mixed/profile-card' +import { Markdown } from '@/components/mixed/markdown' +import { Background } from '@/components/ui/background' +import { Button } from '@/components/ui/button' +import { Constants } from '@/lib/constants' +import { Github } from 'lucide-react' +import Link from 'next/link' + +export interface ProfileModelDraft { + views: number, + profile: Partial + repository: Partial + json: Partial +} + +const pageData: ProfileModelDraft = { + views: 1984, + profile: { + login: 'example', + avatar_url: 'https://i.pinimg.com/originals/ba/82/7c/ba827cdd57394d4d3eac9f8980a7a152.gif' + }, + repository: { + stargazers_count: 23 + }, + json: { + display_name: 'satoko', + bio: 'your bio', + platforms: [ + 'https://instagram.com/yoursitee', + 'https://github.com/yoursitee', + 'https://x.com/yoursitee', + 'https://yoursit.ee', + 'https://t.me/yoursitee' + ], + background_color: 'purple', + show_views: true + } +} + +export default function HomePage() { + const { json } = pageData || { } + + return( + <> + +
+
+
+
+

+ Collect your socials like a + developer🎀 +

+

Customize your page on Github, watch the result real-time

+ +
+
+ +

Are you interested?

+

Read our docs to create your own profile!

+ +

You don't even have to register 💯

+
+
+
+

+ made by thesatoko team +

+
+ + ) +} diff --git a/src/components/mixed/alert-container.tsx b/src/components/mixed/alert-container.tsx new file mode 100644 index 0000000..44790ab --- /dev/null +++ b/src/components/mixed/alert-container.tsx @@ -0,0 +1,21 @@ +'use client' + +import { Alert, AlertDescription } from '@/components/ui/alert' +import { AlertCircle } from 'lucide-react' + +const AlertContainer = ({ error }: { error?: string }) => { + const isLoading = error === undefined + + return( +
+ + + + { isLoading ? 'Fetching profile...' : error } + + +
+ ) +} + +export { AlertContainer } diff --git a/src/components/mixed/icon-wrapper.tsx b/src/components/mixed/icon-wrapper.tsx new file mode 100644 index 0000000..b5fdf32 --- /dev/null +++ b/src/components/mixed/icon-wrapper.tsx @@ -0,0 +1,40 @@ +'use client' + +import type { PlatformModel } from '@/lib/platform' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' +import { Icon } from '@/components/ui/icon' +import { PlatformIcon } from '@/lib/utils/icons' +import { randomize } from '@/lib/utils' +import Link from 'next/link' + +const IconWrapper = ({ props }: { props: (PlatformModel | undefined)[] }) => { + return( +
+ { props.map((prop: PlatformModel | undefined) => { + if(prop === undefined) return + + return( + + + + + + { prop.icon } + + + + +

{ prop.name }

+
+
+
+ ) + })} +
+ ) +} + +export { IconWrapper } \ No newline at end of file diff --git a/src/components/mixed/markdown.tsx b/src/components/mixed/markdown.tsx new file mode 100644 index 0000000..c5414c3 --- /dev/null +++ b/src/components/mixed/markdown.tsx @@ -0,0 +1,49 @@ +import { unified } from 'unified' + +//plugins +import remarkParse from 'remark-parse' +import remarkRehype from 'remark-rehype' +import rehypeSanitize from 'rehype-sanitize' +import rehypeStringify from 'rehype-stringify' +import rehypePrettyCode from 'rehype-pretty-code' + +import { Card, CardContent, CardHeader } from '@/components/ui/card' +import { Constants } from '@/lib/constants' +import Link from 'next/link' + +async function render(content: string): Promise { + return String(await unified() + .use(remarkParse) + .use(remarkRehype) + .use(rehypeSanitize) + .use(rehypeStringify) + .use(rehypePrettyCode, { + keepBackground: false + }) + .process(content) + ) +} + +const Markdown = async ({ owner, fileName, content, draft }: { owner: string, fileName: string, content: string, draft?: boolean }) => { + let html_url = `https://github.com/${owner}/${Constants.WANTED_REPO_NAME}/blob/main/${fileName}` + + if(draft) html_url = 'https://github.com/csehviktor/gitbiome?tab=readme-ov-file#page.json' + + return( + + + + { owner } / { fileName } + + + +
+ + + ) +} + +export { Markdown } \ No newline at end of file diff --git a/src/components/mixed/profile-card.tsx b/src/components/mixed/profile-card.tsx new file mode 100644 index 0000000..1962bad --- /dev/null +++ b/src/components/mixed/profile-card.tsx @@ -0,0 +1,118 @@ +'use client' + +import type { ProfileModelDraft } from '@/app/page' +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card' +import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar' +import { Skeleton } from '@/components/ui/skeleton' +import { Separator } from '@/components/ui/separator' +import { Badge } from '@/components/ui/badge' +import { IconWrapper } from '@/components/mixed/icon-wrapper' +import { Tooltip, TooltipProvider, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' +import { Constants } from '@/lib/constants' +import { getPlatformByUrl } from '@/lib/platform' +import { CodeXml, Eye, Github, Heart } from 'lucide-react' +import Link from 'next/link' + +const ProfileCard = ({ profileData, theme, draft }: { profileData: ProfileModelDraft, theme: 'light' | 'dark', draft?: boolean }) => { + const { profile, repository, json, views } = profileData || { } + + const { avatar_url, id, login } = profile || { } + const { stargazers_count, name } = repository || { } + const { display_name, bio, platforms, show_views = true } = json || { } + + return( + + + + + + + + + +
+ + { !display_name ? (login ? login : ) : display_name } + + { Constants.STAFF_ID.includes(id ?? 0) && + + + + + + + + +

developer

+
+
+
+ } +
+ +
{ login ? `@${login}` : }
+ + { + stargazers_count !== undefined ? +
+

+ + { stargazers_count } likes +

+ { + show_views && ( +

+ + { views } views +

+ ) + } +
: +
+ + +
+ } +
+
+
+ + + + { bio ?? } + + + +
+ { + platforms + ? getPlatformByUrl(platform, theme) )} /> + : + } +
+
+ + + { !draft ? +
+ { login ? +
+ + + view this repository + +
: + + } +
: '' + } +
+
+ ) +} + +export { ProfileCard } diff --git a/src/components/mixed/repository-card.tsx b/src/components/mixed/repository-card.tsx new file mode 100644 index 0000000..c6f8fe6 --- /dev/null +++ b/src/components/mixed/repository-card.tsx @@ -0,0 +1,59 @@ +'use client' + +import type { RepositoryModel } from '@/lib/services/github' +import { TooltipProvider, TooltipTrigger, Tooltip, TooltipContent } from '@/components/ui/tooltip' +import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card' +import { truncate } from '@/lib/utils' +import { GitFork, Star, SquareArrowOutUpRight } from 'lucide-react' +import Link from 'next/link' + +const RepositoryCard = ({ owner, repository }: { owner?: string, repository?: RepositoryModel }) => { + const { name, description, latest_commit, language, language_color, forks_count, stargazers_count, fork } = repository ?? { } + + return( + + + +
+ + + { name } { fork && } + + + { truncate(description ?? '', 150, true) } + +
+ + + { stargazers_count } + + + + { forks_count } + +
+
+
+ +
+ +

{ truncate(latest_commit ?? '', 8, false) }

+ +
+ + + +
+ + +

{ language }

+
+ + +
+ + + ) +} + +export { RepositoryCard } diff --git a/src/components/mixed/spotify.tsx b/src/components/mixed/spotify.tsx new file mode 100644 index 0000000..21fc655 --- /dev/null +++ b/src/components/mixed/spotify.tsx @@ -0,0 +1,89 @@ +'use client' + +import useSWRSubscription, { type SWRSubscriptionOptions } from 'swr/subscription' +import { Card, CardContent, CardHeader } from '@/components/ui/card' +import { Progress } from '@/components/ui/progress' +import { Icon } from '@/components/ui/icon' +import { PlatformIcon } from '@/lib/utils/icons' +import { timeformat, truncate } from '@/lib/utils' +import { useEffect, useState } from 'react' +import Link from 'next/link' + +interface SpotifyModel { + item: { + name: string + album: { + images: [{ url: string }] + } + popularity: number + duration_ms: number + artists: [{ name: string }] + external_urls: { spotify: string } + } + progress_ms: number + is_playing: boolean +} + +const Spotify = ({ wsUrl, theme }: { wsUrl: string, theme: string}) => { + const [ spotify, setSpotify ] = useState() + const [ timestamp, setTimeStamp ] = useState(0) + + useSWRSubscription(wsUrl, (key: string | URL, { next }: SWRSubscriptionOptions) => { + const socket = new WebSocket(key) + + socket.onopen = () => socket.send('HELP') + socket.onmessage = ({ data }: { data: string }) => next(null, () => { + const response = JSON.parse(data) as SpotifyModel + + setSpotify(response) + setTimeStamp(response.progress_ms) + }) + + return () => socket.readyState === 1 && socket.close() + }) + + const { item } = spotify ?? { } + + useEffect(() => { + const id = setInterval(() => { + if(spotify?.is_playing && (timestamp + 1000) < spotify.item.duration_ms) + setTimeStamp((old) => old + 1000) + }, 1000) + + return () => clearInterval(id) + }, [spotify]) + + return( + + + + + { PlatformIcon.SPOTIFY } + +

+ { spotify?.is_playing ? 'currently playing' : 'last played track'} +

+
+ +
+

{ truncate(item?.name ?? 'unknown track', 35, true) }

+

{ truncate(item?.artists?.map(artist => artist.name).join(', ') ?? 'unknown artist', 45, true) }

+ + { item && +
+ + { timeformat(timestamp) } + { timeformat(item?.duration_ms ?? 0) } +
+ } +
+
+ +
+ ) +} + +export { Spotify } diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsx new file mode 100644 index 0000000..d6a22d2 --- /dev/null +++ b/src/components/ui/alert.tsx @@ -0,0 +1,39 @@ +import * as React from 'react' +import { cva, type VariantProps } from 'class-variance-authority' + +import { merge } from '@/lib/utils' + +const alertVariants = cva('fixed z-10 top-2 w-full rounded-lg border p-4 flex items-center space-x-2', { + variants: { + variant: { + default: 'text-foreground', + destructive: + 'border-destructive/50 text-destructive-foreground [&>svg]:text-destructive' + } + }, + defaultVariants: { + variant: 'default' + } +}) + +const Alert = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes & VariantProps +>(({ className, variant, ...props }, ref) => ( +
+)) +Alert.displayName = 'Alert' + +const AlertDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +AlertDescription.displayName = 'AlertDescription' + +export { Alert, AlertDescription } diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx new file mode 100644 index 0000000..6eecb3e --- /dev/null +++ b/src/components/ui/avatar.tsx @@ -0,0 +1,38 @@ +'use client' + +import * as React from 'react' +import * as AvatarPrimitive from '@radix-ui/react-avatar' + +import { merge } from '@/lib/utils' + +const Avatar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Avatar.displayName = AvatarPrimitive.Root.displayName + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarImage.displayName = AvatarPrimitive.Image.displayName + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName + +export { Avatar, AvatarImage, AvatarFallback } diff --git a/src/components/ui/background.tsx b/src/components/ui/background.tsx new file mode 100644 index 0000000..b53154c --- /dev/null +++ b/src/components/ui/background.tsx @@ -0,0 +1,10 @@ +const Background = ({backgroundColor, theme }: { backgroundColor: string, theme: 'light' | 'dark' }) => { + return ( +
+ ) +} + +export { Background } \ No newline at end of file diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx new file mode 100644 index 0000000..13c27f5 --- /dev/null +++ b/src/components/ui/badge.tsx @@ -0,0 +1,26 @@ +import * as React from 'react' +import { cva, type VariantProps } from 'class-variance-authority' + +import { merge } from '@/lib/utils' + +const badgeVariants = cva('inline-flex items-center rounded-full border px-1 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', { + variants: { + variant: { + default: 'text-foreground', + dev: 'border-transparent bg-badge text-badge-foreground' + } + }, + defaultVariants: { + variant: 'default' + } +}) + +export interface BadgeProps extends React.HTMLAttributes, VariantProps {} + +const Badge = ({ className, variant, ...props }: BadgeProps) => { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx new file mode 100644 index 0000000..825c5ce --- /dev/null +++ b/src/components/ui/button.tsx @@ -0,0 +1,43 @@ +import * as React from 'react' +import { Slot } from '@radix-ui/react-slot' +import { cva, type VariantProps } from 'class-variance-authority' + +import { merge } from '@/lib/utils' + +const buttonVariants = cva('inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', { + variants: { + variant: { + default: 'bg-background/45 text-foreground', + destructive: 'bg-destructive text-foreground hover:bg-destructive/90' + }, + size: { + default: 'rounded-xl px-4 py-2', + sm: 'rounded-xl py-2 px-3', + lg: 'rounded-xl py-4 px-12', + icon: 'h-10 w-10' + } + }, + defaultVariants: { + variant: 'default', + size: 'default' + } +}) + +export interface ButtonProps + extends React.ButtonHTMLAttributes, VariantProps { + asChild?: boolean +} + +const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : 'button' + + return ( + + ) +}) + +Button.displayName = 'Button' + +export { Button, buttonVariants } diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx new file mode 100644 index 0000000..dcad115 --- /dev/null +++ b/src/components/ui/card.tsx @@ -0,0 +1,65 @@ +import * as React from 'react' + +import { merge } from '@/lib/utils' + +const Card = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +Card.displayName = 'Card' + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardHeader.displayName = 'CardHeader' + +const CardTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)) +CardTitle.displayName = 'CardTitle' + +const CardDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardDescription.displayName = 'CardDescription' + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardContent.displayName = 'CardContent' + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardFooter.displayName = 'CardFooter' + +export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } diff --git a/src/components/ui/icon.tsx b/src/components/ui/icon.tsx new file mode 100644 index 0000000..ad9adb2 --- /dev/null +++ b/src/components/ui/icon.tsx @@ -0,0 +1,18 @@ +import { merge } from '@/lib/utils' + +interface IconProps extends React.HtmlHTMLAttributes { + color: string + viewBox: 'small' | 'big' +} + +const Icon = ({ color, viewBox, children, className }: IconProps) => { + return( + + { children } + + ) +} + +export { Icon } \ No newline at end of file diff --git a/src/components/ui/progress.tsx b/src/components/ui/progress.tsx new file mode 100644 index 0000000..361b2fe --- /dev/null +++ b/src/components/ui/progress.tsx @@ -0,0 +1,23 @@ +'use client' + +import * as React from 'react' +import * as ProgressPrimitive from '@radix-ui/react-progress' + +import { merge } from '@/lib/utils' + +const Progress = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, value, color, ...props }, ref) => ( + + + +)) +Progress.displayName = ProgressPrimitive.Root.displayName + +export { Progress } \ No newline at end of file diff --git a/src/components/ui/separator.tsx b/src/components/ui/separator.tsx new file mode 100644 index 0000000..20e2a27 --- /dev/null +++ b/src/components/ui/separator.tsx @@ -0,0 +1,18 @@ +'use client' + +import * as React from 'react' +import * as SeparatorPrimitive from '@radix-ui/react-separator' + +import { merge } from '@/lib/utils' + +const Separator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+)) +Separator.displayName = SeparatorPrimitive.Root.displayName + +export { Separator } diff --git a/src/components/ui/skeleton.tsx b/src/components/ui/skeleton.tsx new file mode 100644 index 0000000..3cfcccb --- /dev/null +++ b/src/components/ui/skeleton.tsx @@ -0,0 +1,11 @@ +import { merge } from '@/lib/utils' + +const Skeleton = ({className, ...props}: React.HTMLAttributes) => { + return ( +
+ ) +} + +export { Skeleton } diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx new file mode 100644 index 0000000..dfbcaf5 --- /dev/null +++ b/src/components/ui/tooltip.tsx @@ -0,0 +1,22 @@ +'use client' + +import * as React from 'react' +import * as TooltipPrimitive from '@radix-ui/react-tooltip' + +import { merge } from '@/lib/utils' + +const TooltipProvider = TooltipPrimitive.Provider +const TooltipTrigger = TooltipPrimitive.Trigger +const Tooltip = TooltipPrimitive.Root + +const TooltipContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, sideOffset = 4, ...props }, ref) => ( + +)) +TooltipContent.displayName = TooltipPrimitive.Content.displayName + +export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } diff --git a/src/lib/constants.ts b/src/lib/constants.ts new file mode 100644 index 0000000..260dc67 --- /dev/null +++ b/src/lib/constants.ts @@ -0,0 +1,115 @@ +import type { PlatformModel } from '@/lib/platform' +import { PlatformIcon } from '@/lib/utils/icons' + +const { GITHUB_ACCESS_TOKEN, JWT_SECRET, NEXT_BASE_URL } = process.env + +export class Constants { + // github constants + public static WANTED_REPO_NAME = 'gitbio' + public static PAGE_FILE = 'page.json' + + // profile badge + public static STAFF_ID = [123418829, 53189968] + + // fetcher + public static BASIC_ACCESS_TOKEN = GITHUB_ACCESS_TOKEN + + // jwt + public static JWT_SIGNER = new TextEncoder().encode(JWT_SECRET) + + // metadata + public static META_TITLE = 'gitbiome' + public static META_DESC = 'collect your socials like a developer 💯🔥' + public static META_LOGO = `${NEXT_BASE_URL}/favicon.ico` + + // icons + public static PLATFORMS: PlatformModel[] = [ + { + url: ['https://github.com/'], + color: { + light: '#171717', + dark: '#f9f9f9' + }, + name: 'github', + icon: PlatformIcon.GITHUB + }, + { + url: ['https://linkedin.com/in/'], + color: '#0077b5', + name: 'linkedin', + icon: PlatformIcon.LINKEDIN + }, + { + url: ['https://instagram.com/'], + color: '#e1306c', + name: 'instagram', + icon: PlatformIcon.INSTAGRAM + }, + { + url: ['https://open.spotify.com/user/'], + color: '#1db954', + name: 'spotify', + icon: PlatformIcon.SPOTIFY + }, + { + url: ['https://youtube.com/@'], + color: '#ff0000', + name: 'youtube', + icon: PlatformIcon.YOUTUBE + }, + { + url: [ + 'https://x.com/', + 'https://twitter.com/' + ], + color: { + light: '#000000', + dark: '#ffffff' + }, + name: 'x', + icon: PlatformIcon.X + }, + { + url: ['https://t.me/'], + color: '#0088cc', + name: 'telegram', + icon: PlatformIcon.TELEGRAM + }, + { + url: ['https://pinterest.com/'], + color: '#e60023', + name: 'pinterest', + icon: PlatformIcon.PINTEREST + }, + { + url: ['https://soundcloud.com'], + color: '#ff7700', + name: 'soundcloud', + icon: PlatformIcon.SOUNDCLOUD + }, + { + url: ['https://paypal.me/'], + color: '#00457c', + name: 'paypal', + icon: PlatformIcon.PAYPAL + }, + { + url: ['https://tiktok.com/'], + color: '#ff0050', + name: 'tiktok', + icon: PlatformIcon.TIKTOK + }, + { + url: ['https://reddit.com/u/'], + color: '#ff5700', + name: 'reddit', + icon: PlatformIcon.REDDIT + }, + { + url: ['https://facebook.com/'], + color: '#3b5998', + name: 'facebook', + icon: PlatformIcon.FACEBOOK + } + ] +} \ No newline at end of file diff --git a/src/lib/fetcher.ts b/src/lib/fetcher.ts new file mode 100644 index 0000000..8d00567 --- /dev/null +++ b/src/lib/fetcher.ts @@ -0,0 +1,13 @@ +import { Constants } from '@/lib/constants' + +export async function fetchWithToken(url: string): Promise { + const response = await fetch(url, { + method: 'GET', + headers: { + 'Authorization': `Bearer ${Constants.BASIC_ACCESS_TOKEN}`, + }, + next: { revalidate: 60 } + }) + + return response +} \ No newline at end of file diff --git a/src/lib/platform.ts b/src/lib/platform.ts new file mode 100644 index 0000000..d1a4712 --- /dev/null +++ b/src/lib/platform.ts @@ -0,0 +1,37 @@ +import type { ReactElement } from 'react' +import { Constants } from '@/lib/constants' +import { PlatformIcon } from '@/lib/utils/icons' + +export interface PlatformModel { + url: string[] + color: string | { + light: string + dark: string + } + name: string + icon: ReactElement +} + +export function getPlatformByUrl(value: string, theme?: 'light' | 'dark'): PlatformModel | undefined { + try { + const url_obj = new URL(value) + const origin = `${url_obj.origin.replace('www.', '')}/` + + let name = value + let color = '#335df5' + let icon = PlatformIcon.EXTERNAL + + const iconProp = Constants.PLATFORMS.find((platform: PlatformModel) => platform.url.includes(origin)) + + if(iconProp) { + name = value.split('/').pop()! + icon = iconProp.icon + color = (iconProp.color as { dark: string, light: string })[theme!] ?? iconProp.color as string + } + + return { url: [ value ], name, color, icon } as PlatformModel + + } catch (e: unknown) { + //ignored + } +} diff --git a/src/lib/services/content.ts b/src/lib/services/content.ts new file mode 100644 index 0000000..7b49f28 --- /dev/null +++ b/src/lib/services/content.ts @@ -0,0 +1,32 @@ +import { GithubService, type RepositoryModel } from '@/lib/services/github' +import { fetchWithToken } from '@/lib/fetcher' + +export interface JsonProfileModel { + display_name: string + bio: string + platforms: string[] + showcased_repos: RepositoryModel[] | string[] + show_views: boolean + theme: 'dark' | 'light' + background_color: string + spotify_ws: string +} + +class ContentService extends GithubService { + constructor(username: string, private repository: string) { + super(username) + } + + public async readFileByModel(fileName: string, throwable: boolean): Promise { + const response = await fetchWithToken(`https://raw.githubusercontent.com/${this.username}/${this.repository}/main/${fileName}`) + + if(!response.ok && throwable) + throw new Error(`File (${fileName}) was not found`) + + const extension = fileName.split('.').pop() + + return response?.ok ? (extension === 'json' ? await response.json() as T : await response.text()) : '' + } +} + +export { ContentService as Service } \ No newline at end of file diff --git a/src/lib/services/database.ts b/src/lib/services/database.ts new file mode 100644 index 0000000..f05985b --- /dev/null +++ b/src/lib/services/database.ts @@ -0,0 +1,22 @@ +import { sha256 } from '@/lib/utils' +import { Redis } from '@upstash/redis' +import { unstable_noStore } from 'next/cache' + +export class DatabaseService { + private static redis = Redis.fromEnv() + + public static async incrementViews(username: string, ip: string): Promise { + unstable_noStore() + + ip = sha256(ip) + + if(!(await this.redis.sismember(username, ip))) + await this.redis.sadd(username, ip) + } + + public static async getViews(username: string): Promise { + unstable_noStore() + + return await this.redis.scard(username) ?? 0 + } +} diff --git a/src/lib/services/github.ts b/src/lib/services/github.ts new file mode 100644 index 0000000..97cb7f8 --- /dev/null +++ b/src/lib/services/github.ts @@ -0,0 +1,51 @@ +import { fetchWithToken } from '@/lib/fetcher' +import { colorize } from '@/lib/utils' + +export interface GithubProfileModel { + login: string + id: number + avatar_url: string +} + +export interface RepositoryModel { + name: string + description: string + language: string + language_color: string + stargazers_count: number + forks_count: number + latest_commit: string + fork: boolean +} + +export class GithubService { + constructor(protected username: string) { } + + public async getGithubProfile(): Promise { + const response = await fetchWithToken(`https://api.github.com/users/${this.username}`) + + if(!response.ok) + throw new Error(`Github profile (${this.username}) was not found`) + + const { login, id, avatar_url } = await response.json() as GithubProfileModel + + return { login, id, avatar_url } + } + + public async getRepository(repository: string): Promise { + const repoUrl = `https://api.github.com/repos/${this.username}/${repository}` + + const repoResponse = await fetchWithToken(repoUrl) + const commitResponse = await fetchWithToken(`${repoUrl}/commits`) + + if(!repoResponse.ok || !commitResponse.ok) + throw new Error(`Repository (${repository}) was not found`) + + const { name, description, language, stargazers_count, forks_count, fork } = await repoResponse.json() as RepositoryModel + const { 0: { sha: latest_commit }} = await commitResponse.json() as { 0: { sha: string }} + + const language_color = colorize(language) + + return { name, description, language, language_color, stargazers_count, forks_count, latest_commit, fork } + } +} \ No newline at end of file diff --git a/src/lib/utils/colors.json b/src/lib/utils/colors.json new file mode 100644 index 0000000..5446e0c --- /dev/null +++ b/src/lib/utils/colors.json @@ -0,0 +1,1919 @@ +{ + "1C Enterprise": { + "color": "#814CCC" + }, + "2-Dimensional Array": { + "color": "#38761D" + }, + "4D": { + "color": "#004289" + }, + "ABAP": { + "color": "#E8274B" + }, + "ABAP CDS": { + "color": "#555e25" + }, + "ActionScript": { + "color": "#882B0F" + }, + "Ada": { + "color": "#02f88c" + }, + "Adblock Filter List": { + "color": "#800000" + }, + "Adobe Font Metrics": { + "color": "#fa0f00" + }, + "Agda": { + "color": "#315665" + }, + "AGS Script": { + "color": "#B9D9FF" + }, + "AIDL": { + "color": "#34EB6B" + }, + "AL": { + "color": "#3AA2B5" + }, + "Alloy": { + "color": "#64C800" + }, + "Alpine Abuild": { + "color": "#0D597F" + }, + "Altium Designer": { + "color": "#A89663" + }, + "AMPL": { + "color": "#E6EFBB" + }, + "AngelScript": { + "color": "#C7D7DC" + }, + "Ant Build System": { + "color": "#A9157E" + }, + "Antlers": { + "color": "#ff269e" + }, + "ANTLR": { + "color": "#9DC3FF" + }, + "ApacheConf": { + "color": "#d12127" + }, + "Apex": { + "color": "#1797c0" + }, + "API Blueprint": { + "color": "#2ACCA8" + }, + "APL": { + "color": "#5A8164" + }, + "Apollo Guidance Computer": { + "color": "#0B3D91" + }, + "AppleScript": { + "color": "#101F1F" + }, + "Arc": { + "color": "#aa2afe" + }, + "AsciiDoc": { + "color": "#73a0c5" + }, + "ASL": { + "color": null + }, + "ASP.NET": { + "color": "#9400ff" + }, + "AspectJ": { + "color": "#a957b0" + }, + "Assembly": { + "color": "#6E4C13" + }, + "Astro": { + "color": "#ff5a03" + }, + "Asymptote": { + "color": "#ff0000" + }, + "ATS": { + "color": "#1ac620" + }, + "Augeas": { + "color": "#9CC134" + }, + "AutoHotkey": { + "color": "#6594b9" + }, + "AutoIt": { + "color": "#1C3552" + }, + "Avro IDL": { + "color": "#0040FF" + }, + "Awk": { + "color": "#c30e9b" + }, + "Ballerina": { + "color": "#FF5000" + }, + "BASIC": { + "color": "#ff0000" + }, + "Batchfile": { + "color": "#C1F12E" + }, + "Beef": { + "color": "#a52f4e" + }, + "Befunge": { + "color": null + }, + "Berry": { + "color": "#15A13C" + }, + "BibTeX": { + "color": "#778899" + }, + "Bicep": { + "color": "#519aba" + }, + "Bikeshed": { + "color": "#5562ac" + }, + "Bison": { + "color": "#6A463F" + }, + "BitBake": { + "color": "#00bce4" + }, + "Blade": { + "color": "#f7523f" + }, + "BlitzBasic": { + "color": "#00FFAE" + }, + "BlitzMax": { + "color": "#cd6400" + }, + "Bluespec": { + "color": "#12223c" + }, + "Bluespec BH": { + "color": "#12223c" + }, + "Boo": { + "color": "#d4bec1" + }, + "Boogie": { + "color": "#c80fa0" + }, + "Brainfuck": { + "color": "#2F2530" + }, + "BrighterScript": { + "color": "#66AABB" + }, + "Brightscript": { + "color": "#662D91" + }, + "Browserslist": { + "color": "#ffd539" + }, + "C": { + "color": "#555555" + }, + "C#": { + "color": "#178600" + }, + "C++": { + "color": "#f34b7d" + }, + "C2hs Haskell": { + "color": null + }, + "Cabal Config": { + "color": "#483465" + }, + "Cadence": { + "color": "#00ef8b" + }, + "Cairo": { + "color": "#ff4a48" + }, + "CameLIGO": { + "color": "#3be133" + }, + "CAP CDS": { + "color": "#0092d1" + }, + "Cap'n Proto": { + "color": "#c42727" + }, + "CartoCSS": { + "color": null + }, + "Ceylon": { + "color": "#dfa535" + }, + "Chapel": { + "color": "#8dc63f" + }, + "Charity": { + "color": null + }, + "ChucK": { + "color": "#3f8000" + }, + "Circom": { + "color": "#707575" + }, + "Cirru": { + "color": "#ccccff" + }, + "Clarion": { + "color": "#db901e" + }, + "Clarity": { + "color": "#5546ff" + }, + "Classic ASP": { + "color": "#6a40fd" + }, + "Clean": { + "color": "#3F85AF" + }, + "Click": { + "color": "#E4E6F3" + }, + "CLIPS": { + "color": "#00A300" + }, + "Clojure": { + "color": "#db5855" + }, + "Closure Templates": { + "color": "#0d948f" + }, + "Cloud Firestore Security Rules": { + "color": "#FFA000" + }, + "CMake": { + "color": "#DA3434" + }, + "COBOL": { + "color": null + }, + "CodeQL": { + "color": "#140f46" + }, + "CoffeeScript": { + "color": "#244776" + }, + "ColdFusion": { + "color": "#ed2cd6" + }, + "ColdFusion CFC": { + "color": "#ed2cd6" + }, + "COLLADA": { + "color": "#F1A42B" + }, + "Common Lisp": { + "color": "#3fb68b" + }, + "Common Workflow Language": { + "color": "#B5314C" + }, + "Component Pascal": { + "color": "#B0CE4E" + }, + "Cool": { + "color": null + }, + "Coq": { + "color": "#d0b68c" + }, + "Crystal": { + "color": "#000100" + }, + "CSON": { + "color": "#244776" + }, + "Csound": { + "color": "#1a1a1a" + }, + "Csound Document": { + "color": "#1a1a1a" + }, + "Csound Score": { + "color": "#1a1a1a" + }, + "CSS": { + "color": "#563d7c" + }, + "CSV": { + "color": "#237346" + }, + "Cuda": { + "color": "#3A4E3A" + }, + "CUE": { + "color": "#5886E1" + }, + "Curry": { + "color": "#531242" + }, + "CWeb": { + "color": "#00007a" + }, + "Cycript": { + "color": null + }, + "Cypher": { + "color": "#34c0eb" + }, + "Cython": { + "color": "#fedf5b" + }, + "D": { + "color": "#ba595e" + }, + "D2": { + "color": "#526ee8" + }, + "Dafny": { + "color": "#FFEC25" + }, + "Darcs Patch": { + "color": "#8eff23" + }, + "Dart": { + "color": "#00B4AB" + }, + "DataWeave": { + "color": "#003a52" + }, + "Debian Package Control File": { + "color": "#D70751" + }, + "DenizenScript": { + "color": "#FBEE96" + }, + "Dhall": { + "color": "#dfafff" + }, + "DIGITAL Command Language": { + "color": null + }, + "DirectX 3D File": { + "color": "#aace60" + }, + "DM": { + "color": "#447265" + }, + "Dockerfile": { + "color": "#384d54" + }, + "Dogescript": { + "color": "#cca760" + }, + "Dotenv": { + "color": "#e5d559" + }, + "DTrace": { + "color": null + }, + "Dylan": { + "color": "#6c616e" + }, + "E": { + "color": "#ccce35" + }, + "Earthly": { + "color": "#2af0ff" + }, + "Easybuild": { + "color": "#069406" + }, + "eC": { + "color": "#913960" + }, + "Ecere Projects": { + "color": "#913960" + }, + "ECL": { + "color": "#8a1267" + }, + "ECLiPSe": { + "color": "#001d9d" + }, + "Ecmarkup": { + "color": "#eb8131" + }, + "Edge": { + "color": "#0dffe0" + }, + "EdgeQL": { + "color": "#31A7FF" + }, + "EditorConfig": { + "color": "#fff1f2" + }, + "Eiffel": { + "color": "#4d6977" + }, + "EJS": { + "color": "#a91e50" + }, + "Elixir": { + "color": "#6e4a7e" + }, + "Elm": { + "color": "#60B5CC" + }, + "Elvish": { + "color": "#55BB55" + }, + "Elvish Transcript": { + "color": "#55BB55" + }, + "Emacs Lisp": { + "color": "#c065db" + }, + "EmberScript": { + "color": "#FFF4F3" + }, + "EQ": { + "color": "#a78649" + }, + "Erlang": { + "color": "#B83998" + }, + "Euphoria": { + "color": "#FF790B" + }, + "F#": { + "color": "#b845fc" + }, + "F*": { + "color": "#572e30" + }, + "Factor": { + "color": "#636746" + }, + "Fancy": { + "color": "#7b9db4" + }, + "Fantom": { + "color": "#14253c" + }, + "Faust": { + "color": "#c37240" + }, + "Fennel": { + "color": "#fff3d7" + }, + "FIGlet Font": { + "color": "#FFDDBB" + }, + "Filebench WML": { + "color": "#F6B900" + }, + "Filterscript": { + "color": null + }, + "fish": { + "color": "#4aae47" + }, + "Fluent": { + "color": "#ffcc33" + }, + "FLUX": { + "color": "#88ccff" + }, + "Forth": { + "color": "#341708" + }, + "Fortran": { + "color": "#4d41b1" + }, + "Fortran Free Form": { + "color": "#4d41b1" + }, + "FreeBasic": { + "color": "#141AC9" + }, + "FreeMarker": { + "color": "#0050b2" + }, + "Frege": { + "color": "#00cafe" + }, + "Futhark": { + "color": "#5f021f" + }, + "G-code": { + "color": "#D08CF2" + }, + "Game Maker Language": { + "color": "#71b417" + }, + "GAML": { + "color": "#FFC766" + }, + "GAMS": { + "color": "#f49a22" + }, + "GAP": { + "color": "#0000cc" + }, + "GCC Machine Description": { + "color": "#FFCFAB" + }, + "GDB": { + "color": null + }, + "GDScript": { + "color": "#355570" + }, + "GEDCOM": { + "color": "#003058" + }, + "Gemfile.lock": { + "color": "#701516" + }, + "Gemini": { + "color": "#ff6900" + }, + "Genero 4gl": { + "color": "#63408e" + }, + "Genero per": { + "color": "#d8df39" + }, + "Genie": { + "color": "#fb855d" + }, + "Genshi": { + "color": "#951531" + }, + "Gentoo Ebuild": { + "color": "#9400ff" + }, + "Gentoo Eclass": { + "color": "#9400ff" + }, + "Gerber Image": { + "color": "#d20b00" + }, + "Gherkin": { + "color": "#5B2063" + }, + "Git Attributes": { + "color": "#F44D27" + }, + "Git Config": { + "color": "#F44D27" + }, + "Git Revision List": { + "color": "#F44D27" + }, + "Gleam": { + "color": "#ffaff3" + }, + "Glimmer JS": { + "color": "#F5835F" + }, + "Glimmer TS": { + "color": "#3178c6" + }, + "GLSL": { + "color": "#5686a5" + }, + "Glyph": { + "color": "#c1ac7f" + }, + "Gnuplot": { + "color": "#f0a9f0" + }, + "Go": { + "color": "#00ADD8" + }, + "Go Checksums": { + "color": "#00ADD8" + }, + "Go Module": { + "color": "#00ADD8" + }, + "Go Workspace": { + "color": "#00ADD8" + }, + "Godot Resource": { + "color": "#355570" + }, + "Golo": { + "color": "#88562A" + }, + "Gosu": { + "color": "#82937f" + }, + "Grace": { + "color": "#615f8b" + }, + "Gradle": { + "color": "#02303a" + }, + "Gradle Kotlin DSL": { + "color": "#02303a" + }, + "Grammatical Framework": { + "color": "#ff0000" + }, + "GraphQL": { + "color": "#e10098" + }, + "Graphviz (DOT)": { + "color": "#2596be" + }, + "Groovy": { + "color": "#4298b8" + }, + "Groovy Server Pages": { + "color": "#4298b8" + }, + "GSC": { + "color": "#FF6800" + }, + "Hack": { + "color": "#878787" + }, + "Haml": { + "color": "#ece2a9" + }, + "Handlebars": { + "color": "#f7931e" + }, + "HAProxy": { + "color": "#106da9" + }, + "Harbour": { + "color": "#0e60e3" + }, + "Haskell": { + "color": "#5e5086" + }, + "Haxe": { + "color": "#df7900" + }, + "HCL": { + "color": "#844FBA" + }, + "HiveQL": { + "color": "#dce200" + }, + "HLSL": { + "color": "#aace60" + }, + "HOCON": { + "color": "#9ff8ee" + }, + "HolyC": { + "color": "#ffefaf" + }, + "hoon": { + "color": "#00b171" + }, + "Hosts File": { + "color": "#308888" + }, + "HTML": { + "color": "#e34c26" + }, + "HTML+ECR": { + "color": "#2e1052" + }, + "HTML+EEX": { + "color": "#6e4a7e" + }, + "HTML+ERB": { + "color": "#701516" + }, + "HTML+PHP": { + "color": "#4f5d95" + }, + "HTML+Razor": { + "color": "#512be4" + }, + "HTTP": { + "color": "#005C9C" + }, + "HXML": { + "color": "#f68712" + }, + "Hy": { + "color": "#7790B2" + }, + "HyPhy": { + "color": null + }, + "IDL": { + "color": "#a3522f" + }, + "Idris": { + "color": "#b30000" + }, + "Ignore List": { + "color": "#000000" + }, + "IGOR Pro": { + "color": "#0000cc" + }, + "ImageJ Macro": { + "color": "#99AAFF" + }, + "Imba": { + "color": "#16cec6" + }, + "Inform 7": { + "color": null + }, + "INI": { + "color": "#d1dbe0" + }, + "Ink": { + "color": null + }, + "Inno Setup": { + "color": "#264b99" + }, + "Io": { + "color": "#a9188d" + }, + "Ioke": { + "color": "#078193" + }, + "Isabelle": { + "color": "#FEFE00" + }, + "Isabelle ROOT": { + "color": "#FEFE00" + }, + "J": { + "color": "#9EEDFF" + }, + "Janet": { + "color": "#0886a5" + }, + "JAR Manifest": { + "color": "#b07219" + }, + "Jasmin": { + "color": "#d03600" + }, + "Java": { + "color": "#b07219" + }, + "Java Properties": { + "color": "#2A6277" + }, + "Java Server Pages": { + "color": "#2A6277" + }, + "JavaScript": { + "color": "#f1e05a" + }, + "JavaScript+ERB": { + "color": "#f1e05a" + }, + "JCL": { + "color": "#d90e09" + }, + "Jest Snapshot": { + "color": "#15c213" + }, + "JetBrains MPS": { + "color": "#21D789" + }, + "JFlex": { + "color": "#DBCA00" + }, + "Jinja": { + "color": "#a52a22" + }, + "Jison": { + "color": "#56b3cb" + }, + "Jison Lex": { + "color": "#56b3cb" + }, + "Jolie": { + "color": "#843179" + }, + "jq": { + "color": "#c7254e" + }, + "JSON": { + "color": "#292929" + }, + "JSON with Comments": { + "color": "#292929" + }, + "JSON5": { + "color": "#267CB9" + }, + "JSONiq": { + "color": "#40d47e" + }, + "JSONLD": { + "color": "#0c479c" + }, + "Jsonnet": { + "color": "#0064bd" + }, + "Julia": { + "color": "#a270ba" + }, + "Jupyter Notebook": { + "color": "#DA5B0B" + }, + "Just": { + "color": "#384d54" + }, + "Kaitai Struct": { + "color": "#773b37" + }, + "KakouneScript": { + "color": "#6f8042" + }, + "KerboScript": { + "color": "#41adf0" + }, + "KiCad Layout": { + "color": "#2f4aab" + }, + "KiCad Legacy Layout": { + "color": "#2f4aab" + }, + "KiCad Schematic": { + "color": "#2f4aab" + }, + "Kotlin": { + "color": "#A97BFF" + }, + "KRL": { + "color": "#28430A" + }, + "kvlang": { + "color": "#1da6e0" + }, + "LabVIEW": { + "color": "#fede06" + }, + "Lark": { + "color": "#2980B9" + }, + "Lasso": { + "color": "#999999" + }, + "Latte": { + "color": "#f2a542" + }, + "Lean": { + "color": null + }, + "Lean 4": { + "color": null + }, + "Less": { + "color": "#1d365d" + }, + "Lex": { + "color": "#DBCA00" + }, + "LFE": { + "color": "#4C3023" + }, + "LigoLANG": { + "color": "#0e74ff" + }, + "LilyPond": { + "color": "#9ccc7c" + }, + "Limbo": { + "color": null + }, + "Liquid": { + "color": "#67b8de" + }, + "Literate Agda": { + "color": "#315665" + }, + "Literate CoffeeScript": { + "color": "#244776" + }, + "Literate Haskell": { + "color": "#5e5086" + }, + "LiveScript": { + "color": "#499886" + }, + "LLVM": { + "color": "#185619" + }, + "Logos": { + "color": null + }, + "Logtalk": { + "color": "#295b9a" + }, + "LOLCODE": { + "color": "#cc9900" + }, + "LookML": { + "color": "#652B81" + }, + "LoomScript": { + "color": null + }, + "LSL": { + "color": "#3d9970" + }, + "Lua": { + "color": "#000080" + }, + "M": { + "color": null + }, + "M4": { + "color": null + }, + "M4Sugar": { + "color": null + }, + "Macaulay2": { + "color": "#d8ffff" + }, + "Makefile": { + "color": "#427819" + }, + "Mako": { + "color": "#7e858d" + }, + "Markdown": { + "color": "#083fa1" + }, + "Marko": { + "color": "#42bff2" + }, + "Mask": { + "color": "#f97732" + }, + "Mathematica": { + "color": "#dd1100" + }, + "MATLAB": { + "color": "#e16737" + }, + "Max": { + "color": "#c4a79c" + }, + "MAXScript": { + "color": "#00a6a6" + }, + "mcfunction": { + "color": "#E22837" + }, + "MDX": { + "color": "#fcb32c" + }, + "Mercury": { + "color": "#ff2b2b" + }, + "Mermaid": { + "color": "#ff3670" + }, + "Meson": { + "color": "#007800" + }, + "Metal": { + "color": "#8f14e9" + }, + "MiniD": { + "color": null + }, + "MiniYAML": { + "color": "#ff1111" + }, + "Mint": { + "color": "#02b046" + }, + "Mirah": { + "color": "#c7a938" + }, + "mIRC Script": { + "color": "#3d57c3" + }, + "MLIR": { + "color": "#5EC8DB" + }, + "Modelica": { + "color": "#de1d31" + }, + "Modula-2": { + "color": "#10253f" + }, + "Modula-3": { + "color": "#223388" + }, + "Module Management System": { + "color": null + }, + "Mojo": { + "color": "#ff4c1f" + }, + "Monkey": { + "color": null + }, + "Monkey C": { + "color": "#8D6747" + }, + "Moocode": { + "color": null + }, + "MoonScript": { + "color": "#ff4585" + }, + "Motoko": { + "color": "#fbb03b" + }, + "Motorola 68K Assembly": { + "color": "#005daa" + }, + "Move": { + "color": "#4a137a" + }, + "MQL4": { + "color": "#62A8D6" + }, + "MQL5": { + "color": "#4A76B8" + }, + "MTML": { + "color": "#b7e1f4" + }, + "MUF": { + "color": null + }, + "mupad": { + "color": "#244963" + }, + "Mustache": { + "color": "#724b3b" + }, + "Myghty": { + "color": null + }, + "nanorc": { + "color": "#2d004d" + }, + "Nasal": { + "color": "#1d2c4e" + }, + "NASL": { + "color": null + }, + "NCL": { + "color": "#28431f" + }, + "Nearley": { + "color": "#990000" + }, + "Nemerle": { + "color": "#3d3c6e" + }, + "nesC": { + "color": "#94B0C7" + }, + "NetLinx": { + "color": "#0aa0ff" + }, + "NetLinx+ERB": { + "color": "#747faa" + }, + "NetLogo": { + "color": "#ff6375" + }, + "NewLisp": { + "color": "#87AED7" + }, + "Nextflow": { + "color": "#3ac486" + }, + "Nginx": { + "color": "#009639" + }, + "Nim": { + "color": "#ffc200" + }, + "Nit": { + "color": "#009917" + }, + "Nix": { + "color": "#7e7eff" + }, + "NPM Config": { + "color": "#cb3837" + }, + "NSIS": { + "color": null + }, + "Nu": { + "color": "#c9df40" + }, + "NumPy": { + "color": "#9C8AF9" + }, + "Nunjucks": { + "color": "#3d8137" + }, + "Nushell": { + "color": "#4E9906" + }, + "NWScript": { + "color": "#111522" + }, + "OASv2-json": { + "color": "#85ea2d" + }, + "OASv2-yaml": { + "color": "#85ea2d" + }, + "OASv3-json": { + "color": "#85ea2d" + }, + "OASv3-yaml": { + "color": "#85ea2d" + }, + "Oberon": { + "color": null + }, + "Objective-C": { + "color": "#438eff" + }, + "Objective-C++": { + "color": "#6866fb" + }, + "Objective-J": { + "color": "#ff0c5a" + }, + "ObjectScript": { + "color": "#424893" + }, + "OCaml": { + "color": "#ef7a08" + }, + "Odin": { + "color": "#60AFFE" + }, + "Omgrofl": { + "color": "#cabbff" + }, + "ooc": { + "color": "#b0b77e" + }, + "Opa": { + "color": null + }, + "Opal": { + "color": "#f7ede0" + }, + "Open Policy Agent": { + "color": "#7d9199" + }, + "OpenAPI Specification v2": { + "color": "#85ea2d" + }, + "OpenAPI Specification v3": { + "color": "#85ea2d" + }, + "OpenCL": { + "color": "#ed2e2d" + }, + "OpenEdge ABL": { + "color": "#5ce600" + }, + "OpenQASM": { + "color": "#AA70FF" + }, + "OpenRC runscript": { + "color": null + }, + "OpenSCAD": { + "color": "#e5cd45" + }, + "Option List": { + "color": "#476732" + }, + "Org": { + "color": "#77aa99" + }, + "Ox": { + "color": null + }, + "Oxygene": { + "color": "#cdd0e3" + }, + "Oz": { + "color": "#fab738" + }, + "P4": { + "color": "#7055b5" + }, + "Pact": { + "color": "#F7A8B8" + }, + "Pan": { + "color": "#cc0000" + }, + "Papyrus": { + "color": "#6600cc" + }, + "Parrot": { + "color": "#f3ca0a" + }, + "Parrot Assembly": { + "color": null + }, + "Parrot Internal Representation": { + "color": null + }, + "Pascal": { + "color": "#E3F171" + }, + "Pawn": { + "color": "#dbb284" + }, + "PDDL": { + "color": "#0d00ff" + }, + "PEG.js": { + "color": "#234d6b" + }, + "Pep8": { + "color": "#C76F5B" + }, + "Perl": { + "color": "#0298c3" + }, + "PHP": { + "color": "#4F5D95" + }, + "PicoLisp": { + "color": "#6067af" + }, + "PigLatin": { + "color": "#fcd7de" + }, + "Pike": { + "color": "#005390" + }, + "Pip Requirements": { + "color": "#FFD343" + }, + "PlantUML": { + "color": "#fbbd16" + }, + "PLpgSQL": { + "color": "#336790" + }, + "PLSQL": { + "color": "#dad8d8" + }, + "PogoScript": { + "color": "#d80074" + }, + "Polar": { + "color": "#ae81ff" + }, + "Pony": { + "color": null + }, + "Portugol": { + "color": "#f8bd00" + }, + "PostCSS": { + "color": "#dc3a0c" + }, + "PostScript": { + "color": "#da291c" + }, + "POV-Ray SDL": { + "color": "#6bac65" + }, + "PowerBuilder": { + "color": "#8f0f8d" + }, + "PowerShell": { + "color": "#012456" + }, + "Praat": { + "color": "#c8506d" + }, + "Prisma": { + "color": "#0c344b" + }, + "Processing": { + "color": "#0096D8" + }, + "Procfile": { + "color": "#3B2F63" + }, + "Prolog": { + "color": "#74283c" + }, + "Promela": { + "color": "#de0000" + }, + "Propeller Spin": { + "color": "#7fa2a7" + }, + "Pug": { + "color": "#a86454" + }, + "Puppet": { + "color": "#302B6D" + }, + "PureBasic": { + "color": "#5a6986" + }, + "PureScript": { + "color": "#1D222D" + }, + "Pyret": { + "color": "#ee1e10" + }, + "Python": { + "color": "#3572A5" + }, + "Python console": { + "color": "#3572A5" + }, + "Python traceback": { + "color": "#3572A5" + }, + "q": { + "color": "#0040cd" + }, + "Q#": { + "color": "#fed659" + }, + "QMake": { + "color": null + }, + "QML": { + "color": "#44a51c" + }, + "Qt Script": { + "color": "#00b841" + }, + "Quake": { + "color": "#882233" + }, + "R": { + "color": "#198CE7" + }, + "Racket": { + "color": "#3c5caa" + }, + "Ragel": { + "color": "#9d5200" + }, + "Raku": { + "color": "#0000fb" + }, + "RAML": { + "color": "#77d9fb" + }, + "Rascal": { + "color": "#fffaa0" + }, + "RBS": { + "color": "#701516" + }, + "RDoc": { + "color": "#701516" + }, + "REALbasic": { + "color": null + }, + "Reason": { + "color": "#ff5847" + }, + "ReasonLIGO": { + "color": "#ff5847" + }, + "Rebol": { + "color": "#358a5b" + }, + "Record Jar": { + "color": "#0673ba" + }, + "Red": { + "color": "#f50000" + }, + "Redcode": { + "color": null + }, + "Regular Expression": { + "color": "#009a00" + }, + "Ren'Py": { + "color": "#ff7f7f" + }, + "RenderScript": { + "color": null + }, + "ReScript": { + "color": "#ed5051" + }, + "reStructuredText": { + "color": "#141414" + }, + "REXX": { + "color": "#d90e09" + }, + "Rez": { + "color": "#FFDAB3" + }, + "Ring": { + "color": "#2D54CB" + }, + "Riot": { + "color": "#A71E49" + }, + "RMarkdown": { + "color": "#198ce7" + }, + "RobotFramework": { + "color": "#00c0b5" + }, + "Roc": { + "color": "#7c38f5" + }, + "Roff": { + "color": "#ecdebe" + }, + "Roff Manpage": { + "color": "#ecdebe" + }, + "Rouge": { + "color": "#cc0088" + }, + "RouterOS Script": { + "color": "#DE3941" + }, + "RPC": { + "color": null + }, + "RPGLE": { + "color": "#2BDE21" + }, + "Ruby": { + "color": "#701516" + }, + "RUNOFF": { + "color": "#665a4e" + }, + "Rust": { + "color": "#dea584" + }, + "Sage": { + "color": null + }, + "SaltStack": { + "color": "#646464" + }, + "SAS": { + "color": "#B34936" + }, + "Sass": { + "color": "#a53b70" + }, + "Scala": { + "color": "#c22d40" + }, + "Scaml": { + "color": "#bd181a" + }, + "Scenic": { + "color": "#fdc700" + }, + "Scheme": { + "color": "#1e4aec" + }, + "Scilab": { + "color": "#ca0f21" + }, + "SCSS": { + "color": "#c6538c" + }, + "sed": { + "color": "#64b970" + }, + "Self": { + "color": "#0579aa" + }, + "ShaderLab": { + "color": "#222c37" + }, + "Shell": { + "color": "#89e051" + }, + "ShellCheck Config": { + "color": "#cecfcb" + }, + "ShellSession": { + "color": null + }, + "Shen": { + "color": "#120F14" + }, + "Sieve": { + "color": null + }, + "Simple File Verification": { + "color": "#C9BFED" + }, + "Singularity": { + "color": "#64E6AD" + }, + "Slash": { + "color": "#007eff" + }, + "Slice": { + "color": "#003fa2" + }, + "Slim": { + "color": "#2b2b2b" + }, + "Slint": { + "color": "#2379F4" + }, + "Smali": { + "color": null + }, + "Smalltalk": { + "color": "#596706" + }, + "Smarty": { + "color": "#f0c040" + }, + "Smithy": { + "color": "#c44536" + }, + "SmPL": { + "color": "#c94949" + }, + "SMT": { + "color": null + }, + "Snakemake": { + "color": "#419179" + }, + "Solidity": { + "color": "#AA6746" + }, + "SourcePawn": { + "color": "#f69e1d" + }, + "SPARQL": { + "color": "#0C4597" + }, + "SQF": { + "color": "#3F3F3F" + }, + "SQL": { + "color": "#e38c00" + }, + "SQLPL": { + "color": "#e38c00" + }, + "Squirrel": { + "color": "#800000" + }, + "SRecode Template": { + "color": "#348a34" + }, + "Stan": { + "color": "#b2011d" + }, + "Standard ML": { + "color": "#dc566d" + }, + "Starlark": { + "color": "#76d275" + }, + "Stata": { + "color": "#1a5f91" + }, + "STL": { + "color": "#373b5e" + }, + "StringTemplate": { + "color": "#3fb34f" + }, + "Stylus": { + "color": "#ff6347" + }, + "SubRip Text": { + "color": "#9e0101" + }, + "SugarSS": { + "color": "#2fcc9f" + }, + "SuperCollider": { + "color": "#46390b" + }, + "Svelte": { + "color": "#ff3e00" + }, + "SVG": { + "color": "#ff9900" + }, + "Sway": { + "color": "#00F58C" + }, + "Sweave": { + "color": "#198ce7" + }, + "Swift": { + "color": "#F05138" + }, + "SWIG": { + "color": null + }, + "SystemVerilog": { + "color": "#DAE1C2" + }, + "Talon": { + "color": "#333333" + }, + "Tcl": { + "color": "#e4cc98" + }, + "Tcsh": { + "color": null + }, + "Terra": { + "color": "#00004c" + }, + "Terraform Template": { + "color": "#7b42bb" + }, + "TeX": { + "color": "#3D6117" + }, + "TextGrid": { + "color": "#c8506d" + }, + "Textile": { + "color": "#ffe7ac" + }, + "TextMate Properties": { + "color": "#df66e4" + }, + "Thrift": { + "color": "#D12127" + }, + "TI Program": { + "color": "#A0AA87" + }, + "TL-Verilog": { + "color": "#C40023" + }, + "TLA": { + "color": "#4b0079" + }, + "Toit": { + "color": "#c2c9fb" + }, + "TOML": { + "color": "#9c4221" + }, + "TSQL": { + "color": "#e38c00" + }, + "TSV": { + "color": "#237346" + }, + "TSX": { + "color": "#3178c6" + }, + "Turing": { + "color": "#cf142b" + }, + "Twig": { + "color": "#c1d026" + }, + "TXL": { + "color": "#0178b8" + }, + "TypeScript": { + "color": "#3178c6" + }, + "Typst": { + "color": "#239dad" + }, + "Unified Parallel C": { + "color": "#4e3617" + }, + "Unity3D Asset": { + "color": "#222c37" + }, + "Unix Assembly": { + "color": null + }, + "Uno": { + "color": "#9933cc" + }, + "UnrealScript": { + "color": "#a54c4d" + }, + "UrWeb": { + "color": "#ccccee" + }, + "V": { + "color": "#4f87c4" + }, + "Vala": { + "color": "#a56de2" + }, + "Valve Data Format": { + "color": "#f26025" + }, + "VBA": { + "color": "#867db1" + }, + "VBScript": { + "color": "#15dcdc" + }, + "VCL": { + "color": "#148AA8" + }, + "Velocity Template Language": { + "color": "#507cff" + }, + "Verilog": { + "color": "#b2b7f8" + }, + "VHDL": { + "color": "#adb2cb" + }, + "Vim Help File": { + "color": "#199f4b" + }, + "Vim Script": { + "color": "#199f4b" + }, + "Vim Snippet": { + "color": "#199f4b" + }, + "Visual Basic .NET": { + "color": "#945db7" + }, + "Visual Basic 6.0": { + "color": "#2c6353" + }, + "Volt": { + "color": "#1F1F1F" + }, + "Vue": { + "color": "#41b883" + }, + "Vyper": { + "color": "#2980b9" + }, + "WDL": { + "color": "#42f1f4" + }, + "Web Ontology Language": { + "color": "#5b70bd" + }, + "WebAssembly": { + "color": "#04133b" + }, + "WebAssembly Interface Type": { + "color": "#6250e7" + }, + "WebIDL": { + "color": null + }, + "WGSL": { + "color": "#1a5e9a" + }, + "Whiley": { + "color": "#d5c397" + }, + "Wikitext": { + "color": "#fc5757" + }, + "Windows Registry Entries": { + "color": "#52d5ff" + }, + "wisp": { + "color": "#7582D1" + }, + "Witcher Script": { + "color": "#ff0000" + }, + "Wollok": { + "color": "#a23738" + }, + "World of Warcraft Addon Data": { + "color": "#f7e43f" + }, + "Wren": { + "color": "#383838" + }, + "X10": { + "color": "#4B6BEF" + }, + "xBase": { + "color": "#403a40" + }, + "XC": { + "color": "#99DA07" + }, + "XML": { + "color": "#0060ac" + }, + "XML Property List": { + "color": "#0060ac" + }, + "Xojo": { + "color": "#81bd41" + }, + "Xonsh": { + "color": "#285EEF" + }, + "XProc": { + "color": null + }, + "XQuery": { + "color": "#5232e7" + }, + "XS": { + "color": null + }, + "XSLT": { + "color": "#EB8CEB" + }, + "Xtend": { + "color": "#24255d" + }, + "Yacc": { + "color": "#4B6C4B" + }, + "YAML": { + "color": "#cb171e" + }, + "YARA": { + "color": "#220000" + }, + "YASnippet": { + "color": "#32AB90" + }, + "Yul": { + "color": "#794932" + }, + "ZAP": { + "color": "#0d665e" + }, + "Zeek": { + "color": null + }, + "ZenScript": { + "color": "#00BCD1" + }, + "Zephir": { + "color": "#118f9e" + }, + "Zig": { + "color": "#ec915c" + }, + "ZIL": { + "color": "#dc75e5" + }, + "Zimpl": { + "color": "#d67711" + } +} diff --git a/src/lib/utils/icons.tsx b/src/lib/utils/icons.tsx new file mode 100644 index 0000000..982dd14 --- /dev/null +++ b/src/lib/utils/icons.tsx @@ -0,0 +1,25 @@ +export class PlatformIcon { + public static GITHUB = + public static LINKEDIN = + public static INSTAGRAM = + public static SPOTIFY = + public static YOUTUBE = + public static X = + public static TELEGRAM = + public static PINTEREST = + public static SOUNDCLOUD = + public static PAYPAL = + public static TIKTOK = + public static REDDIT = + public static FACEBOOK = + public static EXTERNAL = ( + + + + + + + + + ) +} \ No newline at end of file diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts new file mode 100644 index 0000000..1d75695 --- /dev/null +++ b/src/lib/utils/index.ts @@ -0,0 +1,23 @@ +import { clsx, type ClassValue } from 'clsx' +import { twMerge } from 'tailwind-merge' +import { createHash } from 'crypto' + +import colors from '@/lib/utils/colors.json' + +export const randomize = (param: string | number): number => { + const additive = typeof param === 'string' + ? param.length + : param + + return Math.ceil(Date.now() * Math.random()) + additive +} +export const timeformat = (ms: number): string => { + const min = Math.floor((ms/1000/60) << 0) + const sec = Math.floor((ms/1000) % 60) + + return `${min}:${sec < 10 ? '0' : ''}${sec}` +} +export const sha256 = (str: string) => createHash('sha256').update(str).digest('hex'); +export const merge = (...inputs: ClassValue[]) => twMerge(clsx(inputs)) +export const truncate = (str: string, n: number, show_dots?: boolean) => str.length > n ? str.slice(0, n - 1) + (show_dots ? '...' : '') : str +export const colorize = (language: string): string => (colors as unknown as Record)[language]?.color ?? '#bababa' diff --git a/src/middleware.ts b/src/middleware.ts new file mode 100644 index 0000000..bc67b7e --- /dev/null +++ b/src/middleware.ts @@ -0,0 +1,20 @@ +import { type NextRequest, NextResponse } from 'next/server' + +const { NEXT_BASE_HOST } = process.env + +export const config = { + matcher: [ '/((?!api/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)' ] +} + +export default async function middleware(req: NextRequest) { + const url = req.nextUrl + + const subdomain = req.headers + .get('host')! + .replace(`.${NEXT_BASE_HOST}`, '') + + if(subdomain && subdomain !== NEXT_BASE_HOST) + url.pathname = `/${subdomain}${url.pathname}` + + return NextResponse.rewrite(url) +} diff --git a/tailwind.config.ts b/tailwind.config.ts new file mode 100644 index 0000000..8ad88bd --- /dev/null +++ b/tailwind.config.ts @@ -0,0 +1,43 @@ +import type { Config } from 'tailwindcss' + +const config: Config = { + content: [ + './src/components/**/*.{js,ts,jsx,tsx,mdx}', + './src/app/**/*.{js,ts,jsx,tsx,mdx}', + ], + theme: { + container: { + center: true, + padding: '2rem', + screens: { + '2xl': '1400px' + } + }, + extend: { + colors: { + border: 'hsl(var(--border))', + background: 'hsl(var(--background))', + foreground: 'hsl(var(--foreground))', + card: { + DEFAULT: 'hsl(var(--card))', + foreground: 'hsl(var(--card-foreground))' + }, + muted: { + DEFAULT: 'hsl(var(--muted))', + foreground: 'hsl(var(--muted-foreground))' + }, + badge: { + DEFAULT: 'hsl(var(--badge))', + foreground: 'hsl(var(--badge-foreground))' + }, + destructive: { + DEFAULT: 'hsl(var(--destructive))', + foreground: 'hsl(var(--destructive-foreground))' + } + } + }, + }, + plugins: [require('tailwindcss-animate')] +} + +export default config diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4d3fd35 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,45 @@ +{ + "compilerOptions": { + /* Base Options: */ + "esModuleInterop": true, + "skipLibCheck": true, + "target": "es2022", + "allowJs": true, + "resolveJsonModule": true, + "moduleDetection": "force", + "isolatedModules": true, + + /* Strictness */ + "strict": true, + "noUncheckedIndexedAccess": true, + "checkJs": true, + + /* Bundled projects */ + "lib": ["dom", "dom.iterable", "ES2022"], + "noEmit": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "jsx": "preserve", + "plugins": [{ "name": "next" }], + "incremental": true, + + /* Path Aliases */ + "baseUrl": "src", + "paths": { + "@/*": ["./*"] + } + }, + "include": [ + ".eslintrc.js", + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + "**/*.cjs", + "**/*.js", + ".next/types/**/*.ts", + "next.config.mjs", + "postcss.config.mjs", + "tailwind.config.ts", + ], + "exclude": ["node_modules"] + }