Repository: NayamAmarshe/writedown Branch: main Commit: 3d0bd61bdccf Files: 80 Total size: 224.9 KB Directory structure: gitextract_fn_ur9d7/ ├── .eslintrc.json ├── .firebaserc ├── .gitignore ├── .husky/ │ └── pre-commit ├── .prettierrc ├── .vscode/ │ └── extensions.json ├── LICENSE ├── README.md ├── animations/ │ ├── pencil-write-dark.json │ └── pencil-write.json ├── components/ │ ├── Navbar.tsx │ ├── common/ │ │ ├── HeadTags.tsx │ │ └── UserMenu.tsx │ ├── dashboard/ │ │ ├── CheckUsername.tsx │ │ ├── Sidebar/ │ │ │ ├── PostRow.tsx │ │ │ ├── ThemeChanger.tsx │ │ │ └── index.tsx │ │ └── TextArea/ │ │ ├── EditorButtons.tsx │ │ ├── LinkPreview.tsx │ │ ├── PostButtons.tsx │ │ └── index.tsx │ ├── home/ │ │ ├── FeatureCard.tsx │ │ ├── Features.tsx │ │ ├── Footer.tsx │ │ ├── HeroSection.tsx │ │ └── Navbar.tsx │ ├── hooks/ │ │ ├── UsePaginateQuery.ts │ │ ├── useMounted.ts │ │ ├── useNotes.ts │ │ ├── usePublicNotes.ts │ │ └── useUser.ts │ ├── login/ │ │ ├── InfoSidebar.tsx │ │ └── SignInArea.tsx │ └── ui/ │ ├── Badge.tsx │ ├── BetaBadge.tsx │ ├── Button.tsx │ ├── IconButton.tsx │ ├── Input.tsx │ ├── Loading.tsx │ ├── Modal.tsx │ ├── Popover.tsx │ ├── Toggle.tsx │ └── WritedownEditor.tsx ├── constants/ │ ├── channel-background-colors.ts │ ├── feature-flags.ts │ └── firebase-auth-error-codes.ts ├── declaration.d.ts ├── docs/ │ ├── colors.md │ ├── firebase.md │ └── tiptap.md ├── firebase.json ├── firestore.indexes.json ├── firestore.rules ├── html2pdf.js.d.ts ├── lib/ │ └── firebase.ts ├── next.config.js ├── package.json ├── pages/ │ ├── [username]/ │ │ └── posts/ │ │ └── [postId].tsx │ ├── _app.tsx │ ├── api/ │ │ ├── link-preview.ts │ │ └── og.tsx │ ├── dashboard.tsx │ ├── index.tsx │ ├── login.tsx │ └── not-found.tsx ├── postcss.config.js ├── public/ │ └── manifest.json ├── stores/ │ ├── postDataAtom.ts │ ├── syncLoadingAtom.ts │ └── syncedAtom.ts ├── styles/ │ ├── code-block.css │ └── globals.css ├── tailwind.config.js ├── todo.md ├── tsconfig.json ├── types/ │ ├── components/ │ │ └── firebase-hooks.d.ts │ └── utils/ │ └── firebaseOperations.d.ts └── utils/ ├── debounce.ts ├── firestoreDataConverter.ts └── markdownStyles.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc.json ================================================ { "extends": "next/core-web-vitals", "rules": { "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-namespace": "off", "@next/next/no-img-element": "off", "react-hooks/exhaustive-deps": "off", "no-console": "warn", "prefer-const": "warn" } } ================================================ FILE: .firebaserc ================================================ { "projects": { "default": "writedown-4a984" } } ================================================ FILE: .gitignore ================================================ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /.pnp .pnp.js # testing /coverage # next.js /.next/ /out/ # production /build # misc .DS_Store *.pem # debug npm-debug.log* yarn-debug.log* yarn-error.log* .pnpm-debug.log* # local env files .env*.local # vercel .vercel # typescript *.tsbuildinfo next-env.d.ts firebase-debug.log firestore-debug.log *.log #PWA Files /public/precache.*.*.js /public/sw.js /public/workbox-*.js /public/worker-*.js /public/fallback-*.js /public/precache.*.*.js.map /public/sw.js.map /public/workbox-*.js.map /public/worker-*.js.map /public/fallback-*.js /firebase/ /firebase/**/* functions/ .npmrc ================================================ FILE: .husky/pre-commit ================================================ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" npx pretty-quick --staged npm run lint ================================================ FILE: .prettierrc ================================================ { "plugins": ["prettier-plugin-tailwindcss"], "arrowParens": "always", "bracketSpacing": true, "endOfLine": "lf", "htmlWhitespaceSensitivity": "css", "jsxSingleQuote": false, "printWidth": 80, "proseWrap": "preserve", "quoteProps": "as-needed", "semi": true, "tabWidth": 2, "trailingComma": "es5" } ================================================ FILE: .vscode/extensions.json ================================================ { "recommendations": [ "formulahendry.auto-close-tag", "steoates.autoimport", "formulahendry.auto-rename-tag", "dsznajder.es7-react-js-snippets", "beatzoid.http-status-codes", "shd101wyy.markdown-preview-enhanced", "esbenp.prettier-vscode", "afzalsayed96.reacticons", "jeffersonlicet.snipped", "simonsiefke.svg-preview", "bradlc.vscode-tailwindcss", "chakrounanas.turbo-console-log", "mgmcdermott.vscode-language-babel", "naumovs.color-highlight", "mrmlnc.vscode-duplicate", "irongeek.vscode-env", "eamodio.gitlens", "pkief.material-icon-theme", "pkief.material-product-icons", "csstools.postcss", "usernamehw.errorlens" ] } ================================================ FILE: LICENSE ================================================ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 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 Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are 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. 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. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. 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 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 work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. 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 AGPL, see . ================================================ FILE: README.md ================================================
# ✏ [writedown (beta)](https://writedown.app) #### Free and Open Source Markdown Diary #### Public Blogs and Private Notes Write. Share. Inspire. **writedown** is the new way of writing markdown notes fast and easily. With a beautiful interface and polished user experience, writedown is simple but powerful. ![806shots_so (1)](https://user-images.githubusercontent.com/25067102/232125868-062e2438-c387-4c30-86e2-2766ff300cd0.png)
## 🤔 Why writedown? Love simplicity? **Good.** Hate complexity? **Even Better!** **writedown**'s focus is on providing a polished experience. A simple markdown editor you can use for writing notes quickly to publish and share them with the world. ### Here's what writedown provides that most other editors don't: 📴 **Offline support** ☁️ **Cloud Sync** 🤝 **Free and Open Source** 🪟 **Real-time Markdown Preview** 📨 **Publishing and Sharing** 🌹 **Simple and beautiful interface** [**GET STARTED IN JUST 5 SECONDS!**](https://writedown.app/login) ## ✨ Features ### Here are the markdown features that writedown supports: - Headings (1 to 4) - Bold - Italics - Underline - Quotes - Strikethrough - Ordered List - Unordered List - Task List - Code Block - Image - Horizontal Rule (Line) ### Along with that, writedown lets you: - Share posts with people - Create your personalized landing page - Add your social media links and many more being added as you read this! ## 🧑‍💻️ Development writedown is self-hostable with Firebase and Node.js. To run a local instance, follow these steps: 0. First install [Volta](https://volta.sh/). Then open your terminal and enter: `volta install node`. 1. Enter the following commands in your terminal. ```bash git clone https://github.com/NayamAmarshe/writedown cd writedown ``` 2. [Setup Firebase Emulator](https://github.com/NayamAmarshe/writedown/blob/main/docs/firebase.md) 3. [Setup TipTap Editor](docs/tiptap.md) 4. Install dependencies with: `npm install` 5. Run local dev server with: `npm run dev` OR local production server with `npm run build && npm run start`. #
© 2023 **writedown**. All rights reserved.
================================================ FILE: animations/pencil-write-dark.json ================================================ { "nm": "Pencil", "ddd": 0, "h": 800, "w": 800, "meta": { "g": "@lottiefiles/toolkit-js 0.26.1" }, "layers": [ { "ty": 4, "nm": "line", "sr": 1, "st": 0, "op": 49, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "hasMask": false, "ao": 0, "ks": { "a": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "s": { "a": 0, "k": [100, 100, 100] }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [400, 400, 0] }, "r": { "a": 0, "k": 0 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100 } }, "ef": [], "shapes": [ { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Shape 1", "ix": 1, "cix": 2, "np": 4, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0] ], "v": [ [-198.875, 197.5], [197.938, 197.5] ] } } }, { "ty": "tm", "bm": 0, "hd": false, "mn": "ADBE Vector Filter - Trim", "nm": "Trim Paths 1", "ix": 2, "e": { "a": 1, "k": [ { "o": { "x": 0.522, "y": 0 }, "i": { "x": 0.442, "y": 1 }, "s": [0], "t": 0 }, { "s": [100], "t": 20 } ], "ix": 2 }, "o": { "a": 0, "k": 0, "ix": 3 }, "s": { "a": 1, "k": [ { "o": { "x": 0.333, "y": 0 }, "i": { "x": 0.667, "y": 1 }, "s": [0], "t": 9 }, { "s": [100], "t": 27 } ], "ix": 1 }, "m": 1 }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 4, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 14 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [0, 0], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] } ], "ind": 1 }, { "ty": 3, "nm": "pencilRot", "sr": 1, "st": 0, "op": 49, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "hasMask": false, "ao": 0, "ks": { "a": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "s": { "a": 0, "k": [100, 100, 100] }, "sk": { "a": 0, "k": 0 }, "p": { "a": 1, "k": [ { "o": { "x": 0.522, "y": 0 }, "i": { "x": 0.442, "y": 1 }, "s": [200, 422, 0], "t": 0, "ti": [0, 0, 0], "to": [0, 0, 0] }, { "o": { "x": 0.333, "y": 0 }, "i": { "x": 1, "y": 1 }, "s": [600, 422, 0], "t": 20, "ti": [194, 0, 0], "to": [0, 0, 0] }, { "o": { "x": 0, "y": 0 }, "i": { "x": 0.667, "y": 1 }, "s": [400, 217, 0], "t": 36, "ti": [0, 0, 0], "to": [-179, 0, 0] }, { "s": [200, 422, 0], "t": 48 } ] }, "r": { "a": 1, "k": [ { "o": { "x": 0.7, "y": 0 }, "i": { "x": 0.256, "y": 1 }, "s": [0], "t": 20 }, { "s": [-360], "t": 48 } ] }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 0 } }, "ef": [], "ind": 2 }, { "ty": 4, "nm": "pencil", "sr": 1, "st": 0, "op": 49, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "hasMask": false, "ao": 0, "ks": { "a": { "a": 0, "k": [524.082, 810.037, 0] }, "s": { "a": 0, "k": [60, 60, 100] }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [0, 162.022, 0] }, "r": { "a": 1, "k": [ { "o": { "x": 0.469, "y": 0 }, "i": { "x": 0.212, "y": 1 }, "s": [-6], "t": 0 }, { "o": { "x": 0.441, "y": 0 }, "i": { "x": 1, "y": 1 }, "s": [11], "t": 20 }, { "o": { "x": 0, "y": 0 }, "i": { "x": 0.415, "y": 1 }, "s": [0], "t": 36 }, { "s": [-6], "t": 48 } ] }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100 } }, "ef": [], "shapes": [ { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 1", "ix": 1, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0] ], "v": [ [548, 341], [548, 657] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [0, 0], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 2", "ix": 2, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0] ], "v": [ [-0.063, -159.25], [0.063, 159.25] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [500.063, 497.25], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 3", "ix": 3, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [13.222, 0], [0, 13.222] ], "o": [ [0, 13.222], [-13.221, 0], [0, 0] ], "v": [ [23.94, -11.97], [0, 11.97], [-23.94, -11.97] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [524.06, 668.47], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 4", "ix": 4, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": true, "i": [ [0, 0], [-13.222, 0], [0, -13.221], [0, 0] ], "o": [ [0, -13.222], [13.221, 0], [0, 0], [0, 0] ], "v": [ [-23.939, -6.583], [0, -30.523], [23.94, -6.583], [0, 30.523] ] } } }, { "ty": "fl", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Fill", "nm": "Fill 1", "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] }, "r": 1, "o": { "a": 0, "k": 100 } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [524.06, 773.81], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 5", "ix": 5, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [6.412, 0], [0, 13.222] ], "o": [ [-4.297, 4.104], [-13.222, 0], [0, 0] ], "v": [ [20.236, 5.345], [3.704, 11.97], [-20.236, -11.97] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [568.231, 668.47], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 6", "ix": 6, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [13.222, 0], [3.802, 2.543] ], "o": [ [0, 13.222], [-4.917, 0], [0, 0] ], "v": [ [18.616, -11.97], [-5.324, 11.97], [-18.616, 7.944] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [481.509, 668.47], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 7", "ix": 7, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": false, "i": [ [0, 0], [-33.936, 0], [0, -34] ], "o": [ [0, -34], [33.935, 0], [0, 0] ], "v": [ [-61.446, 30.723], [0, -30.723], [61.446, 30.723] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 3, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 20 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [524.06, 245.277], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 8", "ix": 8, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": true, "i": [ [0, 0], [0, 0], [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0], [0, 0], [0, 0] ], "v": [ [61.446, 10.827], [-61.446, 10.827], [-61.446, -10.827], [61.446, -10.827] ] } } }, { "ty": "fl", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Fill", "nm": "Fill 1", "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] }, "r": 1, "o": { "a": 0, "k": 100 } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [524.06, 336.333], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] }, { "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Group 9", "ix": 9, "cix": 2, "np": 2, "it": [ { "ty": "sh", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Group", "nm": "Path 1", "ix": 1, "d": 1, "ks": { "a": 0, "k": { "c": true, "i": [ [0, 0], [0, 0], [0, 0], [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0], [0, 0], [0, 0], [0, 0] ], "v": [ [61.446, 130.452], [0, 258.452], [-61.446, 130.452], [-61.446, -258.452], [61.446, -258.452] ] } } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Stroke 1", "lc": 1, "lj": 1, "ml": 10, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 20 }, "c": { "a": 0, "k": [0.9451, 0.9608, 0.9765] } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [524.06, 551.548], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } } ] } ], "ind": 3, "parent": 2 }, { "ty": 4, "nm": "Shape Layer 1", "sr": 1, "st": 0, "op": 49, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "hasMask": false, "ao": 0, "ks": { "a": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "s": { "a": 0, "k": [100, 100, 100] }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [400, 400, 0] }, "r": { "a": 0, "k": 0 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100 } }, "ef": [], "shapes": [], "ind": 4 } ], "v": "4.6.6", "fr": 24, "op": 48, "ip": 0, "assets": [] } ================================================ FILE: animations/pencil-write.json ================================================ { "v": "4.6.6", "fr": 24, "ip": 0, "op": 48, "w": 800, "h": 800, "nm": "Pencil", "ddd": 0, "assets": [], "layers": [ { "ddd": 0, "ind": 1, "ty": 4, "nm": "line", "ks": { "o": { "a": 0, "k": 100 }, "r": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [400, 400, 0] }, "a": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "s": { "a": 0, "k": [100, 100, 100] } }, "ao": 0, "shapes": [ { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0] ], "v": [ [-198.875, 197.5], [197.938, 197.5] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "tm", "s": { "a": 1, "k": [ { "i": { "x": [0.667], "y": [1] }, "o": { "x": [0.333], "y": [0] }, "n": ["0p667_1_0p333_0"], "t": 9, "s": [0], "e": [100] }, { "t": 27 } ], "ix": 1 }, "e": { "a": 1, "k": [ { "i": { "x": [0.442], "y": [1] }, "o": { "x": [0.522], "y": [0] }, "n": ["0p442_1_0p522_0"], "t": 0, "s": [0], "e": [100] }, { "t": 20 } ], "ix": 2 }, "o": { "a": 0, "k": 0, "ix": 3 }, "m": 1, "ix": 2, "nm": "Trim Paths 1", "mn": "ADBE Vector Filter - Trim" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 14 }, "lc": 1, "lj": 1, "ml": 4, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [0, 0], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Shape 1", "np": 4, "cix": 2, "ix": 1, "mn": "ADBE Vector Group" } ], "ip": 0, "op": 49, "st": 0, "bm": 0, "sr": 1 }, { "ddd": 0, "ind": 2, "ty": 3, "nm": "pencilRot", "ks": { "o": { "a": 0, "k": 0 }, "r": { "a": 1, "k": [ { "i": { "x": [0.256], "y": [1] }, "o": { "x": [0.7], "y": [0] }, "n": ["0p256_1_0p7_0"], "t": 20, "s": [0], "e": [-360] }, { "t": 48 } ] }, "p": { "a": 1, "k": [ { "i": { "x": 0.442, "y": 1 }, "o": { "x": 0.522, "y": 0 }, "n": "0p442_1_0p522_0", "t": 0, "s": [200, 422, 0], "e": [600, 422, 0], "to": [0, 0, 0], "ti": [0, 0, 0] }, { "i": { "x": 1, "y": 1 }, "o": { "x": 0.333, "y": 0 }, "n": "1_1_0p333_0", "t": 20, "s": [600, 422, 0], "e": [400, 217, 0], "to": [0, 0, 0], "ti": [194, 0, 0] }, { "i": { "x": 0.667, "y": 1 }, "o": { "x": 0, "y": 0 }, "n": "0p667_1_0_0", "t": 36, "s": [400, 217, 0], "e": [200, 422, 0], "to": [-179, 0, 0], "ti": [0, 0, 0] }, { "t": 48 } ] }, "a": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "s": { "a": 0, "k": [100, 100, 100] } }, "ao": 0, "ip": 0, "op": 49, "st": 0, "bm": 0, "sr": 1 }, { "ddd": 0, "ind": 3, "ty": 4, "nm": "pencil", "parent": 2, "ks": { "o": { "a": 0, "k": 100 }, "r": { "a": 1, "k": [ { "i": { "x": [0.212], "y": [1] }, "o": { "x": [0.469], "y": [0] }, "n": ["0p212_1_0p469_0"], "t": 0, "s": [-6], "e": [11] }, { "i": { "x": [1], "y": [1] }, "o": { "x": [0.441], "y": [0] }, "n": ["1_1_0p441_0"], "t": 20, "s": [11], "e": [0] }, { "i": { "x": [0.415], "y": [1] }, "o": { "x": [0], "y": [0] }, "n": ["0p415_1_0_0"], "t": 36, "s": [0], "e": [-6] }, { "t": 48 } ] }, "p": { "a": 0, "k": [0, 162.022, 0] }, "a": { "a": 0, "k": [524.082, 810.037, 0] }, "s": { "a": 0, "k": [60, 60, 100] } }, "ao": 0, "shapes": [ { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0] ], "v": [ [548, 341], [548, 657] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "lc": 1, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [0, 0], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 1", "np": 2, "cix": 2, "ix": 1, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0] ], "v": [ [-0.063, -159.25], [0.063, 159.25] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "lc": 1, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [500.063, 497.25], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 2", "np": 2, "cix": 2, "ix": 2, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [13.222, 0], [0, 13.222] ], "o": [ [0, 13.222], [-13.221, 0], [0, 0] ], "v": [ [23.94, -11.97], [0, 11.97], [-23.94, -11.97] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "lc": 1, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [524.06, 668.47], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 3", "np": 2, "cix": 2, "ix": 3, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [-13.222, 0], [0, -13.221], [0, 0] ], "o": [ [0, -13.222], [13.221, 0], [0, 0], [0, 0] ], "v": [ [-23.939, -6.583], [0, -30.523], [23.94, -6.583], [0, 30.523] ], "c": true } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "fl", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "r": 1, "nm": "Fill 1", "mn": "ADBE Vector Graphic - Fill" }, { "ty": "tr", "p": { "a": 0, "k": [524.06, 773.81], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 4", "np": 2, "cix": 2, "ix": 4, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [6.412, 0], [0, 13.222] ], "o": [ [-4.297, 4.104], [-13.222, 0], [0, 0] ], "v": [ [20.236, 5.345], [3.704, 11.97], [-20.236, -11.97] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "lc": 1, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [568.231, 668.47], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 5", "np": 2, "cix": 2, "ix": 5, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [13.222, 0], [3.802, 2.543] ], "o": [ [0, 13.222], [-4.917, 0], [0, 0] ], "v": [ [18.616, -11.97], [-5.324, 11.97], [-18.616, 7.944] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 10 }, "lc": 1, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [481.509, 668.47], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 6", "np": 2, "cix": 2, "ix": 6, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [-33.936, 0], [0, -34] ], "o": [ [0, -34], [33.935, 0], [0, 0] ], "v": [ [-61.446, 30.723], [0, -30.723], [61.446, 30.723] ], "c": false } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 20 }, "lc": 3, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [524.06, 245.277], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 7", "np": 2, "cix": 2, "ix": 7, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [0, 0], [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0], [0, 0], [0, 0] ], "v": [ [61.446, 10.827], [-61.446, 10.827], [-61.446, -10.827], [61.446, -10.827] ], "c": true } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "fl", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "r": 1, "nm": "Fill 1", "mn": "ADBE Vector Graphic - Fill" }, { "ty": "tr", "p": { "a": 0, "k": [524.06, 336.333], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 8", "np": 2, "cix": 2, "ix": 8, "mn": "ADBE Vector Group" }, { "ty": "gr", "it": [ { "ind": 0, "ty": "sh", "ix": 1, "ks": { "a": 0, "k": { "i": [ [0, 0], [0, 0], [0, 0], [0, 0], [0, 0] ], "o": [ [0, 0], [0, 0], [0, 0], [0, 0], [0, 0] ], "v": [ [61.446, 130.452], [0, 258.452], [-61.446, 130.452], [-61.446, -258.452], [61.446, -258.452] ], "c": true } }, "nm": "Path 1", "mn": "ADBE Vector Shape - Group" }, { "ty": "st", "c": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "o": { "a": 0, "k": 100 }, "w": { "a": 0, "k": 20 }, "lc": 1, "lj": 1, "ml": 10, "nm": "Stroke 1", "mn": "ADBE Vector Graphic - Stroke" }, { "ty": "tr", "p": { "a": 0, "k": [524.06, 551.548], "ix": 2 }, "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "r": { "a": 0, "k": 0, "ix": 6 }, "o": { "a": 0, "k": 100, "ix": 7 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "nm": "Transform" } ], "nm": "Group 9", "np": 2, "cix": 2, "ix": 9, "mn": "ADBE Vector Group" } ], "ip": 0, "op": 49, "st": 0, "bm": 0, "sr": 1 }, { "ddd": 0, "ind": 4, "ty": 4, "nm": "Shape Layer 1", "ks": { "o": { "a": 0, "k": 100 }, "r": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [400, 400, 0] }, "a": { "a": 0, "k": [0.05859375, 0.08984375, 0.1640625] }, "s": { "a": 0, "k": [100, 100, 100] } }, "ao": 0, "shapes": [], "ip": 0, "op": 49, "st": 0, "bm": 0, "sr": 1 } ] } ================================================ FILE: components/Navbar.tsx ================================================ import Link from "next/link"; import React from "react"; import UserMenu from "./common/UserMenu"; import { RiMenu5Fill } from "react-icons/ri"; import useUser from "./hooks/useUser"; type Props = {}; const Navbar = (props: Props) => { const { user } = useUser(); return ( ); }; export default Navbar; ================================================ FILE: components/common/HeadTags.tsx ================================================ import Head from "next/head"; import React from "react"; type HeadTagsProps = { title: string; ogImage: string; description: string; ogUrl: string; }; const HeadTags = ({ title, ogImage, description, ogUrl }: HeadTagsProps) => { return ( {/* META TAGS */} {title} {/* TWITTER */} {/* OG */} ); }; export default HeadTags; ================================================ FILE: components/common/UserMenu.tsx ================================================ import { BiHomeAlt, BiLogInCircle, BiLogOutCircle, BiMoon, BiPencil, BiSun, } from "react-icons/bi"; import { selectedNoteAtom } from "@/stores/postDataAtom"; import { useTheme } from "next-themes"; import Popover from "../ui/Popover"; import { auth } from "@/lib/firebase"; import { useAtom, useSetAtom } from "jotai"; import Link from "next/link"; import React from "react"; type UserMenuProps = { reverse?: boolean; dashboard?: boolean; home?: boolean; themeOption?: boolean; logout?: boolean; showImageAsButton?: boolean; children?: React.ReactNode; }; const UserMenu = ({ reverse, dashboard, home, themeOption, logout, showImageAsButton, children, }: UserMenuProps) => { const { theme, setTheme } = useTheme(); const [selectedNote, setSelectedNote] = useAtom(selectedNoteAtom); return ( {children}} reverse={reverse} > {dashboard && auth.currentUser && ( writedown )} {dashboard && !auth.currentUser && ( Login )} {home && ( Home )} {themeOption && ( )} {logout && auth.currentUser && ( )} ); }; export default UserMenu; ================================================ FILE: components/dashboard/CheckUsername.tsx ================================================ import React, { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import useUser from "../hooks/useUser"; import { auth } from "@/lib/firebase"; import Modal from "../ui/Modal"; import Input from "../ui/Input"; const CheckUsername = ({ show, onSetShow, }: { show: boolean; onSetShow: (state: boolean) => void; }) => { const { user, setUsername, checkUsernameValidity } = useUser(); const [input, setInput] = useState(""); const [invalidUsername, setInvalidUsername] = useState(false); const onUsernameSet = async (username: string) => { if (!user) return; try { await setUsername(user.uid, username); onSetShow(false); } catch (error) { toast.error("Error setting username"); setInvalidUsername(true); } }; const handleSaveUsername = async () => { try { const isValid = await checkUsernameValidity(input); if (!isValid) { toast.error("Username is not valid"); setInvalidUsername(true); return; } await onUsernameSet(input); } catch (error) { toast.error("Error checking username"); } }; return ( {invalidUsername && (

Username is not valid or already taken

)} setInput(e.target.value)} />

Username must:

  • Begin with a lowercase letter (a-z).
  • Combine lowercase letters (a-z) and digits (0-9).
  • Optionally contain periods (.), underscores (_), or hyphens (-).
); }; export default CheckUsername; ================================================ FILE: components/dashboard/Sidebar/PostRow.tsx ================================================ import React from "react"; import Skeleton from "react-loading-skeleton"; import { useAtom, useAtomValue } from "jotai"; import RemoveMarkdown from "remove-markdown"; import { BiGlobe } from "react-icons/bi"; import { isSyncedAtom } from "@/stores/syncedAtom"; import { selectedNoteAtom } from "@/stores/postDataAtom"; type PostRowProps = { title: string; content: string; noteId: string; userId: string | undefined; isPublic: boolean; setShowSidebar: React.Dispatch>; }; const PostRow = ({ title, content, noteId, isPublic, setShowSidebar, }: PostRowProps) => { const [selectedNote, setSelectedNote] = useAtom(selectedNoteAtom); const synced = useAtomValue(isSyncedAtom); const switchNotesHandler = async (noteId: string) => { if (!synced) { const confirm = window.confirm( "You have unsaved changes. Are you sure you want to switch notes?" ); if (!confirm) return; } setSelectedNote((prev) => ({ ...prev, id: noteId })); window.innerWidth <= 768 && setShowSidebar(false); }; return (
switchNotesHandler(noteId)} >
switchNotesHandler(noteId)} >
{title === "" ? "Untitled" : title || }
{isPublic && }
); }; export default PostRow; ================================================ FILE: components/dashboard/Sidebar/ThemeChanger.tsx ================================================ import { useTheme } from "next-themes"; import Button from "../../ui/Button"; export default function ThemeChanger() { const { theme, setTheme } = useTheme(); return ( ); } ================================================ FILE: components/dashboard/Sidebar/index.tsx ================================================ import React, { useEffect, useState } from "react"; import Link from "next/link"; import { useRouter } from "next/router"; import { useAtom, useAtomValue } from "jotai"; import Skeleton from "react-loading-skeleton"; import { toast } from "react-hot-toast"; import { IoMdAddCircle, IoMdRefreshCircle } from "react-icons/io"; import { BsChevronBarLeft } from "react-icons/bs"; import { IFirebaseAuth } from "@/types/components/firebase-hooks"; import { FEATURE_FLAGS } from "@/constants/feature-flags"; import { selectedNoteAtom } from "@/stores/postDataAtom"; import UserMenu from "@/components/common/UserMenu"; import IconButton from "@/components/ui/IconButton"; import useNotes from "@/components/hooks/useNotes"; import { isSyncedAtom } from "@/stores/syncedAtom"; import BetaBadge from "@/components/ui/BetaBadge"; import useUser from "@/components/hooks/useUser"; import Button from "@/components/ui/Button"; import PostRow from "./PostRow"; interface SidebarProps { showSidebar: boolean; setShowSidebar: React.Dispatch>; } const Sidebar = ({ showSidebar, setShowSidebar, }: SidebarProps & IFirebaseAuth) => { const router = useRouter(); const { user, publicUserDetails } = useUser(); const [mounted, setMounted] = useState(false); const [createPostLoading, setCreatePostLoading] = useState(false); const [selectedNote, setSelectedNote] = useAtom(selectedNoteAtom); const synced = useAtomValue(isSyncedAtom); const { notes, createNote, refreshNotes } = useNotes({ userId: user?.uid }); useEffect(() => { if (!selectedNote.id) return; router.push(`/dashboard/?post=${selectedNote.id}`, undefined, { shallow: true, }); }, [selectedNote.id]); useEffect(() => { if (!router.query.post) return; setSelectedNote((prev) => ({ ...prev, id: router.query.post as string })); }, [router.query.post]); useEffect(() => { refreshNotes(); }, [synced, selectedNote.id]); const newPostClickHandler = async () => { setCreatePostLoading(true); const newId = await createNote(); await refreshNotes(); if (!newId) { toast.error("Failed to create new post"); return; } setSelectedNote((prev) => ({ ...prev, id: newId })); setCreatePostLoading(false); window.innerWidth <= 768 && setShowSidebar(false); }; useEffect(() => { setMounted(true); }, []); return ( ); }; export default Sidebar; ================================================ FILE: components/dashboard/TextArea/EditorButtons.tsx ================================================ import React, { useState } from "react"; import { LuBold, LuLink, LuCheckSquare, LuCode, LuHeading1, LuHeading2, LuHeading3, LuHeading4, LuImage, LuItalic, LuList, LuListOrdered, LuMinus, LuQuote, LuStrikethrough, } from "react-icons/lu"; import Toggle from "@/components/ui/Toggle"; import { Editor } from "@tiptap/react"; import Modal from "../../ui/Modal"; import Input from "../../ui/Input"; type EditorButtonsProps = { shiftRight?: boolean; editor: Editor | null; }; const EditorButtons = ({ shiftRight, editor }: EditorButtonsProps) => { const [isOpen, setIsOpen] = useState(false); const [title, setTitle] = useState(""); const [url, setUrl] = useState(""); // Image preview states const [isUrlPromptOpen, setIsUrlPromptOpen] = useState(false); const [isLinkPreview, setIsLinkPreview] = useState(false); if (!editor) return <>; return (
{/* */} { isLinkPreview ? editor.chain().setLinkPreview({ url: url }).run() : editor.chain().insertContent(`[${url}](${url})`).run(); setIsUrlPromptOpen(false); }} >
Link Preview: setIsLinkPreview((prev) => !prev)} />
setUrl(e.target.value)} />
{ editor.chain().focus().setImage({ src: url, title }).run(); setIsOpen(false); }} >
setTitle(e.target.value)} /> setUrl(e.target.value)} />
); }; export default EditorButtons; ================================================ FILE: components/dashboard/TextArea/LinkPreview.tsx ================================================ import { LuLink } from "react-icons/lu"; import { NodeViewWrapper, ReactNodeViewRenderer, Node, mergeAttributes, } from "@tiptap/react"; import React, { useEffect, useState } from "react"; const LinkPreviewCard = ({ node }: { node: any }) => { const { url } = node.attrs; const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [image, setImage] = useState( "https://placehold.co/900x600/000000/FFF?text=writedown&font=raleway/jpeg" ); const sanitizedUrl = url.split("/").slice(0, 3).join("/"); useEffect(() => { (async () => { const { title, description, image } = await fetch( `/api/link-preview?url=${url}` ).then((res) => res.json()); setTitle(title); setDescription(description); setImage(image); })(); }, []); return ( {image && (
{`${title}-preview`}
)}
{title}
{description}

{sanitizedUrl}

); }; declare module "@tiptap/core" { interface Commands { linkPreview: { /** * @example editor.commands.setLinkPreview({ url: 'https://example.com' }) */ setLinkPreview: ({ url }: { url: string }) => ReturnType; }; } } export const LinkPreview = Node.create({ name: "linkPreview", priority: 1000, group: "block", content: "inline*", addAttributes() { return { url: { default: null, }, }; }, parseHTML() { return [{ tag: "div" }]; }, renderHTML({ HTMLAttributes }) { return [ "div", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), ]; }, addNodeView() { return ReactNodeViewRenderer(LinkPreviewCard); }, addCommands() { return { setLinkPreview: ({ url }) => ({ commands }) => { return commands.setNode(this.name, { url }); }, }; }, }); ================================================ FILE: components/dashboard/TextArea/PostButtons.tsx ================================================ import React, { useEffect, useState } from "react"; import { useTheme } from "next-themes"; import { useAtom } from "jotai"; import Skeleton from "react-loading-skeleton"; import { toast } from "react-hot-toast"; import { IoMdCheckmarkCircle, IoMdCopy, IoMdRefresh, IoMdRefreshCircle, IoMdSend, IoMdTrash, } from "react-icons/io"; import { selectedNoteAtom } from "@/stores/postDataAtom"; import useNotes from "@/components/hooks/useNotes"; import { isSyncedAtom } from "@/stores/syncedAtom"; import useUser from "@/components/hooks/useUser"; import Button from "@/components/ui/Button"; import Toggle from "@/components/ui/Toggle"; import Modal from "@/components/ui/Modal"; import { Editor } from "@tiptap/react"; type PostButtonsProps = { shiftRight?: boolean; editor: Editor | null; }; export const formatTimeStamp = (time: number | undefined) => { if (!time) return "never"; const formattingOptions: Intl.DateTimeFormatOptions = { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", hour12: true, }; const formattedDate = new Date(time).toLocaleString( "en-US", formattingOptions ); return formattedDate; }; const PostButtons = ({ shiftRight, editor }: PostButtonsProps) => { // HOOKS const { theme } = useTheme(); // LOCAL STATE const [lastUpdated, setLastUpdated] = useState(null); const [showPublishModal, setShowPublishModal] = useState(false); const [downloadLoading, setDownloadLoading] = useState(false); // ATOMIC STATE const [synced, setSynced] = useAtom(isSyncedAtom); const [selectedNote, setSelectedNote] = useAtom(selectedNoteAtom); const { user, publicUserDetails } = useUser(); // CUSTOM HOOKS const { notes, updateNote, deleteNote, refreshNotes } = useNotes({ userId: user?.uid, }); // EFFECTS useEffect(() => { if (!selectedNote.lastUpdated) return; const formattedDate = formatTimeStamp(selectedNote.lastUpdated); setLastUpdated(formattedDate); }, [selectedNote.lastUpdated, selectedNote.id]); /** * Saves the note if not already synced */ const saveNoteHandler = async () => { setSelectedNote((prev) => ({ ...prev, isPublic: !prev.isPublic, })); if (!selectedNote.id || !notes?.find((note) => note.id === selectedNote.id)) return; setSynced(false); await updateNote({ id: selectedNote.id, title: selectedNote.title, content: selectedNote.content, public: selectedNote.isPublic, }); refreshNotes(); setSynced(true); }; /** * Deletes the note and selects the next note in the list */ const deleteNoteHandler = async () => { if (!notes || !selectedNote.id) return; // Confirm deletion const confirm = window.confirm( "Are you sure you want to delete this post?" ); if (!confirm) return; await deleteNote(selectedNote.id); await refreshNotes(); toast.success("Deleted Post!", { iconTheme: { primary: "#f00", secondary: "#ffffff", }, }); const noteIndex = notes.findIndex((note) => note.id === selectedNote.id); const newIndex = noteIndex > 0 ? noteIndex - 1 : noteIndex + 1; setSelectedNote((prev) => ({ ...prev, id: notes[0]?.id || "" })); }; const downloadPDFHandler = async () => { if (!editor) return; setDownloadLoading(true); const content = document.querySelector("#writedown-editor") as HTMLElement; if (!content) return; // const originalColor = content.style.color; const originalBgColor = content.style.backgroundColor; import("html2pdf.js").then((html2pdf) => { // content.style.color = "#000 !important"; content.style.backgroundColor = theme === "dark" ? "#000" : "#fff"; html2pdf .default() .set({ margin: 1, filename: `${selectedNote.title}-${lastUpdated}.pdf`, image: { type: "jpeg", quality: 0.98 }, jsPDF: { compress: true, backgroundColor: "#000" }, enableLinks: true, }) .from(content) .save() .then(() => { // content.style.color = originalColor; content.style.backgroundColor = originalBgColor; }) .finally(() => { setDownloadLoading(false); }); }); }; const downloadMarkdownHandler = () => { if (!editor) return; setDownloadLoading(true); const markdown = selectedNote.content; if (!markdown) return; const blob = new Blob([markdown], { type: "text/plain" }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = `${selectedNote.title}-${lastUpdated}.md`; a.click(); setDownloadLoading(false); }; const downloadHTMLHandler = () => { if (!editor) return; setDownloadLoading(true); const html = editor.getHTML(); if (!html) return; const blob = new Blob([html], { type: "text/plain" }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = `${selectedNote.title}-${lastUpdated}.html`; a.click(); setDownloadLoading(false); }; return (
{/* LAST UPDATED */} {lastUpdated ? (

Last Updated {lastUpdated}

) : ( )} {/* ACTION BUTTONS */}
{/* SAVE BUTTON */} {/* SAVE BUTTON */}

{ if (!selectedNote.isPublic) return; toast.success("Copied link to clipboard!"); const isDev = process.env.NODE_ENV === "development"; navigator.clipboard.writeText( isDev ? `http://localhost:3000/${ publicUserDetails?.username || publicUserDetails?.uid }/posts/${selectedNote.id}` : `https://writedown.app/${ publicUserDetails?.username || publicUserDetails?.uid }/posts/${selectedNote.id}` ); }} >

{/* PROD */} {process.env.NODE_ENV !== "development" && selectedNote.isPublic && `https://writedown.app/${ publicUserDetails?.username || publicUserDetails?.uid }/posts/${selectedNote.id}`} {process.env.NODE_ENV !== "development" && !selectedNote.isPublic && `https://writedown.app/...`} {/* DEV */} {process.env.NODE_ENV === "development" && selectedNote.isPublic && `http://localhost:3000/${ publicUserDetails?.username || publicUserDetails?.uid }/posts/${selectedNote.id}`} {process.env.NODE_ENV === "development" && !selectedNote.isPublic && `http://localhost:3000/...`}
{selectedNote.isPublic && ( )}

); }; export default PostButtons; ================================================ FILE: components/dashboard/TextArea/index.tsx ================================================ import { selectedNoteAtom } from "@/stores/postDataAtom"; import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight"; import DetailsContent from "@tiptap-pro/extension-details-content"; import DetailsSummary from "@tiptap-pro/extension-details-summary"; import WritedownEditor from "@/components/ui/WritedownEditor"; import Mathematics from "@tiptap-pro/extension-mathematics"; import { useAuthState } from "react-firebase-hooks/auth"; import { LinkPreview } from "./LinkPreview"; import UniqueId from "@tiptap-pro/extension-unique-id"; import Details from "@tiptap-pro/extension-details"; import IconButton from "@/components/ui/IconButton"; import useNotes from "@/components/hooks/useNotes"; import TaskList from "@tiptap/extension-task-list"; import TaskItem from "@tiptap/extension-task-item"; import { isSyncedAtom } from "@/stores/syncedAtom"; import { BsChevronBarLeft } from "react-icons/bs"; import Emoji from "@tiptap-pro/extension-emoji"; import StarterKit from "@tiptap/starter-kit"; import { createLowlight } from "lowlight"; import Image from "@tiptap/extension-image"; import EditorButtons from "./EditorButtons"; import { Markdown } from "tiptap-markdown"; import Code from "@tiptap/extension-code"; import Link from "@tiptap/extension-link"; import { useEditor } from "@tiptap/react"; import React, { useEffect } from "react"; import PostButtons from "./PostButtons"; import { auth } from "@/lib/firebase"; import { useAtom } from "jotai"; const lowlight = createLowlight(); type TextAreaProps = { shiftRight: boolean; setShiftRight: React.Dispatch>; }; const TextArea = ({ shiftRight, setShiftRight }: TextAreaProps) => { const [user] = useAuthState(auth); const [selectedNote, setSelectedNote] = useAtom(selectedNoteAtom); const [synced, setSynced] = useAtom(isSyncedAtom); const { notes, updateNote, createNote, refreshNotes } = useNotes({ userId: user?.uid, }); // EDITOR OPTIONS const editor = useEditor({ editorProps: { attributes: { class: "prose !max-h-none min-h-screen !max-w-none p-2 dark:prose-invert focus:outline-none", id: "writedown-editor", }, }, extensions: [ StarterKit.configure({ heading: { levels: [1, 2, 3, 4, 5, 6], HTMLAttributes: { class: "font-semibold", }, }, paragraph: { HTMLAttributes: {}, }, }), TaskList.configure({}), TaskItem.configure({ nested: true, }), Link.configure({ protocols: ["ftp", "mailto"], autolink: true, linkOnPaste: true, HTMLAttributes: { class: "text-sky-500 underline cursor-pointer", target: "_blank", rel: "noopener noreferrer", }, }), Image.configure({ inline: true, allowBase64: false, }), Code.configure({ HTMLAttributes: {}, }), CodeBlockLowlight.configure({ lowlight, HTMLAttributes: { languageClassPrefix: "language-", }, }), Mathematics, Details, DetailsSummary, DetailsContent, Emoji, UniqueId, Markdown.configure({ html: true, tightLists: true, tightListClass: "tight", bulletListMarker: "-", linkify: true, breaks: true, transformPastedText: true, transformCopiedText: true, }), LinkPreview, ], content: selectedNote.content, onUpdate: ({ editor }) => { if (editor) { setSelectedNote((prev) => ({ ...prev, content: editor.storage.markdown.getMarkdown(), })); } }, }); // EFFECTS useEffect(() => { const alertUser = (e: BeforeUnloadEvent) => { e.preventDefault(); }; if (!synced) { window.addEventListener("beforeunload", alertUser); } else { window.removeEventListener("beforeunload", alertUser); } return () => { window.removeEventListener("beforeunload", alertUser); }; }, [synced]); useEffect(() => { if (!notes) return; notes.length === 0 && createNote().then((id) => { if (!id) { return; } setSelectedNote((prev) => ({ ...prev, id })); }); }, [notes]); useEffect(() => { if (!notes) return; if (notes.length > 0 && !selectedNote.id) { setSelectedNote((prev) => ({ ...prev, id: notes[0].id, content: notes[0].content, title: notes[0].title, lastUpdated: notes[0].updatedAt, isPublic: notes[0].public, })); return; } if (!selectedNote.id) return; const foundExistingNote = notes.find((note) => note.id === selectedNote.id); if (!foundExistingNote) return; setSelectedNote((prev) => ({ ...prev, content: foundExistingNote.content, title: foundExistingNote.title, lastUpdated: foundExistingNote.updatedAt, isPublic: foundExistingNote.public, })); }, [notes, selectedNote.id]); useEffect(() => { if (!selectedNote.id || !user) return; const currentNote = notes?.find( (note) => selectedNote.content === note.content && selectedNote.title === note.title && selectedNote.lastUpdated === note.updatedAt && selectedNote.isPublic === note.public ); let debounceSave: NodeJS.Timeout; const isNoteUnchanged = currentNote?.id === selectedNote.id; if (isNoteUnchanged) { setSynced(true); return; } else { debounceSave = setTimeout(() => { setSynced(false); updateNote({ id: selectedNote.id, title: selectedNote.title, content: selectedNote.content, public: selectedNote.isPublic, }); setSynced(true); }, 3000); setSynced(false); } return () => { clearTimeout(debounceSave); }; }, [notes, selectedNote.title, selectedNote.content, selectedNote.isPublic]); useEffect(() => { refreshNotes(); }, [selectedNote.id]); return (
setShiftRight(true)} > {/*BUTTONS AND OTHER STATUS ELEMENTS*/} {/*EDITOR BUTTONS AND THE EDITOR*/}
{/* TITLE OF THE POST */} { setSelectedNote((prev) => ({ ...prev, title: e.target.value, })); }} placeholder="Untitled" value={selectedNote.title} /> {/* SEPARATOR */}
); }; export default TextArea; ================================================ FILE: components/home/FeatureCard.tsx ================================================ import React from "react"; type FeatureCardProps = { icon: React.ReactNode; title: string; description: string; }; const FeatureCard = ({ icon, title, description }: FeatureCardProps) => { return (
{icon} {title}

{description}

); }; export default FeatureCard; ================================================ FILE: components/home/Features.tsx ================================================ import { FiBox, FiCloudLightning, FiEye, FiGithub, FiGlobe, FiPackage, FiRefreshCcw, FiSmile, FiSun, FiUserCheck, FiWifiOff, } from "react-icons/fi"; import FeatureCard from "./FeatureCard"; import React from "react"; const Features = () => { return (
} title="Free and Open Source" description="Sharing is caring, writedown is completely free and open source and licensed under AGPLv3." /> } title="Synced on all your devices" description="All your notes are synced on all your devices. You can access them from anywhere." /> } title="Offline Support" description="Write and save notes even when you are away from the internet!" /> } title="Live Markdown" description="Writedown supports Markdown. You can write markdown and preview it in real-time." /> } title="Easy to Use" description="Writedown is easy to use with a beautiful interface. Get started in just 5 seconds!" />
); }; export default Features; ================================================ FILE: components/home/Footer.tsx ================================================ import { FEATURE_FLAGS } from "@/constants/feature-flags"; import BetaBadge from "../ui/BetaBadge"; import { auth } from "@/lib/firebase"; import Link from "next/link"; import React from "react"; const Footer = ({ className }: { className?: string }) => { return (
writedown {FEATURE_FLAGS.beta && }
  • {auth.currentUser ? "Write Down" : "Login"}
  • GitHub

© {new Date().getFullYear()}{" "} writedown . All rights reserved.

); }; export default Footer; ================================================ FILE: components/home/HeroSection.tsx ================================================ import { Parallax } from "react-scroll-parallax"; import { auth } from "@/lib/firebase"; import Button from "../ui/Button"; import Link from "next/link"; import React from "react"; const HeroSection = () => { return (

Upgrade Your Dear Diary

All your notes, synced on all your devices.
Free, easy and fast.

Writedown Screenshot Writedown Screenshot
); }; export default HeroSection; ================================================ FILE: components/home/Navbar.tsx ================================================ import { FEATURE_FLAGS } from "@/constants/feature-flags"; import { FiMoon, FiSun } from "react-icons/fi"; import BetaBadge from "../ui/BetaBadge"; import { useTheme } from "next-themes"; import { auth } from "@/lib/firebase"; import Button from "../ui/Button"; import Link from "next/link"; import React from "react"; import useMounted from "../hooks/useMounted"; const Navbar = () => { const { theme, setTheme } = useTheme(); const isMounted = useMounted(); return ( ); }; export default Navbar; ================================================ FILE: components/hooks/UsePaginateQuery.ts ================================================ import { startAfter, query, getDocs, DocumentData, QueryDocumentSnapshot, } from "firebase/firestore"; import { useState, useEffect, useCallback, useRef, useMemo } from "react"; import { Query } from "firebase/firestore"; const usePaginateQuery = (queryFn: () => Query, pageLoaded: boolean) => { const [data, setData] = useState[]>([]); const isMountedRef = useRef(false); const lastItemRef = useRef(null); const [isLoading, setisLoading] = useState(); const [errorMsg, setErrorMsg] = useState(); const resetStates = () => { setData([]); setisLoading(false); }; useEffect(() => { if (isMountedRef.current === true) return; async function fetchQuery() { try { isMountedRef.current = true; setisLoading(true); const q = query(queryFn()); const querySnapshot = await getDocs(q); setData([...querySnapshot.docs]); lastItemRef.current = querySnapshot.docs[querySnapshot.docs.length - 1]; setisLoading(false); } catch (error: any) { resetStates(); setErrorMsg(error.code); } } fetchQuery(); }, [queryFn]); const more = useCallback(async () => { try { setisLoading(true); const next = query(queryFn(), startAfter(lastItemRef.current)); const querySnapshot = await getDocs(next); setData([...data, ...querySnapshot.docs]); lastItemRef.current = querySnapshot.docs[querySnapshot.docs.length - 1]; setisLoading(false); } catch (error: any) { resetStates(); setErrorMsg(error.code); } }, [data, queryFn]); return useMemo(() => { return { more, isLoading, data: data ? data : [], errorMsg, }; }, [more, isLoading, data, errorMsg]); }; export default usePaginateQuery; ================================================ FILE: components/hooks/useMounted.ts ================================================ import { useEffect, useState } from "react"; const useMounted = () => { const [isMounted, setIsMounted] = useState(false); useEffect(() => { setIsMounted(true); }, []); return isMounted; }; export default useMounted; ================================================ FILE: components/hooks/useNotes.ts ================================================ import { collection, deleteDoc, doc, getDoc, orderBy, query, setDoc, updateDoc, } from "firebase/firestore"; import { useCollectionDataOnce } from "react-firebase-hooks/firestore"; import { NoteDocument } from "@/types/utils/firebaseOperations"; import { notesConverter } from "@/utils/firestoreDataConverter"; import { selectedNoteAtom } from "@/stores/postDataAtom"; import { toast } from "react-hot-toast"; import { db } from "@/lib/firebase"; import { useCallback } from "react"; import { useAtom, useSetAtom } from "jotai"; type UseNotesProps = { userId: string | undefined; }; export const useNotes = ({ userId }: UseNotesProps) => { const [selectedNote, setSelectedNote] = useAtom(selectedNoteAtom); const [notes, loading, error, snapshot, refreshNotes] = useCollectionDataOnce( userId ? query( collection(db, "users", userId, "notes"), orderBy("updatedAt", "desc") ).withConverter(notesConverter) : null ); const createNote = useCallback(async () => { if (!userId) return; const id = crypto.randomUUID(); const currentTime = new Date().getTime(); const noteData: NoteDocument = { id, content: "", public: false, slug: id, title: "", userId, createdAt: currentTime, updatedAt: currentTime, }; const notesRef = doc(db, "users", userId, "notes", id); try { // Create a document inside channelsRef array await setDoc(notesRef, noteData, { merge: true }); refreshNotes(); return id; } catch (error) { toast.error("Failed to create post, please try again later."); } }, [userId]); const updateNote = useCallback( async (note: { id: string; title: string; content: string; public?: boolean; }) => { if (!userId || !note) return; const notesRef = doc(db, "users", userId, "notes", note.id); const currentTime = new Date().getTime(); const updatedContent = note.public ? { ...note, updatedAt: currentTime, publishedAt: currentTime } : { ...note, updatedAt: currentTime }; try { // Create a document inside channelsRef array await updateDoc(notesRef, updatedContent); setSelectedNote((prev) => ({ ...prev, lastUpdated: currentTime, })); } catch (error) { toast.error("Failed to update post, please try again later."); } }, [userId] ); const deleteNote = useCallback( async (noteId: string) => { if (!userId || !noteId) return; const notesRef = doc(db, "users", userId, "notes", noteId); try { // Create a document inside channelsRef array await deleteDoc(notesRef); refreshNotes(); } catch (error) { toast.error("Failed to delete post, please try again later."); } }, [userId] ); return { notes, refreshNotes, notesLoading: loading, notesError: error, notesSnapshot: snapshot, createNote, updateNote, deleteNote, }; }; export default useNotes; ================================================ FILE: components/hooks/usePublicNotes.ts ================================================ import { useDocumentData } from "react-firebase-hooks/firestore"; import { doc } from "firebase/firestore"; import { db } from "@/lib/firebase"; type UseNotesProps = { noteId: string; }; export const usePublicNotes = ({ noteId }: UseNotesProps) => { const [publicNotes, loading, error, snapshot] = useDocumentData( noteId ? doc(db, "public_notes", noteId) : null ); const [note, note_loading, note_error, note_snapshot] = useDocumentData( publicNotes ? doc(db, "users", publicNotes.userId, "notes", noteId) : null ); return { publicNotes, note, publicNotesLoading: loading, publicNotesError: error, publicNotesSnapshot: snapshot, notesLoading: note_loading, notesError: note_error, notesSnapshot: note_snapshot, }; }; export default usePublicNotes; ================================================ FILE: components/hooks/useUser.ts ================================================ import { deleteDoc, doc, getDoc, writeBatch } from "firebase/firestore"; import { userDocConverter } from "@/utils/firestoreDataConverter"; import { useDocumentData } from "react-firebase-hooks/firestore"; import { UserDocument } from "@/types/utils/firebaseOperations"; import { useAuthState } from "react-firebase-hooks/auth"; import { User } from "firebase/auth"; import { db } from "@/lib/firebase"; import { auth } from "@/lib/firebase"; export const useUser = () => { const [user] = useAuthState(auth); const [publicUserDetails] = useDocumentData( user ? doc(db, "users", user?.uid).withConverter(userDocConverter) : null ); /** * Create a new user document in firestore with * default values * @param user */ const checkUserExists = async (user: User) => { const userRef = doc(db, "users", user.uid); try { const userSnap = await getDoc(userRef); return userSnap.exists(); } catch (error) { throw error; } }; const createUser = async (user: User) => { if (!user) { throw new Error("User not found"); } try { const batch = writeBatch(db); batch.set(doc(db, "users", user.uid), { uid: user.uid, photoURL: user.photoURL, displayName: user.displayName, }); // TODO: Create a {username: uid} doc in usernames collection batch.set(doc(db, "users", user.uid, "extras", "private"), { email: user.email, createdAt: new Date().toISOString(), }); await batch.commit(); } catch (error) { throw error; } }; /** * Set username for a user * @param userId * @param userName */ const setUsername = async (userId: string, userName: string) => { if (!userId) { throw new Error("User not found"); } const batch = writeBatch(db); // Store username->uid mapping const usernameRef = doc(db, "usernames", userName); batch.set(usernameRef, { uid: userId, }); // Store username in user document const userRef = doc(db, "users", userId); batch.update(userRef, { username: userName, }); // Commit batch write try { await batch.commit(); } catch (error) { // Rollback username->uid mapping deleteDoc(usernameRef); throw error; } }; /** * Check if a username is available * @param userName */ const checkUsernameValidity = async (userName: string) => { if (!userName) return false; const usernameDoc = doc(db, "usernames", userName); const usernameSnap = await getDoc(usernameDoc); return usernameSnap.exists() ? false : true; }; /** * Check if a user has a username * @param user */ const hasUsername = async (user: User) => { if (!user) { throw new Error("User not found"); } const userRef = doc(db, "users", user.uid); try { const userSnap = await getDoc(userRef); const userData = userSnap.data() as UserDocument; return userData && userData.username ? true : false; } catch (error) { throw error; } }; return { user, /** The user document with public details */ publicUserDetails, createUser, setUsername, checkUsernameValidity, hasUsername, checkUserExists, }; }; export default useUser; ================================================ FILE: components/login/InfoSidebar.tsx ================================================ import React from "react"; const InfoSidebar = () => { return (

Simplicity starts here

A fast, easy and free way to write notes with offline support, cloud sync and real-time markdown preview.

Writedown Screenshot Writedown Screenshot
); }; export default InfoSidebar; ================================================ FILE: components/login/SignInArea.tsx ================================================ import { useSignInWithGithub, useSignInWithGoogle, } from "react-firebase-hooks/auth"; import { authErrorCodes } from "@/constants/firebase-auth-error-codes"; import { AiFillGithub } from "react-icons/ai"; import { FcGoogle } from "react-icons/fc"; import React, { useEffect } from "react"; import BetaBadge from "../ui/BetaBadge"; import toast from "react-hot-toast"; import { auth } from "@/lib/firebase"; import Button from "../ui/Button"; import Link from "next/link"; const SignInArea = () => { // GOOGLE SIGN IN HOOK const [signInWithGoogle, googleUser, googleLoading, googleError] = useSignInWithGoogle(auth); // GITHUB SIGN IN HOOK const [signInWithGithub, githubUser, githubLoading, githubError] = useSignInWithGithub(auth); const login = (type: "google" | "github") => { if (type === "google") { signInWithGoogle(); } else if (type === "github") { signInWithGithub(); } }; useEffect(() => { const error = githubError || googleError; if (!error) return; toast.error( authErrorCodes[error.code as keyof typeof authErrorCodes] || error.message ); }, [githubError, googleError]); return (
writedown

Login with your familiar services:

); }; export default SignInArea; ================================================ FILE: components/ui/Badge.tsx ================================================ import React, { HTMLAttributes } from "react"; type BadgeProps = { children: React.ReactNode; color: "yellow" | "green" | "red" | "blue" | "purple" | "pink"; }; const Badge = ({ children, color }: BadgeProps) => { const getColorClasses = () => { switch (color) { case "yellow": return "bg-yellow-100 text-yellow-800"; case "green": return "bg-green-100 text-green-800"; case "red": return "bg-red-100 text-red-800"; case "blue": return "bg-blue-100 text-blue-800"; case "purple": return "bg-purple-100 text-purple-800"; case "pink": return "bg-pink-100 text-pink-800"; default: return "bg-gray-100 text-gray-800"; } }; return (
{children}
); }; export default Badge; ================================================ FILE: components/ui/BetaBadge.tsx ================================================ import React from "react"; type BetaBadgeProps = { pulse?: boolean; }; const BetaBadge = ({ pulse }: BetaBadgeProps) => { return ( BETA ); }; export default BetaBadge; ================================================ FILE: components/ui/Button.tsx ================================================ import React, { ButtonHTMLAttributes } from "react"; interface ButtonProps { variant?: "red" | "green" | "slate" | "blue"; size?: "sm"; children: React.ReactNode; className?: string; } const Button = ({ variant, size, children, className, ...rest }: ButtonProps & ButtonHTMLAttributes) => { const getButtonClass = () => { if (size === "sm") { switch (variant) { case "red": return "rounded-full py-1 px-3 text-sm font-medium text-red-500 ring-2 ring-red-500 transition-colors duration-300 hover:bg-red-100 bg-red-50 dark:bg-red-900/20 dark:text-red-400 dark:ring-red-400 dark:hover:bg-red-800/50"; case "green": return "rounded-full py-1 px-3 text-sm font-medium text-green-500 ring-2 ring-green-500 transition-colors duration-300 hover:bg-green-100 bg-green-50 dark:bg-green-900/20 dark:text-green-400 dark:ring-green-400 dark:hover:bg-green-800/50"; case "blue": return "rounded-full py-1 px-3 text-sm font-medium text-blue-500 ring-2 ring-blue-500 transition-colors duration-300 hover:bg-blue-100 bg-blue-50 dark:bg-blue-900/20 dark:text-blue-400 dark:ring-blue-400 dark:hover:bg-blue-800/50"; case "slate": return "rounded-full py-1 px-3 text-sm font-medium text-slate-500 ring-2 ring-slate-500 transition-colors duration-300 hover:bg-slate-100 bg-slate-50 dark:bg-slate-900/20 dark:text-slate-400 dark:ring-slate-400 dark:hover:bg-slate-800/50"; default: return "rounded-full py-1 px-3 text-sm font-medium text-slate-900 ring-2 ring-slate-900 transition-colors duration-300 hover:bg-slate-300"; } } switch (variant) { case "red": return "inline-flex items-center justify-center px-5 py-2.5 bg-white border rounded-full border-red-900 text-sm font-medium text-red-900 hover:bg-red-200 transition-all duration-300"; default: return "inline-flex items-center justify-center px-5 py-2.5 bg-slate-50 border rounded-full border-2 border-slate-900 text-sm font-medium text-slate-900 hover:bg-slate-200 transition-all duration-300 dark:bg-slate-900 dark:border-slate-50 dark:text-slate-100 dark:hover:bg-slate-800"; } }; return ( ); }; export default Button; ================================================ FILE: components/ui/IconButton.tsx ================================================ import React from "react"; type IconButtonProps = { children: React.ReactNode; extraClasses?: HTMLButtonElement["className"]; }; const IconButton = ({ children, extraClasses, ...rest }: IconButtonProps & React.ButtonHTMLAttributes) => { return ( ); }; export default IconButton; ================================================ FILE: components/ui/Input.tsx ================================================ import { InputHTMLAttributes } from "react"; import React from "react"; const Input = ({ label, id, small, ...rest }: InputHTMLAttributes & { id: string; label?: string; small?: boolean; }) => { return ( <> {label && ( )} ); }; export default Input; ================================================ FILE: components/ui/Loading.tsx ================================================ import darkLoadingAnimation from "@/animations/pencil-write-dark.json"; import loadingAnimation from "@/animations/pencil-write.json"; import { FEATURE_FLAGS } from "@/constants/feature-flags"; import BetaBadge from "./BetaBadge"; import Lottie from "lottie-react"; import React from "react"; const Loading = () => { return (

writedown {FEATURE_FLAGS.beta && }

); }; export default Loading; ================================================ FILE: components/ui/Modal.tsx ================================================ import { Dialog, Transition } from "@headlessui/react"; import Button from "./Button"; import React from "react"; interface ModalProps { title?: string; description?: string; saveHandler?: () => void; saveText?: string; closeText?: string; isOpen: boolean; setIsOpen: (isOpen: boolean) => void; undismissable?: boolean; children?: React.ReactNode; } const Modal = ({ title, description, saveText, saveHandler, closeText, isOpen, setIsOpen, undismissable, children, }: ModalProps) => { return ( { if (undismissable) { return; } setIsOpen(false); }} >
{title && ( {title} )}

{description}

{children}
{saveText && ( )} {closeText && ( )}
); }; export default Modal; ================================================ FILE: components/ui/Popover.tsx ================================================ import { Popover as HeadlessPopover, Transition } from "@headlessui/react"; import { Fragment } from "react"; type PopoverProps = { button?: React.ReactNode; buttonStyle?: string; openStyle?: string; reverse?: boolean; children: React.ReactNode; }; export default function Popover({ button, buttonStyle, openStyle, reverse = false, children, ...rest }: PopoverProps) { return ( {({ open }) => ( <> {button}
{children}
)}
); } ================================================ FILE: components/ui/Toggle.tsx ================================================ import { Switch } from "@headlessui/react"; import { useState } from "react"; type ToggleProps = { enabled: boolean; onChange: (arg: boolean) => void; screenReaderPrompt?: string; }; export default function Toggle({ enabled, onChange, screenReaderPrompt, }: ToggleProps) { return ( {screenReaderPrompt} ); } ================================================ FILE: components/ui/WritedownEditor.tsx ================================================ import { selectedNoteAtom } from "@/stores/postDataAtom"; import { NoteDocument } from "@/types/utils/firebaseOperations"; import { EditorContent, Editor } from "@tiptap/react"; import { useAtomValue } from "jotai"; import { useEffect } from "react"; interface editorProps { notes?: NoteDocument[] | undefined; editor: Editor | null; } const WritedownEditor = ({ notes, editor }: editorProps) => { const selectedNote = useAtomValue(selectedNoteAtom); useEffect(() => { if (!editor) return; // If there are no notes or no selected note, clear the editor if (!notes || !selectedNote.id) { editor.commands.clearContent(); return; } // Replace the editor content with the current note content const currentNote = notes.find((note) => note.id === selectedNote.id); if (!currentNote) return; editor.commands.setContent(currentNote.content); }, [selectedNote.id, notes]); return ; }; export default WritedownEditor; ================================================ FILE: constants/channel-background-colors.ts ================================================ export const channelBackgroundColors = [ "from-teal-400 to-blue-500", "from-sky-500 to-indigo-600", "from-violet-500 to-fuchsia-500", "from-purple-500 to-pink-500", "from-green-700 to-green-400", "from-orange-400 to-yellow-200", ]; ================================================ FILE: constants/feature-flags.ts ================================================ export const FEATURE_FLAGS = { beta: process.env.NEXT_PUBLIC_FEATURE_FLAG_BETA === "true", }; ================================================ FILE: constants/firebase-auth-error-codes.ts ================================================ export const authErrorCodes = { "auth/claims-too-large": "The claims payload provided to setCustomUserClaims() exceeds the maximum allowed size of 1000 bytes.", "auth/email-already-exists": "The provided email is already in use by an existing user. Each user must have a unique email.", "auth/id-token-expired": "The provided Firebase ID token is expired.", "auth/id-token-revoked": "The Firebase ID token has been revoked.", "auth/account-exists-with-different-credential": "An account with this email address already exists, but it was registered using a different login method. Please log in using the appropriate method associated with this email address.", "auth/insufficient-permission": "The credential used to initialize the Admin SDK has insufficient permission to access the requested Authentication resource. Refer to Set up a Firebase project for documentation on how to generate a credential with appropriate permissions and use it to authenticate the Admin SDKs.", "auth/internal-error": "The Authentication server encountered an unexpected error while trying to process the request. The error message should contain the response from the Authentication server containing additional information. If the error persists, please report the problem to our Bug Report support channel.", "auth/invalid-argument": "An invalid argument was provided to an Authentication method. The error message should contain additional information.", "auth/invalid-claims": "The custom claim attributes provided to setCustomUserClaims() are invalid.", "auth/invalid-continue-uri": "The continue URL must be a valid URL string.", "auth/invalid-creation-time": "The creation time must be a valid UTC date string.", "auth/invalid-credential": "The credential used to authenticate the Admin SDKs cannot be used to perform the desired action. Certain Authentication methods such as createCustomToken() and verifyIdToken() require the SDK to be initialized with a certificate credential as opposed to a refresh token or Application Default credential. See Initialize the SDK for documentation on how to authenticate the Admin SDKs with a certificate credential.", "auth/invalid-disabled-field": "The provided value for the disabled user property is invalid. It must be a boolean.", "auth/invalid-display-name": "The provided value for the displayName user property is invalid. It must be a non-empty string.", "auth/invalid-dynamic-link-domain": "The provided dynamic link domain is not configured or authorized for the current project.", "auth/invalid-email": "The provided value for the email user property is invalid. It must be a string email address.", "auth/invalid-email-verified": "The provided value for the emailVerified user property is invalid. It must be a boolean.", "auth/invalid-hash-algorithm": "The hash algorithm must match one of the strings in the list of supported algorithms.", "auth/invalid-hash-block-size": "The hash block size must be a valid number.", "auth/invalid-hash-derived-key-length": "The hash derived key length must be a valid number.", "auth/invalid-hash-key": "The hash key must a valid byte buffer.", "auth/invalid-hash-memory-cost": "The hash memory cost must be a valid number.", "auth/invalid-hash-parallelization": "The hash parallelization must be a valid number.", "auth/invalid-hash-rounds": "The hash rounds must be a valid number.", "auth/invalid-hash-salt-separator": "The hashing algorithm salt separator field must be a valid byte buffer.", "auth/invalid-id-token": "The provided ID token is not a valid Firebase ID token.", "auth/invalid-last-sign-in-time": "The last sign-in time must be a valid UTC date string.", "auth/invalid-page-token": "The provided next page token in listUsers() is invalid. It must be a valid non-empty string.", "auth/invalid-password": "The provided value for the password user property is invalid.It must be a string with at least six characters.", "auth/invalid-password-hash": "The password hash must be a valid byte buffer.", "auth/invalid-password-salt": "The password salt must be a valid byte buffer", "auth/invalid-phone-number": "The provided value for the phoneNumber is invalid. It must be a non-empty E.164 standard compliant identifier string.", "auth/invalid-photo-url": "The provided value for the photoURL user property is invalid. It must be a string URL.", "auth/invalid-provider-data": "The providerData must be a valid array of UserInfo objects.", "auth/invalid-provider-id": "The providerId must be a valid supported provider identifier string.", "auth/invalid-oauth-responsetype": "Only exactly one OAuth responseType should be set to true.", "auth/invalid-session-cookie-duration": "The session cookie duration must be a valid number in milliseconds between 5 minutes and 2 weeks.", "auth/invalid-uid": "The provided uid must be a non-empty string with at most 128 characters.", "auth/invalid-user-import": "The user record to import is invalid.", "auth/maximum-user-count-exceeded": "The maximum allowed number of users to import has been exceeded.", "auth/missing-android-pkg-name": "An Android Package Name must be provided if the Android App is required to be installed.", "auth/missing-continue-uri": "A valid continue URL must be provided in the request.", "auth/missing-hash-algorithm": "Importing users with password hashes requires that the hashing algorithm and its parameters be provided.", "auth/missing-ios-bundle-id": "The request is missing a Bundle ID.", "auth/missing-uid": "A uid identifier is required for the current operation.", "auth/missing-oauth-client-secret": "The OAuth configuration client secret is required to enable OIDC code flow.", "auth/operation-not-allowed": "The provided sign-in provider is disabled for your Firebase project. Enable it from the Sign-in Method section of the Firebase console.", "auth/phone-number-already-exists": "The provided phoneNumber is already in use by an existing user. Each user must have a unique phoneNumber.", "auth/project-not-found": "No Firebase project was found for the credential used to initialize the Admin SDKs. Refer to Set up a Firebase project for documentation on how to generate a credential for your project and use it to authenticate the Admin SDKs.", "auth/reserved-claims": "One or more custom user claims provided to setCustomUserClaims() are reserved. For example, OIDC specific claims such as (sub, iat, iss, exp, aud, auth_time, etc) should not be used as keys for custom claims.", "auth/session-cookie-expired": "The provided Firebase session cookie is expired.", "auth/session-cookie-revoked": "The Firebase session cookie has been revoked.", "auth/uid-already-exists": "The provided uid is already in use by an existing user. Each user must have a unique uid.", "auth/unauthorized-continue-uri": "The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase Console.", "auth/user-not-found": "There is no existing user record corresponding to the provided identifier.", }; ================================================ FILE: declaration.d.ts ================================================ declare module "preline"; ================================================ FILE: docs/colors.md ================================================ # Mapping Colors from Light to Dark 50 - 900 100 - 800 200 - 700 300 - 600 400 - 500 500 - 400 600 - 300 700 - 200 800 - 100 900 - 50 950 - ================================================ FILE: docs/firebase.md ================================================ # Firebase Emulator Setup ## Setup 0. Don't use Windows and install Java 12+. 1. Install the Firebase CLI ```bash curl -sL firebase.tools | bash ``` 2. Login to Firebase ```bash firebase login ``` It'll ask you: `? Allow Firebase to collect CLI and Emulator Suite usage and error reporting information?` **Just say, "NO!"** 3. Initialize the Firebase project ```bash firebase init ``` Select Firestore and Emulators. Press enter to select default options. Then select authentication and firestore with spacebar and press enter. 4. Select the following options ```bash ? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. Functions: Configure and deploy Cloud Functions ? What language would you like to use to write Cloud Functions? JavaScript ? Do you want to use ESLint to catch probable bugs and enforce style? No ? Do you want to install dependencies with npm now? Yes ``` 5. Install the Firebase Emulator ```bash firebase setup:emulators:firestore ``` 6. Start the Firebase Emulator ```bash npm run firebase ``` ================================================ FILE: docs/tiptap.md ================================================ # TipTap Setup ## Setup 1. Create a TipTap account at [cloud.tiptap.dev](https://cloud.tiptap.dev/pro-extensions). 2. Create a new app and go to Pro Extensions. 3. Copy the token. 4. Open `~/.zshrc` or `~/.bashrc` and add the following line at the end: ```bash export TIPTAP_PRO_TOKEN="YOUR_TOKEN" ``` 5. Run the following command: ```bash source ~/.zshrc # OR source ~/.bashrc ``` 6. You're all set! Now you can use TipTap in your app. ================================================ FILE: firebase.json ================================================ { "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "emulators": { "auth": { "port": 9099, "host": "127.0.0.1" }, "firestore": { "port": 8080, "host": "127.0.0.1" }, "ui": { "enabled": true }, "singleProjectMode": true } } ================================================ FILE: firestore.indexes.json ================================================ { "indexes": [ { "collectionGroup": "messages", "queryScope": "COLLECTION_GROUP", "fields": [ { "fieldPath": "channelId", "order": "ASCENDING" }, { "fieldPath": "createdAt", "order": "DESCENDING" } ] } ], "fieldOverrides": [ { "collectionGroup": "messages", "fieldPath": "createdAt", "ttl": false, "indexes": [ { "order": "ASCENDING", "queryScope": "COLLECTION" }, { "order": "DESCENDING", "queryScope": "COLLECTION" }, { "arrayConfig": "CONTAINS", "queryScope": "COLLECTION" }, { "order": "DESCENDING", "queryScope": "COLLECTION_GROUP" } ] } ] } ================================================ FILE: firestore.rules ================================================ rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /users/{userId} { allow update: if request.auth.uid == userId; allow create: if request.auth != null; allow read; } match /users/{userId}/{document=**} { allow read, write: if request.auth.uid == userId; } function isValidUsername(username) { let isOwner = request.auth.uid == request.resource.data.uid; let isValidLength = username.size() >= 3 && username.size() <= 15; let isValidRegex = username.matches("^[a-z][a-z0-9]*([._-][a-z0-9]+)*$"); let isValidUserDoc = exists(/databases/$(database)/documents/users/$(request.auth.uid)); return isOwner && isValidLength && isValidRegex && isValidUserDoc; } match /usernames/{username} { allow read; allow create: if isValidUsername(username); } match /users/{userId}/notes/{noteId} { allow write: if request.auth.uid == userId; allow read: if isPublicNote() || request.auth.uid == userId; } function isPublicNote() { return resource.data.public == true; } } } ================================================ FILE: html2pdf.js.d.ts ================================================ declare module "html2pdf.js"; ================================================ FILE: lib/firebase.ts ================================================ import { Firestore, getFirestore } from "firebase/firestore"; import { FirebaseApp, getApps, initializeApp } from "firebase/app"; import "firebase/firestore"; import { Auth, getAuth } from "firebase/auth"; const firebaseConfig = { apiKey: "AIzaSyBbfVs3Q1NlARdE5wXZb4DLXonfcwMu2CI", authDomain: "writedown-4a984.firebaseapp.com", databaseURL: "https://writedown-4a984-default-rtdb.firebaseio.com", projectId: "writedown-4a984", storageBucket: "writedown-4a984.appspot.com", messagingSenderId: "991441150383", appId: "1:991441150383:web:73ab73141aee5c3bafcf5a", }; let firebaseApp: FirebaseApp; let db: Firestore; let auth: Auth; const currentApps = getApps(); if (currentApps.length <= 0) { firebaseApp = initializeApp(firebaseConfig); db = getFirestore(firebaseApp); auth = getAuth(firebaseApp); } else { firebaseApp = currentApps[0]; db = getFirestore(firebaseApp); auth = getAuth(firebaseApp); } export { db, auth, firebaseApp }; ================================================ FILE: next.config.js ================================================ /** @type {import('next').NextConfig} */ const runtimeCaching = require("next-pwa/cache"); const withPWA = require("next-pwa")({ dest: "public", runtimeCaching, register: true, disable: process.env.NODE_ENV === "development", }); module.exports = withPWA({ swcMinify: true, }); ================================================ FILE: package.json ================================================ { "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "firebase": "firebase emulators:start", "stop": "for port in 3000 3001 3002 4000 4001 4002 9150; do lsof -t -i:$port | xargs -r kill; done", "prepare": "husky install", "cypress": "cypress open" }, "dependencies": { "@tiptap-pro/extension-details": "^2.8.1", "@tiptap-pro/extension-details-content": "^2.18.0-beta.6", "@tiptap-pro/extension-details-summary": "^2.8.1", "@tiptap-pro/extension-emoji": "^2.18.0-beta.6", "@tiptap-pro/extension-mathematics": "^2.18.0-beta.6", "@tiptap-pro/extension-unique-id": "^2.18.0-beta.6", "@tiptap/extension-code-block-lowlight": "^2.11.7", "@tiptap/extension-image": "^2.11.7", "@tiptap/extension-link": "^2.3.1", "@tiptap/extension-task-item": "^2.11.7", "@tiptap/extension-task-list": "^2.11.7", "@tiptap/react": "^2.11.7", "@tiptap/starter-kit": "^2.11.7", "@vercel/og": "^0.6.8", "cheerio": "^1.0.0", "firebase": "^11.6.0", "html2pdf.js": "^0.10.3", "jotai": "^2.12.2", "katex": "^0.16.21", "lottie-react": "^2.4.1", "lowlight": "^3.3.0", "next": "^14.2.26", "next-pwa": "^5.6.0", "next-themes": "^0.4.6", "react": "^18.3.1", "react-dom": "^18.3.1", "react-firebase-hooks": "^5.1.1", "react-icons": "^5.5.0", "react-markdown": "^10.1.0", "react-scroll-parallax": "^3.4.5", "remark-gfm": "^4.0.1", "remove-markdown": "^0.6.0", "tiptap-markdown": "^0.8.10" }, "devDependencies": { "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", "@types/node": "20.12.8", "@types/react": "18.3.1", "@types/react-dom": "18.3.0", "@types/remove-markdown": "^0.3.4", "autoprefixer": "^10.4.19", "eslint": "8.57.0", "eslint-config-next": "14.2.3", "husky": "^9.0.11", "postcss": "^8.4.38", "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.14", "pretty-quick": "^4.0.0", "tailwindcss": "^3.4.3", "typescript": "5.4.5" }, "volta": { "node": "20.12.2" } } ================================================ FILE: pages/[username]/posts/[postId].tsx ================================================ import { useEffect, useState } from "react"; import { useRouter } from "next/router"; import Markdown from "react-markdown"; import { doc, getDoc } from "firebase/firestore"; import Link from "next/link"; import toast from "react-hot-toast"; import remarkGfm from "remark-gfm"; import { formatTimeStamp } from "@/components/dashboard/TextArea/PostButtons"; import { NoteDocument, UserDocument } from "@/types/utils/firebaseOperations"; import HeadTags from "@/components/common/HeadTags"; import useUser from "@/components/hooks/useUser"; import Footer from "@/components/home/Footer"; import Button from "@/components/ui/Button"; import { db } from "@/lib/firebase"; import Loading from "@/components/ui/Loading"; import Navbar from "@/components/Navbar"; interface Props {} export const PostPage = ({}: Props) => { const router = useRouter(); const [note, setNote] = useState(null); const [name, setName] = useState(""); const [profilePicture, setProfilePicture] = useState(""); const [loading, setLoading] = useState(true); const { username, postId } = router.query; const fetchData = async () => { let user: UserDocument | null = null; let note: NoteDocument | null = null; try { const usernameDoc = doc(db, "usernames", username as string); const usernameSnapshot = await getDoc(usernameDoc); const usernameData = usernameSnapshot.data(); if (usernameData) { const userDoc = doc(db, "users", usernameData.uid as string); const userSnapshot = await getDoc(userDoc); user = userSnapshot.data() as UserDocument; } else { const uid = username as string; const userDoc = doc(db, "users", uid); const userSnapshot = await getDoc(userDoc); user = userSnapshot.data() as UserDocument; } } catch (error) { toast.error("User not found"); setLoading(false); return; } if (!user) return; try { const noteDoc = doc(db, "users", user.uid, "notes", postId as string); const noteSnapshot = await getDoc(noteDoc); note = noteSnapshot.data() as NoteDocument; } catch (error) { toast.error("User not found"); setLoading(false); return; } if (!note || !user) { toast.error("Post not found"); setLoading(false); return; } if (note && !note.public) { toast.error("Post not found"); setLoading(false); return; } setNote(note); setName(user.displayName); setProfilePicture(user.photoURL); setLoading(false); }; useEffect(() => { if (username && postId) { fetchData(); } }, [username, postId]); const { user } = useUser(); if (loading) return ; return ( <> {!note && (

Oops, couldn't find that post!

The post you are looking for might have been removed or the link is broken.

)} {note && (
User Profile Picture

{note?.title}

By{" "} {name}

Published {formatTimeStamp(note?.publishedAt)}

{user?.uid === note?.userId && ( )}
{note?.content}
)} ); }; export default PostPage; ================================================ FILE: pages/_app.tsx ================================================ import { ParallaxProvider } from "react-scroll-parallax"; import { SkeletonTheme } from "react-loading-skeleton"; import { ThemeProvider } from "next-themes"; import "react-loading-skeleton/dist/skeleton.css"; import { useEffect, useState } from "react"; import { Toaster } from "react-hot-toast"; import type { AppProps } from "next/app"; import "katex/dist/katex.min.css"; import { Provider } from "jotai"; import "@/styles/globals.css"; // const env = process.env.NODE_ENV; // if (env === "development") { // connectFirestoreEmulator(db, "localhost", 8080); // connectAuthEmulator(auth, "http://localhost:9099"); // } function MyApp({ Component, pageProps }: AppProps) { const [theme, setTheme] = useState("light"); useEffect(() => { const currentTheme = localStorage.getItem("theme"); if (currentTheme) { setTheme(currentTheme); } else { setTheme("light"); } }, []); return ( {/* EXTRA DIV IS BECAUSE OF TOAST */} ); } export default MyApp; ================================================ FILE: pages/api/link-preview.ts ================================================ import { NextApiRequest, NextApiResponse } from "next"; import * as cheerio from "cheerio"; export default async function handler( req: NextApiRequest, res: NextApiResponse ) { try { const { url } = req.query; const response = await fetch(url as string); const data = await response.text(); const $ = cheerio.load(data); // Site name const name = $('meta[property="og:site_name"]').attr("content"); // Extract title const title = $("head > title").text() || $('meta[property="og:title"]').attr("content"); // Extract the description const description = $('meta[name="description"]').attr("content") || $('meta[property="og:description"]').attr("content"); // Extract the image const image = $('meta[property="og:image"]').attr("content") || $('meta[name="twitter:image"]').attr("content") || $('link[rel="image_src"]').attr("href"); res.status(200).json({ name, title, description, image }); } catch (error) { res.status(500).json({ error: JSON.stringify(error), }); } } ================================================ FILE: pages/api/og.tsx ================================================ import { NextRequest, NextResponse } from "next/server"; import { ImageResponse } from "@vercel/og"; export const config = { runtime: "edge", }; export default function handler(request: NextRequest, res: NextResponse) { try { const { searchParams } = new URL(request.url); const hasTitle = searchParams.has("title"); const hasContent = searchParams.has("content"); const hasAuthor = searchParams.has("author"); const hasProfilePicture = searchParams.has("profilePicture"); const title = hasTitle ? searchParams.get("title")?.slice(0, 100) : "writedown"; const content = hasContent ? searchParams.get("content")?.slice(0, 200) + ".." : "A free markdown notes app that is simple and beautiful."; const author = hasAuthor ? searchParams.get("author")?.slice(0, 100) : "writedown"; const profilePicture = hasProfilePicture ? searchParams.get("profilePicture")?.slice() : "https://writedown.app/og-image.png"; return new ImageResponse( (
Author profile picture
{title}

