Showing preview only (244K chars total). Download the full file or copy to clipboard to get everything.
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. <https://fsf.org/>
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <https://www.gnu.org/licenses/>.
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
<https://www.gnu.org/licenses/>.
================================================
FILE: README.md
================================================
<div align="center">
# ✏ [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.

</div>
## 🤔 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`.
#
<div align="center">
© 2023 **writedown**. All rights reserved.
</div>
================================================
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 (
<nav className="fixed top-0 z-20 flex w-full flex-row items-center justify-between border-b border-gray-300 bg-transparent p-4 backdrop-blur dark:border-gray-700">
{/* LOGO */}
<Link href="/">
<h4 className="flex items-center text-2xl font-semibold">writedown</h4>
</Link>
{/* USER MENU */}
<div className="flex flex-row items-center gap-4">
<UserMenu dashboard home logout themeOption reverse>
{user ? (
<img
src={
user?.photoURL ||
`https://ui-avatars.com/api/?name=${user?.displayName}&rounded=true&format=svg&background=random`
}
alt="User Photo"
className="h-10 w-10 rounded-full object-cover"
/>
) : (
<RiMenu5Fill className="h-7 w-7" />
)}
</UserMenu>
</div>
</nav>
);
};
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 (
<Head>
<link rel="manifest" href="/manifest.json" />
<link rel="apple-touch-icon" href="/icons/icon-180x180.png" />
<meta name="theme-color" content="#e2e8f0" />
<link rel="icon" type="image/png" href="/icons/favicon-32x32.png" />
<link
href="/icons/favicon-16x16.png"
rel="icon"
type="image/png"
sizes="16x16"
/>
<link
href="/icons/favicon-32x32.png"
rel="icon"
type="image/png"
sizes="32x32"
/>
<meta name="application-name" content="writedown" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
{/* META TAGS */}
<title>{title}</title>
<meta
name="apple-mobile-web-app-title"
content="writedown - Notes made simple"
/>
<meta name="description" content={description} key="description" />
{/* TWITTER */}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:url" content={ogUrl} />
<meta name="twitter:title" content={title} />
<meta
name="twitter:description"
content={description}
key="twitter-description"
/>
<meta name="twitter:image" content={ogImage} key="twitter-image" />
{/* OG */}
<meta property="og:type" content="website" />
<meta property="og:title" content={title} key="og-title" />
<meta
property="og:description"
content={description}
key="og-description"
/>
<meta property="og:site_name" content="writedown" />
<meta property="og:url" content={ogUrl} />
<meta property="og:image" content={ogImage} key="og-image" />
</Head>
);
};
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 (
<Popover
data-testid="logout"
buttonStyle="outline-none"
button={<>{children}</>}
reverse={reverse}
>
{dashboard && auth.currentUser && (
<Link
href="/dashboard"
className="flex items-center gap-2 rounded-md p-2 text-left text-sm font-medium hover:bg-slate-200 dark:text-slate-300 dark:hover:bg-slate-700"
>
<BiPencil /> writedown
</Link>
)}
{dashboard && !auth.currentUser && (
<Link
href="/login"
className="flex items-center gap-2 rounded-md p-2 text-left text-sm font-medium hover:bg-slate-200 dark:text-slate-300 dark:hover:bg-slate-700"
>
<BiLogInCircle className="" /> Login
</Link>
)}
{home && (
<Link
href="/"
className="flex items-center gap-2 rounded-md p-2 text-left text-sm font-medium hover:bg-slate-200 dark:text-slate-300 dark:hover:bg-slate-700"
>
<BiHomeAlt className="" />
Home
</Link>
)}
{themeOption && (
<button
onClick={() => {
theme === "light" ? setTheme("dark") : setTheme("light");
}}
className="flex items-center gap-2 rounded-md p-2 text-left text-sm font-medium hover:bg-slate-200 dark:text-slate-300 dark:hover:bg-slate-700"
>
{theme === "light" ? <BiMoon className="" /> : <BiSun className="" />}
{theme === "light" ? "Dark" : "Light"} Mode
</button>
)}
{logout && auth.currentUser && (
<button
onClick={() => {
auth.signOut();
setSelectedNote((prev) => ({
...prev,
id: "",
isPublic: false,
title: "",
content: "",
}));
}}
className="flex items-center gap-2 rounded-md p-2 text-left text-sm font-medium hover:bg-slate-200 dark:text-slate-300 dark:hover:bg-slate-700"
>
<BiLogOutCircle className="" /> Logout
</button>
)}
</Popover>
);
};
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 (
<Modal
isOpen={show}
setIsOpen={onSetShow}
saveText="Save"
title="Set Username"
description="Set a username to create your personal writedown space."
saveHandler={handleSaveUsername}
undismissable
>
{invalidUsername && (
<p className="mb-2 text-sm text-red-400">
Username is not valid or already taken
</p>
)}
<Input
id="username"
placeholder="Username"
value={input}
small
onChange={(e) => setInput(e.target.value)}
/>
<div className="flex flex-col">
<p className="mt-4 text-sm text-slate-600 dark:text-slate-300">
Username must:
</p>
<ul className="ml-4 list-disc text-xs leading-relaxed text-slate-500 dark:text-slate-400">
<li>Begin with a lowercase letter (a-z).</li>
<li>Combine lowercase letters (a-z) and digits (0-9).</li>
<li className="leading-normal">
Optionally contain periods (.), underscores (_), or hyphens (-).
</li>
</ul>
</div>
</Modal>
);
};
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<React.SetStateAction<boolean>>;
};
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 (
<div
className={`flex items-center justify-between rounded-xl p-4 ${
selectedNote.id === noteId
? "bg-slate-200 dark:bg-slate-700"
: "bg-slate-50 hover:bg-slate-100 dark:bg-slate-800 dark:hover:bg-slate-700"
}`}
onClick={() => switchNotesHandler(noteId)}
>
<div
className="flex w-full cursor-pointer flex-col gap-2 truncate"
onClick={() => switchNotesHandler(noteId)}
>
<div className="w-full truncate font-medium dark:text-slate-200">
{title === "" ? "Untitled" : title || <Skeleton className="w-1/2" />}
</div>
<button className="flex flex-col gap-2">
<p className="w-full truncate text-left text-sm text-slate-600 dark:text-slate-400">
{content === null || content === undefined ? (
<Skeleton />
) : (
RemoveMarkdown(content.slice(0, 50)) || "Empty Post"
)}
</p>
{/* TODO: Add tags */}
{/* <div className="flex flex-row flex-wrap gap-1">
<Badge color="yellow">UI</Badge>
<Badge color="green">Development</Badge>
<Badge color="red">UX</Badge>
</div> */}
</button>
</div>
{isPublic && <BiGlobe title="Public" size={25} />}
</div>
);
};
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 (
<Button
onClick={() => {
setTheme(theme === "dark" ? "light" : "dark");
}}
>
{theme === "dark" ? "Light" : "Dark"}
</Button>
);
}
================================================
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<React.SetStateAction<boolean>>;
}
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 (
<aside
className={`dark:slate-950 absolute bottom-0 left-0 right-0 top-0 z-50 flex h-full flex-col gap-y-5 bg-white p-2 shadow-2xl shadow-slate-400 transition-transform duration-300 dark:bg-slate-900 dark:text-slate-50 dark:shadow-slate-950 md:bottom-auto md:left-auto md:right-auto md:top-auto md:m-4 md:h-[calc(96%)] md:w-96 md:rounded-xl md:p-5 ${
showSidebar ? "translate-x-0" : "-translate-x-full"
}`}
>
{/* MOBILE - SIDEBAR TOGGLE BUTTON */}
<IconButton
id="new"
onClick={() => setShowSidebar(!showSidebar)}
extraClasses={`fixed z-10 ml-auto top-[10px] right-[15px] md:hidden dark:!bg-slate-800 !bg-slate-100`}
>
<BsChevronBarLeft
className={`duration-400 h-4 w-4 text-black transition-transform dark:text-slate-100 ${
showSidebar ? "rotate-0" : "rotate-180"
}`}
/>
</IconButton>
{/* DESKTOP - SIDEBAR TOGGLE BUTTON */}
<IconButton
data-testid="sidebarToggle"
onClick={() => setShowSidebar(!showSidebar)}
extraClasses="absolute top-1/2 -right-5 z-10 hidden md:block"
>
<BsChevronBarLeft
className={`duration-400 h-5 w-5 translate-x-1 text-black transition-transform dark:text-slate-100 ${
showSidebar ? "" : "rotate-180"
}`}
/>
</IconButton>
{/* USER GREETING SECTION */}
<div className="relative min-w-fit">
<UserMenu home logout themeOption showImageAsButton>
<div className="flex flex-row items-center gap-2">
{user ? (
<img
src={
user?.photoURL ||
`https://ui-avatars.com/api/?name=${user?.displayName}&rounded=true&format=svg&background=random`
}
alt="User Photo"
className="h-10 w-10 rounded-full object-cover"
/>
) : (
<Skeleton className="h-10 w-10" circle={true} />
)}
{user ? (
<h4 className="truncate text-xl font-semibold text-slate-500 dark:text-slate-300">
Hi there,{" "}
<span className="text-slate-900 dark:text-slate-100">
{user?.displayName}{" "}
</span>
</h4>
) : (
<Skeleton className="w-32" />
)}
</div>
</UserMenu>
</div>
{/* CREATE NEW POST BUTTON */}
{notes ? (
<Button
data-testid="new-note"
onClick={newPostClickHandler}
disabled={createPostLoading}
className="disabled:cursor-not-allowed"
>
<span className="flex items-center justify-center gap-1">
{createPostLoading ? (
<IoMdRefreshCircle className="h-5 w-5 animate-spin" />
) : (
<IoMdAddCircle className="h-5 w-5" />
)}
Create New Post
</span>
</Button>
) : (
<Skeleton className="h-9 w-full" borderRadius={50} />
)}
{/* POSTS SECTION */}
{/* POSTS HEADING */}
<h6 className="font-semibold">Posts</h6>
<div className="scrollbar flex h-full flex-col gap-3 overflow-y-auto">
{/* POSTS LIST */}
<div className="mb-64 flex flex-col gap-2 p-1">
{notes ? (
notes.map((note) => (
<Link
href={`/dashboard/?post=${note.slug}`}
key={note.id}
as={
note.public
? `/${publicUserDetails?.username}/posts/${note.slug}`
: `/dashboard/?post=${note.slug}`
}
>
<PostRow
userId={user?.uid}
title={note.title}
content={note.content}
noteId={note.id}
isPublic={
note.id === selectedNote.id
? selectedNote.isPublic
: note.public
}
setShowSidebar={setShowSidebar}
/>
</Link>
))
) : (
<Skeleton className="mb-2 h-20 p-4" count={4} />
)}
<div className="pointer-events-none absolute inset-x-0 bottom-10 flex justify-center bg-gradient-to-t from-white pb-32 pt-32 dark:from-slate-900"></div>
</div>
</div>
<div className="mt-auto">
<p className="text-center text-xs text-slate-400">
© {new Date().getFullYear()} <b>writedown</b>. All rights reserved.
{FEATURE_FLAGS.beta && <BetaBadge pulse />}
</p>
</div>
</aside>
);
};
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 (
<div
className={`m-4 flex w-full max-w-3xl items-center justify-center rounded-xl bg-white p-1 transition-transform duration-300 dark:bg-slate-900 sm:justify-start ${
shiftRight ? "translate-x-52" : "translate-x-0"
}`}
>
<div className="flex flex-row items-center gap-2 overflow-x-auto sm:w-full sm:justify-evenly">
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() =>
editor
.chain()
.focus()
.toggleHeading({
level: 1,
})
.run()
}
>
<LuHeading1 className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() =>
editor
.chain()
.focus()
.toggleHeading({
level: 2,
})
.run()
}
>
<LuHeading2 className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() =>
editor.chain().focus().toggleHeading({ level: 3 }).run()
}
>
<LuHeading3 className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() =>
editor
.chain()
.focus()
.toggleHeading({
level: 4,
})
.run()
}
>
<LuHeading4 className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleBold().run()}
>
<LuBold className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleItalic().run()}
>
<LuItalic className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleBlockquote().run()}
>
<LuQuote className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleStrike().run()}
>
<LuStrikethrough className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleOrderedList().run()}
>
<LuListOrdered className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleBulletList().run()}
>
<LuList className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().toggleTaskList().run()}
>
<LuCheckSquare className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().setCodeBlock().run()}
>
<LuCode className="dark:text-slate-200" />
</button>
{/* <button className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700">
<MaterialLink />
</button> */}
<button
className="rounded-xl p-3 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => setIsUrlPromptOpen(true)}
>
<LuLink className="dark:text-slate-200" />
</button>
<Modal
isOpen={isUrlPromptOpen}
setIsOpen={setIsUrlPromptOpen}
title="Insert Link"
saveText="Insert"
closeText="Cancel"
saveHandler={() => {
isLinkPreview
? editor.chain().setLinkPreview({ url: url }).run()
: editor.chain().insertContent(`[${url}](${url})`).run();
setIsUrlPromptOpen(false);
}}
>
<div className="flex flex-col items-center gap-2">
<div className="mb-2 inline-flex w-full items-center justify-end gap-4">
<span>Link Preview: </span>
<Toggle
enabled={isLinkPreview}
onChange={() => setIsLinkPreview((prev) => !prev)}
/>
</div>
<Input
id="url"
placeholder="Enter URL"
onChange={(e) => setUrl(e.target.value)}
/>
</div>
</Modal>
<button
className="rounded-xl p-3 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => setIsOpen(true)}
>
<LuImage className="dark:text-slate-200" />
</button>
<button
className="rounded-xl p-2 hover:bg-slate-200 dark:hover:bg-slate-700"
onClick={() => editor.chain().focus().setHorizontalRule().run()}
>
<LuMinus className="dark:text-slate-200" />
</button>
<Modal
isOpen={isOpen}
setIsOpen={setIsOpen}
title="Insert Image"
description="Enter a title and the link to an image."
saveText="Insert"
closeText="Cancel"
saveHandler={() => {
editor.chain().focus().setImage({ src: url, title }).run();
setIsOpen(false);
}}
>
<div className="flex flex-col items-center gap-2">
<Input
id="title"
placeholder="Enter Title"
onChange={(e) => setTitle(e.target.value)}
/>
<Input
id="url"
placeholder="Enter URL"
onChange={(e) => setUrl(e.target.value)}
/>
</div>
</Modal>
</div>
</div>
);
};
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 (
<NodeViewWrapper contenteditable="false" id="link-preview">
<a
href={url}
target="_blank"
rel="noreferrer"
className="not-prose mb-4 flex w-full cursor-pointer items-center gap-4 rounded-lg bg-slate-100 p-3 transition-colors hover:bg-slate-200 dark:bg-slate-800 dark:hover:bg-slate-700 "
>
{image && (
<div className="w-1/3 overflow-hidden">
<img
src={image}
alt={`${title}-preview`}
className="not-prose rounded-lg"
/>
</div>
)}
<div className="w-2/3 space-y-2 text-xs md:text-sm">
<div className="truncate">{title} </div>
<div className="line-clamp-2 text-slate-400 md:line-clamp-3">
{description}
</div>
<p className="hidden cursor-pointer items-center gap-2 font-medium text-sky-500 md:inline-flex">
<LuLink />
{sanitizedUrl}
</p>
</div>
</a>
</NodeViewWrapper>
);
};
declare module "@tiptap/core" {
interface Commands<ReturnType> {
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<string | null>(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 (
<div
className={`mt-14 flex w-full max-w-3xl select-none flex-col gap-4 transition-transform duration-300 md:mt-52 md:flex-row md:items-center md:justify-between md:px-4 ${
shiftRight ? "translate-x-52" : "translate-x-0"
}`}
>
{/* LAST UPDATED */}
{lastUpdated ? (
<p className="flex items-center justify-center text-xs font-medium text-slate-500 dark:text-slate-400 md:text-sm">
Last Updated {lastUpdated}
</p>
) : (
<Skeleton className="w-44" />
)}
{/* ACTION BUTTONS */}
<div className="flex flex-wrap items-center justify-center gap-4 md:items-start">
{/* SAVE BUTTON */}
<Button
data-testid="save"
type="button"
size="sm"
variant="green"
className="w-28"
>
{!synced && (
<span className="flex items-center justify-center gap-1">
<IoMdRefreshCircle className="h-5 w-5 animate-spin" />
<p>Saving</p>
</span>
)}
{synced && (
<span className="flex items-center justify-center gap-1">
<IoMdCheckmarkCircle className="h-5 w-5" />
<p>Saved</p>
</span>
)}
</Button>
<Button
data-testid="del"
type="button"
onClick={deleteNoteHandler}
variant="red"
size="sm"
>
<span className="flex items-center justify-center gap-1">
<IoMdTrash className="h-5 w-5" />
<p>Delete Post</p>
</span>
</Button>
{/* SAVE BUTTON */}
<Button
data-testid="download"
type="button"
onClick={() => {
setShowPublishModal(true);
}}
size="sm"
variant="blue"
>
<span className="flex items-center justify-center gap-1">
<IoMdSend className="h-5 w-5" />
<p>Publish</p>
</span>
</Button>
<Modal
isOpen={showPublishModal}
setIsOpen={setShowPublishModal}
title="Publish and Share"
>
<div className="p-2">
<div className="mb-4 flex flex-row items-center gap-2">
<label
htmlFor="toggle"
className="cursor-pointer select-none font-medium dark:text-slate-300"
onClick={saveNoteHandler}
>
Enable Public Viewing
</label>
<Toggle
enabled={selectedNote.isPublic}
onChange={saveNoteHandler}
screenReaderPrompt="Toggle Public Sharing"
/>
</div>
<p
className={`relative rounded-lg p-2 text-sm transition-all duration-500 ${
selectedNote.isPublic
? "cursor-pointer bg-emerald-50 text-slate-900 ring-2 ring-emerald-300 hover:scale-95 dark:bg-emerald-950 dark:text-emerald-100 dark:ring-emerald-400"
: "select-none bg-slate-200 text-slate-400 ring-2 ring-slate-300 dark:bg-slate-800 dark:text-slate-500 dark:ring-slate-500"
}`}
onClick={() => {
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}`
);
}}
>
<div className="w-11/12 truncate">
{/* 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/...`}
</div>
{selectedNote.isPublic && (
<IoMdCopy className="absolute right-2 top-1/2 h-5 w-5 -translate-y-1/2" />
)}
</p>
<div className="mt-5">
<label className="font-medium dark:text-slate-300">
{!downloadLoading ? (
"Download Post"
) : (
<div className="flex items-center gap-1">
Downloading
<IoMdRefresh className="h-5 w-5 animate-spin" />
</div>
)}
</label>
<div className="mt-4 flex flex-row flex-wrap items-center justify-center gap-4">
<Button variant="red" size="sm" onClick={downloadPDFHandler}>
Download PDF
</Button>
<Button
variant="green"
size="sm"
onClick={downloadMarkdownHandler}
>
Download Markdown
</Button>
<Button variant="blue" size="sm" onClick={downloadHTMLHandler}>
Download HTML
</Button>
</div>
</div>
</div>
</Modal>
</div>
</div>
);
};
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<React.SetStateAction<boolean>>;
};
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 (
<div
className={`scrollbar flex w-full flex-col items-center justify-start overflow-x-hidden overflow-y-scroll p-2 md:p-5`}
>
<IconButton
extraClasses={`fixed z-10 ml-auto top-[10px] right-[15px] md:hidden transition-transform duration-400 rotate-180 ${
shiftRight ? "translate-x-52" : "translate-x-0"
}`}
onClick={() => setShiftRight(true)}
>
<BsChevronBarLeft
className={`duration-400 h-4 w-4 text-black transition-transform dark:text-slate-100`}
/>
</IconButton>
{/*BUTTONS AND OTHER STATUS ELEMENTS*/}
<PostButtons shiftRight={shiftRight} editor={editor} />
{/*EDITOR BUTTONS AND THE EDITOR*/}
<EditorButtons shiftRight={shiftRight} editor={editor} />
<div
tabIndex={0}
id="editor"
className={`mb-64 w-full max-w-3xl flex-col rounded-xl bg-white p-5 transition-transform duration-300 dark:bg-slate-900 ${
shiftRight ? "translate-x-52" : "translate-x-0"
}`}
>
{/* TITLE OF THE POST */}
<input
data-testid="noteTitle"
type="text"
className="w-full appearance-none border-none p-0 text-5xl font-bold leading-relaxed focus:outline-none focus:ring-0 dark:bg-slate-900 dark:text-slate-200"
onChange={(e) => {
setSelectedNote((prev) => ({
...prev,
title: e.target.value,
}));
}}
placeholder="Untitled"
value={selectedNote.title}
/>
{/* SEPARATOR */}
<div className="mb-5 mt-2 h-0.5 w-full rounded-full bg-slate-200 dark:bg-slate-800" />
<WritedownEditor notes={notes} editor={editor} />
</div>
</div>
);
};
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 (
<div className="flex w-full cursor-default flex-col gap-4 rounded-xl bg-slate-200 p-5 text-sm transition-all duration-300 hover:scale-105 hover:bg-slate-100 dark:bg-slate-700 sm:hover:scale-110">
<h6 className="tex-base flex flex-col items-center gap-1 font-medium text-slate-900 dark:text-slate-100 sm:text-lg">
{icon} {title}
</h6>
<p className="text-slate-600 dark:text-slate-300">{description}</p>
</div>
);
};
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 (
<div className="mb-10 grid grid-cols-1 content-center gap-4 px-4 sm:grid-cols-2 sm:gap-8 sm:px-5 md:px-20 lg:grid-cols-2 lg:px-36 xl:grid-cols-5">
<FeatureCard
icon={<FiGlobe className="h-6 w-6" />}
title="Free and Open Source"
description="Sharing is caring, writedown is completely free and open source and licensed under AGPLv3."
/>
<FeatureCard
icon={<FiCloudLightning className="h-6 w-6" />}
title="Synced on all your devices"
description="All your notes are synced on all your devices. You can access them from anywhere."
/>
<FeatureCard
icon={<FiWifiOff className="h-6 w-6" />}
title="Offline Support"
description="Write and save notes even when you are away from the internet!"
/>
<FeatureCard
icon={<FiEye className="h-6 w-6" />}
title="Live Markdown"
description="Writedown supports Markdown. You can write markdown and preview it in real-time."
/>
<FeatureCard
icon={<FiSmile className="h-6 w-6" />}
title="Easy to Use"
description="Writedown is easy to use with a beautiful interface. Get started in just 5 seconds!"
/>
</div>
);
};
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 (
<footer
className={
"flex flex-col items-center justify-between gap-2 bg-slate-200 px-4 text-slate-900 dark:bg-slate-700 dark:text-slate-50 sm:flex-row sm:py-4 md:px-10 lg:px-36" +
" " +
className
}
>
<div className="pt-4 sm:pt-0">
<Link href="/" className="text-xl font-semibold">
writedown {FEATURE_FLAGS.beta && <BetaBadge />}
</Link>
</div>
<div className="text-sm">
<ul className="flex flex-row gap-5">
<li>
<Link href="/login">
{auth.currentUser ? "Write Down" : "Login"}
</Link>
</li>
<li>
<a href="https://github.com/NayamAmarshe/writedown">GitHub</a>
</li>
</ul>
</div>
<div className="pb-5 text-slate-500 dark:text-slate-400 sm:pb-0">
<p className="text-sm">
© {new Date().getFullYear()}{" "}
<Link href="/" className="font-semibold">
writedown
</Link>
. All rights reserved.
</p>
</div>
</footer>
);
};
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 (
<div className="my-32 h-full w-full">
<div className="flex h-full w-full flex-col items-center justify-center gap-20 px-4">
<div className="flex flex-col items-center justify-center gap-5">
<h1 className="flex flex-col gap-5 text-center text-4xl font-semibold leading-tight text-slate-900 dark:text-slate-50 xs:text-5xl sm:text-7xl">
<span className="whitespace-nowrap">Upgrade Your</span>
<span className="text-pacifico whitespace-nowrap font-light">
Dear Diary
</span>
</h1>
<p className="mt-4 max-w-lg text-center text-base font-medium text-slate-800 dark:text-slate-200 xs:text-xl">
All your notes, synced on all your devices. <br />
Free, easy and fast.
</p>
<div>
<Link href="/login">
<Button>{auth.currentUser ? "Write Down" : "Try Now"}</Button>
</Link>
</div>
</div>
<Parallax speed={10}>
<img
src="/screenshot.png"
alt="Writedown Screenshot"
className="dark:hidden"
/>
<img
src="/dark-screenshot.png"
alt="Writedown Screenshot"
className="hidden dark:block"
/>
</Parallax>
</div>
</div>
);
};
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 (
<nav className="fixed z-10 flex w-full flex-row justify-between bg-slate-50/50 px-4 py-4 backdrop-blur-md dark:bg-slate-900/50 md:px-10 lg:px-36">
<div className="flex w-full flex-row items-center justify-start gap-2">
<Link href="/">
<h4 className="flex items-center text-2xl font-semibold">
writedown {FEATURE_FLAGS.beta && <BetaBadge />}
</h4>
</Link>
</div>
<div className="flex w-full flex-row items-center justify-end gap-4">
<button
onClick={() => {
setTheme(theme === "light" ? "dark" : "light");
}}
>
{isMounted && theme === "light" ? (
<FiMoon className="h-6 w-6 duration-300 hover:scale-110" />
) : (
<FiSun className="h-6 w-6 duration-300 hover:scale-110" />
)}
</button>
<Link href="/login" className="hidden sm:block">
<Button>{auth.currentUser ? "Write Down" : "Try Now"}</Button>
</Link>
</div>
</nav>
);
};
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<QueryDocumentSnapshot<DocumentData>[]>([]);
const isMountedRef = useRef(false);
const lastItemRef = useRef<any>(null);
const [isLoading, setisLoading] = useState<boolean>();
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 (
<div className="relative h-1/2 w-full flex-col gap-2 overflow-hidden bg-slate-300 dark:bg-slate-600 md:h-full md:w-2/3">
<h1 className="ml-10 mt-20 text-lg font-semibold dark:text-slate-50 md:ml-20 md:mt-52 md:text-2xl">
Simplicity starts here
</h1>
<p className="ml-10 w-9/12 text-slate-700 dark:text-slate-200 sm:w-6/12 md:ml-20 md:w-1/2">
A fast, easy and free way to write notes with offline support, cloud
sync and real-time markdown preview.
</p>
<img
src="/writedown.png"
alt="Writedown Screenshot"
className="ml-10 mt-5 h-96 origin-top-left rounded-l-xl object-cover object-left-top shadow-lg shadow-slate-900/50 dark:hidden dark:shadow-black/30 md:ml-20 md:mt-10 md:h-[70vh]"
/>
<img
src="/writedown-dark.png"
alt="Writedown Screenshot"
className="ml-10 mt-5 hidden h-96 origin-top-left rounded-l-xl object-cover object-left-top shadow-lg shadow-slate-900/50 dark:block dark:shadow-black/30 md:ml-20 md:mt-10 md:h-[70vh]"
/>
</div>
);
};
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 (
<div className="flex h-1/2 w-full flex-col items-center justify-end gap-4 bg-slate-300 dark:bg-slate-600 dark:text-slate-50 md:h-full md:w-1/2">
<div className="absolute left-5 top-0 px-4 pb-4 text-2xl font-semibold">
<Link href="/" className="fixed top-4 z-10 flex items-center">
writedown
</Link>
</div>
<div className="bottom-0 flex h-full w-full flex-col items-center gap-4 bg-slate-50 px-10 py-16 pb-20 dark:bg-slate-900 md:justify-center md:rounded-r-xl">
<p className="mb-5 text-center text-sm font-medium">
Login with your familiar services:
</p>
<Button
className="hover:!border-slate- flex gap-2 border-2 !px-10 !text-slate-900 dark:!text-slate-50"
data-testid="google-login"
onClick={() => login("google")}
>
<FcGoogle className="h-6 w-6" /> Sign in with Google
</Button>
<Button
className="flex gap-2 border-2 !bg-slate-900 !px-10 !text-slate-50 hover:!border-slate-600 hover:!bg-slate-600 hover:!text-slate-50 dark:!text-slate-50 dark:hover:!border-slate-300 dark:hover:!bg-slate-300 dark:hover:!text-slate-900"
data-testid="github-login"
onClick={() => login("github")}
>
<AiFillGithub className="h-6 w-6" /> Sign in with GitHub
</Button>
</div>
</div>
);
};
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 (
<div
className={`${getColorClasses()} cursor-pointer select-none rounded-full px-2 text-xs`}
>
{children}
</div>
);
};
export default Badge;
================================================
FILE: components/ui/BetaBadge.tsx
================================================
import React from "react";
type BetaBadgeProps = {
pulse?: boolean;
};
const BetaBadge = ({ pulse }: BetaBadgeProps) => {
return (
<span
className={`ml-2 ${
pulse && "animate-pulse"
} rounded-full bg-violet-500 px-3 text-xs text-violet-100`}
>
BETA
</span>
);
};
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<HTMLButtonElement>) => {
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 (
<button
type="button"
className={getButtonClass() + " " + className}
{...rest}
>
{children}
</button>
);
};
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<HTMLButtonElement>) => {
return (
<button
className={"rounded-full bg-white p-3 dark:bg-slate-900 " + extraClasses}
{...rest}
>
{children}
</button>
);
};
export default IconButton;
================================================
FILE: components/ui/Input.tsx
================================================
import { InputHTMLAttributes } from "react";
import React from "react";
const Input = ({
label,
id,
small,
...rest
}: InputHTMLAttributes<HTMLInputElement> & {
id: string;
label?: string;
small?: boolean;
}) => {
return (
<>
{label && (
<label className="mb-2 block text-sm font-medium dark:text-white">
{label}
</label>
)}
<input
id={id}
className={`w-full rounded-xl bg-slate-200 p-2 outline-none dark:bg-slate-900 dark:text-slate-200 ${
small && "text-sm"
}`}
{...rest}
/>
</>
);
};
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 (
<div className="fixed left-0 top-0 z-[99] flex h-screen w-screen flex-col overflow-y-auto bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
<div className="flex h-screen w-full flex-col items-center justify-center">
<Lottie
className="max-h-96 dark:hidden"
animationData={loadingAnimation}
loop={true}
/>
<Lottie
className="hidden max-h-96 dark:block"
animationData={darkLoadingAnimation}
loop={true}
/>
<p className="flex items-center text-2xl font-semibold text-slate-900 dark:text-slate-100 sm:text-4xl">
writedown {FEATURE_FLAGS.beta && <BetaBadge />}
</p>
</div>
</div>
);
};
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 (
<Transition appear show={isOpen} as={React.Fragment}>
<Dialog
as="div"
className="relative z-50"
onClose={() => {
if (undismissable) {
return;
}
setIsOpen(false);
}}
>
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25 backdrop-blur-sm" />
</Transition.Child>
<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-md transform overflow-hidden rounded-2xl bg-slate-50 p-6 text-left align-middle shadow-xl transition-all dark:bg-slate-800">
{title && (
<Dialog.Title
as="h3"
className="text-xl font-semibold leading-6 text-slate-900 dark:text-slate-100"
>
{title}
</Dialog.Title>
)}
<Dialog.Description className="mb-4 mt-2">
<p className="text-sm text-slate-500 dark:text-slate-400">
{description}
</p>
</Dialog.Description>
{children}
<div className="mt-4 flex justify-end gap-2">
{saveText && (
<Button onClick={saveHandler}>{saveText}</Button>
)}
{closeText && (
<Button
variant="red"
onClick={() => {
setIsOpen(false);
}}
>
{closeText}
</Button>
)}
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition>
);
};
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 (
<HeadlessPopover {...rest} className="relative">
{({ open }) => (
<>
<HeadlessPopover.Button
className={`block
${open ? "" : openStyle} ${buttonStyle}`}
>
{button}
</HeadlessPopover.Button>
<Transition
as={Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-1"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
>
<HeadlessPopover.Panel
className={`absolute ${
reverse ? "right-0" : "left-0"
} z-10 mt-2 w-52`}
>
<div className="ring-opacity-15 overflow-hidden rounded-lg shadow-lg shadow-black/10 ring-1 ring-slate-200 dark:shadow-slate-900 dark:ring-slate-700">
<div className="relative flex flex-col gap-1 bg-white p-2 dark:bg-slate-800 lg:grid-cols-2">
{children}
</div>
</div>
</HeadlessPopover.Panel>
</Transition>
</>
)}
</HeadlessPopover>
);
}
================================================
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 (
<Switch
name="toggle"
checked={enabled}
onChange={onChange}
className={`${!enabled ? "bg-rose-500" : "bg-emerald-400"}
relative inline-flex h-7 w-12 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-500 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`}
>
<span className="sr-only">{screenReaderPrompt}</span>
<span
aria-hidden="true"
className={`${enabled ? "translate-x-5" : "translate-x-0"}
pointer-events-none inline-block h-6 w-6 transform rounded-full bg-white shadow-lg ring-0 transition duration-500 ease-in-out`}
/>
</Switch>
);
}
================================================
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 <EditorContent selected editor={editor} />;
};
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<NoteDocument | null>(null);
const [name, setName] = useState<string>("");
const [profilePicture, setProfilePicture] = useState<string>("");
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 <Loading />;
return (
<>
<HeadTags
title={`${note?.title} by ${name} - writedown`}
description={`Read this post by ${name} on writedown - A simple and beautiful notes app with cloud sync, markdown and offline support. Write, share, inspire.`}
ogImage={`https://dynamic-og-image-generator.vercel.app/api/generate?title=${note?.title}&author=${name}&avatar=${profilePicture}&websiteUrl=https://writedown.app&theme=nightOwl`}
// ogImage={`https://writedown.app/api/og?title=${
// note.title
// }&content=${RemoveMarkdown(
// note.content.slice(0, 200)
// )}&author=${name}&profilePicture=${profilePicture}`}
ogUrl={`https://writedown.app/${note?.userId}/posts/${note?.id}`}
/>
<Navbar />
{!note && (
<main className="max-w-screen relative flex min-h-screen flex-row items-center justify-center bg-slate-100 text-slate-900 dark:bg-slate-800 dark:text-slate-50">
<div className="flex h-full w-full flex-col items-center justify-center gap-2">
<h1 className="text-2xl font-medium">
Oops, couldn't find that post!
</h1>
<p className="max-w-96 text-center text-slate-500 dark:text-slate-400">
The post you are looking for might have been removed or the link
is broken.
</p>
</div>
</main>
)}
{note && (
<main className="max-w-screen relative flex min-h-screen flex-row bg-slate-100 text-slate-900 dark:bg-slate-800 dark:text-slate-50">
<div className="flex h-full w-full flex-col items-center justify-center">
<div className="mt-52 flex flex-col items-center justify-center gap-20">
<div className="flex flex-col items-center justify-center gap-4 px-2">
<img
src={profilePicture}
alt="User Profile Picture"
className="w-24 rounded-full"
/>
<h1 className="max-w-4xl text-center text-5xl font-bold leading-tight">
{note?.title}
</h1>
<p className="text-xl dark:text-slate-200">
<span className="font-light">By</span>{" "}
<span className="font-medium">{name}</span>
</p>
<p className="text-sm dark:text-slate-400">
Published {formatTimeStamp(note?.publishedAt)}
</p>
{user?.uid === note?.userId && (
<Link href={`/dashboard?post=${note?.id}`}>
<Button variant="slate" size="sm">
Edit Post
</Button>
</Link>
)}
</div>
<div className="mb-40 flex items-center justify-center px-4">
<Markdown
remarkPlugins={[remarkGfm]}
className="prose dark:prose-invert"
>
{note?.content}
</Markdown>
</div>
</div>
</div>
<Footer className="absolute bottom-0 w-full" />
</main>
)}
</>
);
};
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 (
<Provider>
<ThemeProvider attribute="class">
{/* EXTRA DIV IS BECAUSE OF TOAST */}
<Toaster position="top-center" />
<SkeletonTheme
baseColor={theme === "light" ? "#e2e8f0" : "#0f172a"}
highlightColor={theme === "light" ? "#f8fafc" : "#1e293b"}
borderRadius={10}
>
<ParallaxProvider>
<Component {...pageProps} />
</ParallaxProvider>
</SkeletonTheme>
</ThemeProvider>
</Provider>
);
}
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(
(
<div tw="flex flex-col w-full h-full items-center justify-center bg-slate-100">
<div tw="flex flex-col items-center justify-center mt-auto">
<img
src={profilePicture}
tw="w-12 mx-auto mb-2 rounded-full"
alt="Author profile picture"
/>
<div tw="flex flex-col font-semibold mb-5 text-slate-700 items-center w-11/12 justify-center text-6xl text-center">
{title}
<p tw="text-slate-400 mx-auto text-center font-medium text-base mt-2">
By {author}
</p>
</div>
<div tw="text-slate-600 mx-auto w-7/12 text-center text-lg">
{content}
</div>
</div>
<div tw="font-semibold text-slate-500 text-lg mt-auto mb-2">
writedown.app
</div>
</div>
),
{
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
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
SYMBOL INDEX (41 symbols across 31 files)
FILE: components/Navbar.tsx
type Props (line 7) | type Props = {};
FILE: components/common/HeadTags.tsx
type HeadTagsProps (line 4) | type HeadTagsProps = {
FILE: components/common/UserMenu.tsx
type UserMenuProps (line 17) | type UserMenuProps = {
FILE: components/dashboard/Sidebar/PostRow.tsx
type PostRowProps (line 9) | type PostRowProps = {
FILE: components/dashboard/Sidebar/ThemeChanger.tsx
function ThemeChanger (line 4) | function ThemeChanger() {
FILE: components/dashboard/Sidebar/index.tsx
type SidebarProps (line 21) | interface SidebarProps {
FILE: components/dashboard/TextArea/EditorButtons.tsx
type EditorButtonsProps (line 24) | type EditorButtonsProps = {
FILE: components/dashboard/TextArea/LinkPreview.tsx
type Commands (line 65) | interface Commands<ReturnType> {
method addAttributes (line 81) | addAttributes() {
method parseHTML (line 89) | parseHTML() {
method renderHTML (line 93) | renderHTML({ HTMLAttributes }) {
method addNodeView (line 100) | addNodeView() {
method addCommands (line 104) | addCommands() {
FILE: components/dashboard/TextArea/PostButtons.tsx
type PostButtonsProps (line 23) | type PostButtonsProps = {
FILE: components/dashboard/TextArea/index.tsx
type TextAreaProps (line 33) | type TextAreaProps = {
FILE: components/home/FeatureCard.tsx
type FeatureCardProps (line 3) | type FeatureCardProps = {
FILE: components/hooks/UsePaginateQuery.ts
function fetchQuery (line 26) | async function fetchQuery() {
FILE: components/hooks/useNotes.ts
type UseNotesProps (line 21) | type UseNotesProps = {
FILE: components/hooks/usePublicNotes.ts
type UseNotesProps (line 5) | type UseNotesProps = {
FILE: components/ui/Badge.tsx
type BadgeProps (line 3) | type BadgeProps = {
FILE: components/ui/BetaBadge.tsx
type BetaBadgeProps (line 3) | type BetaBadgeProps = {
FILE: components/ui/Button.tsx
type ButtonProps (line 3) | interface ButtonProps {
FILE: components/ui/IconButton.tsx
type IconButtonProps (line 3) | type IconButtonProps = {
FILE: components/ui/Modal.tsx
type ModalProps (line 5) | interface ModalProps {
FILE: components/ui/Popover.tsx
type PopoverProps (line 4) | type PopoverProps = {
function Popover (line 12) | function Popover({
FILE: components/ui/Toggle.tsx
type ToggleProps (line 4) | type ToggleProps = {
function Toggle (line 10) | function Toggle({
FILE: components/ui/WritedownEditor.tsx
type editorProps (line 7) | interface editorProps {
FILE: constants/feature-flags.ts
constant FEATURE_FLAGS (line 1) | const FEATURE_FLAGS = {
FILE: pages/[username]/posts/[postId].tsx
type Props (line 18) | interface Props {}
FILE: pages/_app.tsx
function MyApp (line 18) | function MyApp({ Component, pageProps }: AppProps) {
FILE: pages/api/link-preview.ts
function handler (line 4) | async function handler(
FILE: pages/api/og.tsx
function handler (line 8) | function handler(request: NextRequest, res: NextResponse) {
FILE: pages/not-found.tsx
type Props (line 3) | type Props = {};
FILE: stores/postDataAtom.ts
type SelectedNote (line 3) | type SelectedNote = {
FILE: types/components/firebase-hooks.d.ts
type IFirebaseAuth (line 3) | interface IFirebaseAuth {
FILE: types/utils/firebaseOperations.d.ts
type NoteDocument (line 1) | type NoteDocument = {
type PublicNoteDocument (line 13) | type PublicNoteDocument = {
type UserDocument (line 17) | type UserDocument = {
type UserPrivateDocument (line 24) | type UserPrivateDocument = {
Condensed preview — 80 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (249K chars).
[
{
"path": ".eslintrc.json",
"chars": 337,
"preview": "{\n \"extends\": \"next/core-web-vitals\",\n \"rules\": {\n \"@typescript-eslint/no-explicit-any\": \"off\",\n \"@typescript-es"
},
{
"path": ".firebaserc",
"chars": 57,
"preview": "{\n \"projects\": {\n \"default\": \"writedown-4a984\"\n }\n}\n"
},
{
"path": ".gitignore",
"chars": 705,
"preview": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pn"
},
{
"path": ".husky/pre-commit",
"chars": 91,
"preview": "#!/usr/bin/env sh\n. \"$(dirname -- \"$0\")/_/husky.sh\"\n\nnpx pretty-quick --staged\nnpm run lint"
},
{
"path": ".prettierrc",
"chars": 323,
"preview": "{\n \"plugins\": [\"prettier-plugin-tailwindcss\"],\n \"arrowParens\": \"always\",\n \"bracketSpacing\": true,\n \"endOfLine\": \"lf\""
},
{
"path": ".vscode/extensions.json",
"chars": 713,
"preview": "{\n \"recommendations\": [\n \"formulahendry.auto-close-tag\",\n \"steoates.autoimport\",\n \"formulahendry.auto-rename-t"
},
{
"path": "LICENSE",
"chars": 34523,
"preview": " GNU AFFERO GENERAL PUBLIC LICENSE\n Version 3, 19 November 2007\n\n Copyright (C)"
},
{
"path": "README.md",
"chars": 2185,
"preview": "<div align=\"center\">\n\n# ✏ [writedown (beta)](https://writedown.app)\n\n#### Free and Open Source Markdown Diary\n\n#### Publ"
},
{
"path": "animations/pencil-write-dark.json",
"chars": 23391,
"preview": "{\n \"nm\": \"Pencil\",\n \"ddd\": 0,\n \"h\": 800,\n \"w\": 800,\n \"meta\": { \"g\": \"@lottiefiles/toolkit-js 0.26.1\" },\n \"layers\":"
},
{
"path": "animations/pencil-write.json",
"chars": 22415,
"preview": "{\n \"v\": \"4.6.6\",\n \"fr\": 24,\n \"ip\": 0,\n \"op\": 48,\n \"w\": 800,\n \"h\": 800,\n \"nm\": \"Pencil\",\n \"ddd\": 0,\n \"assets\": ["
},
{
"path": "components/Navbar.tsx",
"chars": 1207,
"preview": "import Link from \"next/link\";\nimport React from \"react\";\nimport UserMenu from \"./common/UserMenu\";\nimport { RiMenu5Fill "
},
{
"path": "components/common/HeadTags.tsx",
"chars": 2057,
"preview": "import Head from \"next/head\";\nimport React from \"react\";\n\ntype HeadTagsProps = {\n title: string;\n ogImage: string;\n d"
},
{
"path": "components/common/UserMenu.tsx",
"chars": 2963,
"preview": "import {\n BiHomeAlt,\n BiLogInCircle,\n BiLogOutCircle,\n BiMoon,\n BiPencil,\n BiSun,\n} from \"react-icons/bi\";\nimport "
},
{
"path": "components/dashboard/CheckUsername.tsx",
"chars": 2302,
"preview": "import React, { useEffect, useState } from \"react\";\nimport { toast } from \"react-hot-toast\";\nimport useUser from \"../hoo"
},
{
"path": "components/dashboard/Sidebar/PostRow.tsx",
"chars": 2442,
"preview": "import React from \"react\";\nimport Skeleton from \"react-loading-skeleton\";\nimport { useAtom, useAtomValue } from \"jotai\";"
},
{
"path": "components/dashboard/Sidebar/ThemeChanger.tsx",
"chars": 344,
"preview": "import { useTheme } from \"next-themes\";\nimport Button from \"../../ui/Button\";\n\nexport default function ThemeChanger() {\n"
},
{
"path": "components/dashboard/Sidebar/index.tsx",
"chars": 7178,
"preview": "import React, { useEffect, useState } from \"react\";\nimport Link from \"next/link\";\nimport { useRouter } from \"next/router"
},
{
"path": "components/dashboard/TextArea/EditorButtons.tsx",
"chars": 7348,
"preview": "import React, { useState } from \"react\";\nimport {\n LuBold,\n LuLink,\n LuCheckSquare,\n LuCode,\n LuHeading1,\n LuHeadi"
},
{
"path": "components/dashboard/TextArea/LinkPreview.tsx",
"chars": 2817,
"preview": "import { LuLink } from \"react-icons/lu\";\nimport {\n NodeViewWrapper,\n ReactNodeViewRenderer,\n Node,\n mergeAttributes,"
},
{
"path": "components/dashboard/TextArea/PostButtons.tsx",
"chars": 11414,
"preview": "import React, { useEffect, useState } from \"react\";\nimport { useTheme } from \"next-themes\";\nimport { useAtom } from \"jot"
},
{
"path": "components/dashboard/TextArea/index.tsx",
"chars": 7939,
"preview": "import { selectedNoteAtom } from \"@/stores/postDataAtom\";\nimport CodeBlockLowlight from \"@tiptap/extension-code-block-lo"
},
{
"path": "components/home/FeatureCard.tsx",
"chars": 688,
"preview": "import React from \"react\";\n\ntype FeatureCardProps = {\n icon: React.ReactNode;\n title: string;\n description: string;\n}"
},
{
"path": "components/home/Features.tsx",
"chars": 1542,
"preview": "import {\n FiBox,\n FiCloudLightning,\n FiEye,\n FiGithub,\n FiGlobe,\n FiPackage,\n FiRefreshCcw,\n FiSmile,\n FiSun,\n "
},
{
"path": "components/home/Footer.tsx",
"chars": 1392,
"preview": "import { FEATURE_FLAGS } from \"@/constants/feature-flags\";\nimport BetaBadge from \"../ui/BetaBadge\";\nimport { auth } from"
},
{
"path": "components/home/HeroSection.tsx",
"chars": 1594,
"preview": "import { Parallax } from \"react-scroll-parallax\";\nimport { auth } from \"@/lib/firebase\";\nimport Button from \"../ui/Butto"
},
{
"path": "components/home/Navbar.tsx",
"chars": 1544,
"preview": "import { FEATURE_FLAGS } from \"@/constants/feature-flags\";\nimport { FiMoon, FiSun } from \"react-icons/fi\";\nimport BetaBa"
},
{
"path": "components/hooks/UsePaginateQuery.ts",
"chars": 1855,
"preview": "import {\n startAfter,\n query,\n getDocs,\n DocumentData,\n QueryDocumentSnapshot,\n} from \"firebase/firestore\";\nimport "
},
{
"path": "components/hooks/useMounted.ts",
"chars": 233,
"preview": "import { useEffect, useState } from \"react\";\n\nconst useMounted = () => {\n const [isMounted, setIsMounted] = useState(fa"
},
{
"path": "components/hooks/useNotes.ts",
"chars": 3121,
"preview": "import {\n collection,\n deleteDoc,\n doc,\n getDoc,\n orderBy,\n query,\n setDoc,\n updateDoc,\n} from \"firebase/firesto"
},
{
"path": "components/hooks/usePublicNotes.ts",
"chars": 808,
"preview": "import { useDocumentData } from \"react-firebase-hooks/firestore\";\nimport { doc } from \"firebase/firestore\";\nimport { db "
},
{
"path": "components/hooks/useUser.ts",
"chars": 3316,
"preview": "import { deleteDoc, doc, getDoc, writeBatch } from \"firebase/firestore\";\nimport { userDocConverter } from \"@/utils/fires"
},
{
"path": "components/login/InfoSidebar.tsx",
"chars": 1173,
"preview": "import React from \"react\";\nconst InfoSidebar = () => {\n return (\n <div className=\"relative h-1/2 w-full flex-col gap"
},
{
"path": "components/login/SignInArea.tsx",
"chars": 2591,
"preview": "import {\n useSignInWithGithub,\n useSignInWithGoogle,\n} from \"react-firebase-hooks/auth\";\nimport { authErrorCodes } fro"
},
{
"path": "components/ui/Badge.tsx",
"chars": 915,
"preview": "import React, { HTMLAttributes } from \"react\";\n\ntype BadgeProps = {\n children: React.ReactNode;\n color: \"yellow\" | \"gr"
},
{
"path": "components/ui/BetaBadge.tsx",
"chars": 336,
"preview": "import React from \"react\";\n\ntype BetaBadgeProps = {\n pulse?: boolean;\n};\n\nconst BetaBadge = ({ pulse }: BetaBadgeProps)"
},
{
"path": "components/ui/Button.tsx",
"chars": 2390,
"preview": "import React, { ButtonHTMLAttributes } from \"react\";\n\ninterface ButtonProps {\n variant?: \"red\" | \"green\" | \"slate\" | \"b"
},
{
"path": "components/ui/IconButton.tsx",
"chars": 460,
"preview": "import React from \"react\";\n\ntype IconButtonProps = {\n children: React.ReactNode;\n extraClasses?: HTMLButtonElement[\"cl"
},
{
"path": "components/ui/Input.tsx",
"chars": 628,
"preview": "import { InputHTMLAttributes } from \"react\";\nimport React from \"react\";\n\nconst Input = ({\n label,\n id,\n small,\n ...r"
},
{
"path": "components/ui/Loading.tsx",
"chars": 1091,
"preview": "import darkLoadingAnimation from \"@/animations/pencil-write-dark.json\";\nimport loadingAnimation from \"@/animations/penci"
},
{
"path": "components/ui/Modal.tsx",
"chars": 3075,
"preview": "import { Dialog, Transition } from \"@headlessui/react\";\nimport Button from \"./Button\";\nimport React from \"react\";\n\ninter"
},
{
"path": "components/ui/Popover.tsx",
"chars": 1666,
"preview": "import { Popover as HeadlessPopover, Transition } from \"@headlessui/react\";\nimport { Fragment } from \"react\";\n\ntype Popo"
},
{
"path": "components/ui/Toggle.tsx",
"chars": 1033,
"preview": "import { Switch } from \"@headlessui/react\";\nimport { useState } from \"react\";\n\ntype ToggleProps = {\n enabled: boolean;\n"
},
{
"path": "components/ui/WritedownEditor.tsx",
"chars": 1013,
"preview": "import { selectedNoteAtom } from \"@/stores/postDataAtom\";\nimport { NoteDocument } from \"@/types/utils/firebaseOperations"
},
{
"path": "constants/channel-background-colors.ts",
"chars": 244,
"preview": "export const channelBackgroundColors = [\n \"from-teal-400 to-blue-500\",\n \"from-sky-500 to-indigo-600\",\n \"from-violet-5"
},
{
"path": "constants/feature-flags.ts",
"chars": 96,
"preview": "export const FEATURE_FLAGS = {\n beta: process.env.NEXT_PUBLIC_FEATURE_FLAG_BETA === \"true\",\n};\n"
},
{
"path": "constants/firebase-auth-error-codes.ts",
"chars": 7275,
"preview": "export const authErrorCodes = {\n \"auth/claims-too-large\":\n \"The claims payload provided to setCustomUserClaims() exc"
},
{
"path": "declaration.d.ts",
"chars": 26,
"preview": "declare module \"preline\";\n"
},
{
"path": "docs/colors.md",
"chars": 151,
"preview": "# Mapping Colors from Light to Dark\n\n50 - 900\n\n100 - 800\n\n200 - 700\n\n300 - 600\n\n400 - 500\n\n500 - 400\n\n600 - 300\n\n700 - 2"
},
{
"path": "docs/firebase.md",
"chars": 1118,
"preview": "# Firebase Emulator Setup\n\n## Setup\n\n0. Don't use Windows and install Java 12+.\n\n1. Install the Firebase CLI\n\n```bash\ncu"
},
{
"path": "docs/tiptap.md",
"chars": 443,
"preview": "# TipTap Setup\n\n## Setup\n\n1. Create a TipTap account at [cloud.tiptap.dev](https://cloud.tiptap.dev/pro-extensions).\n2. "
},
{
"path": "firebase.json",
"chars": 329,
"preview": "{\n \"firestore\": {\n \"rules\": \"firestore.rules\",\n \"indexes\": \"firestore.indexes.json\"\n },\n \"emulators\": {\n \"au"
},
{
"path": "firestore.indexes.json",
"chars": 841,
"preview": "{\n \"indexes\": [\n {\n \"collectionGroup\": \"messages\",\n \"queryScope\": \"COLLECTION_GROUP\",\n \"fields\": [\n "
},
{
"path": "firestore.rules",
"chars": 1142,
"preview": "rules_version = '2';\nservice cloud.firestore {\n match /databases/{database}/documents {\n\n match /users/{userId} {\n "
},
{
"path": "html2pdf.js.d.ts",
"chars": 30,
"preview": "declare module \"html2pdf.js\";\n"
},
{
"path": "lib/firebase.ts",
"chars": 960,
"preview": "import { Firestore, getFirestore } from \"firebase/firestore\";\nimport { FirebaseApp, getApps, initializeApp } from \"fireb"
},
{
"path": "next.config.js",
"chars": 289,
"preview": "/** @type {import('next').NextConfig} */\nconst runtimeCaching = require(\"next-pwa/cache\");\nconst withPWA = require(\"next"
},
{
"path": "package.json",
"chars": 2172,
"preview": "{\n \"private\": true,\n \"scripts\": {\n \"dev\": \"next dev\",\n \"build\": \"next build\",\n \"start\": \"next start\",\n \"li"
},
{
"path": "pages/[username]/posts/[postId].tsx",
"chars": 6030,
"preview": "import { useEffect, useState } from \"react\";\nimport { useRouter } from \"next/router\";\nimport Markdown from \"react-markdo"
},
{
"path": "pages/_app.tsx",
"chars": 1455,
"preview": "import { ParallaxProvider } from \"react-scroll-parallax\";\nimport { SkeletonTheme } from \"react-loading-skeleton\";\nimport"
},
{
"path": "pages/api/link-preview.ts",
"chars": 1095,
"preview": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport * as cheerio from \"cheerio\";\n\nexport default async functi"
},
{
"path": "pages/api/og.tsx",
"chars": 2138,
"preview": "import { NextRequest, NextResponse } from \"next/server\";\nimport { ImageResponse } from \"@vercel/og\";\n\nexport const confi"
},
{
"path": "pages/dashboard.tsx",
"chars": 2074,
"preview": "import CheckUsername from \"@/components/dashboard/CheckUsername\";\nimport { useAuthState } from \"react-firebase-hooks/aut"
},
{
"path": "pages/index.tsx",
"chars": 880,
"preview": "import HeroSection from \"@/components/home/HeroSection\";\nimport HeadTags from \"@/components/common/HeadTags\";\nimport Fea"
},
{
"path": "pages/login.tsx",
"chars": 1635,
"preview": "import InfoSidebar from \"@/components/login/InfoSidebar\";\nimport { useAuthState } from \"react-firebase-hooks/auth\";\nimpo"
},
{
"path": "pages/not-found.tsx",
"chars": 157,
"preview": "import React from \"react\";\n\ntype Props = {};\n\nconst NotFoundPapge = (props: Props) => {\n return <div>NotFoundPapge</div"
},
{
"path": "postcss.config.js",
"chars": 83,
"preview": "module.exports = {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n};\n"
},
{
"path": "public/manifest.json",
"chars": 747,
"preview": "{\n \"theme_color\": \"#e2e8f0\",\n \"background_color\": \"#e2e8f0\",\n \"display\": \"standalone\",\n \"scope\": \"/\",\n \"start_url\":"
},
{
"path": "stores/postDataAtom.ts",
"chars": 293,
"preview": "import { atom } from \"jotai\";\n\ntype SelectedNote = {\n id: string;\n title: string;\n isPublic: boolean;\n content: stri"
},
{
"path": "stores/syncLoadingAtom.ts",
"chars": 75,
"preview": "import { atom } from \"jotai\";\n\nexport const syncLoadingAtom = atom(false);\n"
},
{
"path": "stores/syncedAtom.ts",
"chars": 71,
"preview": "import { atom } from \"jotai\";\n\nexport const isSyncedAtom = atom(true);\n"
},
{
"path": "styles/code-block.css",
"chars": 1837,
"preview": "/**\n * Dracula Theme originally by Zeno Rocha [@zenorocha]\n * https://draculatheme.com/\n *\n * Ported for PrismJS by Albe"
},
{
"path": "styles/globals.css",
"chars": 1814,
"preview": "@import url(\"https://api.fonts.coollabs.io/css2?family=Poppins:wght@300;400;500;600;700&display=swap\");\n@import url(\"htt"
},
{
"path": "tailwind.config.js",
"chars": 596,
"preview": "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n content: [\n \"node_modules/preline/dist/*.js\",\n \"."
},
{
"path": "todo.md",
"chars": 45,
"preview": "- [ ] Remove headless UI\n- [ ] Add ShadCN UI\n"
},
{
"path": "tsconfig.json",
"chars": 615,
"preview": "{\n \"compilerOptions\": {\n \"target\": \"es5\",\n \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n \"allowJs\": true,\n \"sk"
},
{
"path": "types/components/firebase-hooks.d.ts",
"chars": 142,
"preview": "import { User } from \"firebase/auth\";\n\nexport interface IFirebaseAuth {\n user?: User | null;\n userLoading?: boolean;\n "
},
{
"path": "types/utils/firebaseOperations.d.ts",
"chars": 449,
"preview": "export type NoteDocument = {\n id: string;\n createdAt?: number;\n updatedAt: number;\n publishedAt?: number;\n title: s"
},
{
"path": "utils/debounce.ts",
"chars": 237,
"preview": "export const debounce = (fn: any, time: number) => {\n let timeout: any = null;\n return (...args: any) => {\n if (tim"
},
{
"path": "utils/firestoreDataConverter.ts",
"chars": 496,
"preview": "import {\n NoteDocument,\n PublicNoteDocument,\n UserDocument,\n} from \"@/types/utils/firebaseOperations\";\nimport { Query"
},
{
"path": "utils/markdownStyles.ts",
"chars": 27021,
"preview": "export const markdownStyles = {\n github:\n '@media (prefers-color-scheme: dark) {\\n .markdown-body {\\n color-sche"
}
]
About this extraction
This page contains the full source code of the NayamAmarshe/writedown GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 80 files (224.9 KB), approximately 64.5k tokens, and a symbol index with 41 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.