Skip to content

Commit

Permalink
feat: faq-toc (#777)
Browse files Browse the repository at this point in the history
* feat: faq-toc

* optimize code
  • Loading branch information
Codigo-Fuentes authored Nov 18, 2021
1 parent a2f4f71 commit 365107e
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 120 deletions.
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
import HashLink from '../components/hashlink.js'
import InlineCode from '../components/inline-code.js'
import Link from 'next/link'
import InlineCode from '../../components/inline-code'

/**
* Static Props
*
* @returns {{ props: import('../components/types.js').LayoutProps}}
*/
export const getStaticProps = () => ({
props: {
title: 'FAQ - NFT Storage',
navBgColor: 'bg-nsforest',
needsUser: false,
},
})

/**
* FAQ Page
*
*/
const Faq = () => (
<main className="bg-nsforest">
<div className="mw9 center pv3 ph3 ph5-ns min-vh-100">
<h1 className="chicagoflf white mv4 flex-auto ">FAQ</h1>
<FAQ />
</div>
</main>
)

export const ShortFaq = () => (
<>
<h2 className="chicagoflf white">
<HashLink id="what-is-the-long-term-vision-for-nftstorage">
What is the long-term vision for NFT.Storage?
</HashLink>
</h2>
<p className="lh-copy white mb4">
export default {
longTermVision: (
<p>
NFT.Storage helps NFT developers today who are looking for easy APIs and
best practices for storing their NFT data securely and resiliently. Even
in the short-term, it is a trustless and decentralized solution. Users are
Expand Down Expand Up @@ -66,11 +34,8 @@ export const ShortFaq = () => (
horizon, will help upgrade {"today's"} NFT.Storage implementation into the
provably permanent storage solutions of tomorrow.
</p>
<h2 className="chicagoflf white">
<HashLink id="how-long-will-data-be-stored-on-nftstorage">
How long will data be stored on NFT.Storage?
</HashLink>
</h2>
),
dataStorageLength: (
<p className="lh-copy white mb4">
Data will be available in IPFS indefinitely as well as stored in
long-term, redundant Filecoin storage deals with the global community of
Expand All @@ -80,22 +45,16 @@ export const ShortFaq = () => (
</Link>{' '}
for details.
</p>
<h2 className="chicagoflf white">
<HashLink id="are-there-any-size-restrictions-for-stored-nfts">
Are there any size restrictions for stored NFTs?
</HashLink>
</h2>
),
nftSizeRestrictions: (
<p className="lh-copy white mb4">
NFT.Storage can store NFTs up to <strong>31GiB </strong>
in size! (There was previously a 100MB limit due to Cloudflare workers but
NFT.Storage now supports chunked uploads, allowing files bigger than 100MB
to be uploaded! 🎉)
</p>
<h2 className="chicagoflf white">
<HashLink id="where-can-i-learn-more-about-nft-best-practices">
Where can I learn more about NFT best practices?
</HashLink>
</h2>
),
nftBestPractices: (
<p className="lh-copy white mb4">
Visit{' '}
<a href="https://nftschool.dev" className="white">
Expand All @@ -104,45 +63,24 @@ export const ShortFaq = () => (
for information on NFT best practices as well as a variety of helpful
tutorials and how-to guides for NFT developers.
</p>
<h2 className="chicagoflf white">
<HashLink id="who-can-access-the-data-i-store-on-nftstorage">
Who can access the data I store on NFT.Storage?
</HashLink>
</h2>
),
whoHasAccess: (
<p className="lh-copy white mb4">
All data uploaded to NFT.Storage is available to anyone who requests it
using the correct CID. Do not store any private or sensitive information
in an unencrypted form using NFT.Storage.
</p>
</>
)

/**
* FAQ Content
*
*/
const FAQ = () => (
<>
<ShortFaq />
<h2 className="chicagoflf white">
<HashLink id="can-i-delete-my-data-on-nftstorage">
Can I delete my data on NFT.Storage?
</HashLink>
</h2>
),
dataDeletion: (
<p className="lh-copy white mb4">
You can delete data from being associated with your account, and it will
no longer appear on the Files page of your account. However, this doesn’t
prevent nodes in the IPFS decentralized storage network from retaining
copies of the data indefinitely. Do not use NFT.Storage for data that may
need to be permanently deleted in the future.
</p>
<h2 className="chicagoflf white">
<HashLink id="can-i-delete-my-data-on-nftstorage">
I tried using an HTTP gateway to retrieve my content from IPFS but am
receiving an HTTP error. Does this mean my content was not stored
successfully on NFT.Storage?
</HashLink>
</h2>
),
httpGatewayError: (
<p className="lh-copy white mb4">
Not necessarily! HTTP gateways are a great way for users who {"aren't"}{' '}
running their own IPFS nodes to retrieve content from the IPFS network.
Expand All @@ -158,11 +96,8 @@ const FAQ = () => (
data to the gateway. Using NFT.Storage makes sure that the content stored
is broadcasted to the network using best practices!
</p>
<h2 className="chicagoflf white">
<HashLink id="how-is-nftstorage-free-to-use">
How is NFT.Storage free to use?
</HashLink>
</h2>
),
howIsNftStorageFree: (
<p className="lh-copy white mb4">
Filecoin storage providers commit their hard drive capacity to the
Filecoin network, and earn significant block rewards for doing so. This
Expand Down Expand Up @@ -202,11 +137,8 @@ const FAQ = () => (
our mission to grow the decentralized storage ecosystem and preserve
humanity&#39;s information for future generations.
</p>
<h2 className="chicagoflf white">
<HashLink id="is-there-a-limit-on-numbers-of-files-in-a-directory">
Is there a limit on numbers of files in a directory?
</HashLink>
</h2>
),
filesLimit: (
<p className="lh-copy white mb4">
It depends. If you&#39;re using <InlineCode>storeDirectory</InlineCode>{' '}
from the JS library (i.e. sending a multipart HTTP request) then the
Expand Down Expand Up @@ -251,12 +183,8 @@ const FAQ = () => (
meaning the directory node likely won&#39;t grow beyond the 1MiB block
limit.
</p>
<h2 className="chicagoflf white">
<HashLink id="why-syntax-error-unexpected-token">
Why am I seeing{' '}
<InlineCode>SyntaxError: Unexpected token &#39;.&#39;</InlineCode>?
</HashLink>
</h2>
),
unexpectedToken: (
<p className="lh-copy white mb4">
<strong>Try updating to Node version 14 or later</strong>. We no longer
offer support for versions prior to v14 (
Expand All @@ -274,15 +202,8 @@ const FAQ = () => (
</a>{' '}
with an old version of Node.
</p>
<h2 className="chicagoflf white">
<HashLink id="why-syntax-error-cannot-use-import-statement-outside-a-module">
Why am I seeing{' '}
<InlineCode>
SyntaxError: Cannot use import statement outside a module
</InlineCode>
?
</HashLink>
</h2>
),
importStatementOutsideModule: (
<p className="lh-copy white mb4">
<strong>Try updating to Node version 14 or later</strong>. This error can
occur because of having an old version of Node. We no longer offer support
Expand All @@ -294,11 +215,8 @@ const FAQ = () => (
<InlineCode>import</InlineCode> if you are using ESM Modules, otherwise
you will need to use <InlineCode>require</InlineCode>.
</p>
<h2 className="chicagoflf white">
<HashLink id="why-no-support-for-node-pre-14">
Why don&#39;t you support versions of Node prior to v14?
</HashLink>
</h2>
),
nodeSupport: (
<p className="lh-copy white mb4">
We do not support versions of Node prior to v14 because they are not
considered active{' '}
Expand All @@ -321,11 +239,8 @@ const FAQ = () => (
</a>
.
</p>
<h2 className="chicagoflf white">
<HashLink id="upload-metadata-with-existing-image-url">
Upload metadata with existing image url?
</HashLink>
</h2>
),
httpUrls: (
<p className="lh-copy white mb4">
We generally try to steer people away from linking to specific HTTP
gateways, since they can be a single point of failure and may go down or
Expand All @@ -344,7 +259,5 @@ const FAQ = () => (
stores IPFS URIs in the metadata, but it could easily be modified to store
gateway URLs instead.
</p>
</>
)

export default Faq
),
}
145 changes: 145 additions & 0 deletions packages/website/pages/faq/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import Link from 'next/link'
import HashLink from '../../components/hashlink.js'
import InlineCode from '../../components/inline-code.js'
import faqContent from './faqContent.js'

/**
* @param {string} title
* @returns {string}
*/
const hashify = title =>
title
.substring(0, title.length - 1)
.toLowerCase()
.replace(/\s|\./g, '-')

/**
* Static Props
*
* @returns {{ props: import('../../components/types.js').LayoutProps}}
*/
export const getStaticProps = () => ({
props: {
title: 'FAQ - NFT Storage',
navBgColor: 'bg-nsforest',
needsUser: false,
},
})

const faqs = [
{
question: 'What is the long-term vision for NFT.Storage?',
content: faqContent.longTermVision,
},
{
question: 'How long will data be stored on NFT.Storage?',
content: faqContent.dataStorageLength,
},
{
question: 'Are there any size restrictions for stored NFTs?',
content: faqContent.nftSizeRestrictions,
},
{
question: 'Where can I learn more about NFT best practices?',
content: faqContent.nftBestPractices,
},
{
question: 'Who can access the data I store on NFT.Storage?',
content: faqContent.whoHasAccess,
},
{
question: 'Can I delete my data on NFT.Storage?',
content: faqContent.dataDeletion,
},
{
question:
'I tried using an HTTP gateway to retrieve my content from IPFS but am receiving an HTTP error. Does this mean my content was not stored successfully on NFT.Storage?',
content: faqContent.httpGatewayError,
},
{
question: 'How is NFT.Storage free to use?',
content: faqContent.howIsNftStorageFree,
},
{
question: 'Is there a limit on numbers of files in a directory?',
content: faqContent.filesLimit,
},
{
question: 'Why am I seeing syntax error unexpected token?',
error: `SyntaxError: Unexpected token '.'`,
content: faqContent.unexpectedToken,
},
{
question:
'Why am I seeing syntax error cannot use import statement outside a module?',
error: 'SyntaxError: Cannot use import statement outside a module',
content: faqContent.importStatementOutsideModule,
},
{
question: `Why don't you support versions of Node prior to v14?`,
content: faqContent.nodeSupport,
},
{
question: 'Upload metadata with existing image url?',
content: faqContent.httpUrls,
},
]

const TOC = () => (
<div className="flex flex-column pv1 mw7`">
<h2 className="chicagoflf white">Table Of Contents</h2>
{faqs.map((faq, index) => (
<Link href={`/faq/#${hashify(faq.question)}`} key={`faq-item${index}`}>
<a className="white mv1 underline">
{faq.error ? `Why am I seeing: ${faq.error}` : faq.question}
</a>
</Link>
))}
</div>
)

/**
* @param {Object} props
* @param {number} [props.limit]
*/
export const FAQ = ({ limit = faqs.length }) => {
const items = limit ? faqs.slice(0, limit) : faqs
return (
<>
{items.slice(0, limit).map((faq, index) => (
<div className="faq-item" key={`faq-item${index}`}>
<h2 className="chicagoflf white">
<HashLink id={hashify(faq.question)}>
{faq.error ? (
<>
Why am I seeing:&nbsp;<InlineCode>{faq.error}</InlineCode>
</>
) : (
faq.question
)}
</HashLink>
</h2>
<div className="lh-copy white mb4">{faq.content}</div>
</div>
))}
</>
)
}

/**
* FAQ Page
*
*/
const Faq = () => (
<main className="bg-nsforest">
<div className="mw9 center pv3 ph3 ph5-ns min-vh-100">
<h1 className="chicagoflf white mv4 flex-auto ">FAQ</h1>
<div className="mb5">
<TOC />
</div>
<FAQ />
</div>
</main>
)

export default Faq
Loading

0 comments on commit 365107e

Please sign in to comment.