By {author}

{content}
writedown.app
), { width: 1200, height: 600, } ); } catch (e: any) { console.log(`${e.message}`); return new Response(`Failed to generate the image`, { status: 500, }); } } ================================================ FILE: pages/dashboard.tsx ================================================ import CheckUsername from "@/components/dashboard/CheckUsername"; import { useAuthState } from "react-firebase-hooks/auth"; import TextArea from "@/components/dashboard/TextArea"; import Sidebar from "@/components/dashboard/Sidebar"; import HeadTags from "@/components/common/HeadTags"; import React, { useEffect, useState } from "react"; import useUser from "@/components/hooks/useUser"; import { useRouter } from "next/router"; import { auth } from "@/lib/firebase"; const Dashboard = () => { // NEXT ROUTER const router = useRouter(); const { user, hasUsername } = useUser(); const [showUsernameModal, setShowUsernameModal] = useState(false); const [showSidebar, setShowSidebar] = useState(true); useEffect(() => { (async () => { const user = auth.currentUser; if (!user) return; try { const userHasUsername = await hasUsername(user); if (!userHasUsername) { setShowUsernameModal(true); } } catch (error) { console.log("Error checking username: ", error); } })(); }, [user]); // AUTH STATE HOOK useAuthState(auth, { onUserChanged: async (user) => { console.log("🚀 => user:", user); if (!user) { router.push("/login"); return; } }, }); return ( <>