This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
forked from i18nlaurel/Web3-Glossary
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mapachurro/term-link
Term link
- Loading branch information
Showing
70 changed files
with
37,897 additions
and
764 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
input: ['src/**/*.{js,jsx}'], // Specify the input files to scan | ||
output: 'src/i18n/locales/', // Specify the output directory for the translation files | ||
options: { | ||
debug: true, // Enable debugging | ||
removeUnusedKeys: false, // Remove unused translation keys | ||
func: { | ||
list: ['i18next.t', 'i18n.t'], // List of functions to scan for translation keys | ||
extensions: ['.js', '.jsx'] // File extensions to scan | ||
}, | ||
lngs: ['en', 'es', 'ar', 'de', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pt-br', 'ru', 'th', 'tl', 'tr', 'uk', 'vi', 'zh-cn'], // List of languages to generate translation files for | ||
ns: ['translation'], // Namespace to use for translation keys | ||
defaultLng: 'en', // Default language | ||
resource: { | ||
loadPath: 'src/i18n/locales/{{lng}}/{{ns}}.json', // Path to load existing translation files | ||
savePath: 'src/i18n/locales/{{lng}}/{{ns}}.json', // Path to save updated translation files | ||
jsonIndent: 2 // Indentation for the JSON files | ||
} | ||
} | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
import { Link } from "./Link"; | ||
import "./Breadcrumbs.css"; | ||
import { Fragment } from "react"; | ||
|
||
export function Breadcrumbs({ segments }) { | ||
const homeLink = ( | ||
<Link here="/" key="home"> | ||
Home | ||
</Link> | ||
); | ||
|
||
let path = ""; | ||
const result = [ | ||
<p className="split" key={`/`}> | ||
/ | ||
</p>, | ||
]; | ||
const result = [homeLink]; | ||
|
||
for (let i = 0; i < segments.length; i++) { | ||
const v = segments[i]; | ||
if (i === segments.length - 1) { | ||
result.push(<Fragment key={"last"}>{v}</Fragment>); | ||
} else { | ||
path += v; | ||
result.push( | ||
<Link here={path} key={path}> | ||
{v} | ||
</Link> | ||
); | ||
path += v; | ||
const isLast = i === segments.length - 1; | ||
|
||
// Render regular text instead of a link for the current page | ||
const breadcrumb = isLast ? ( | ||
<span key={path}>{v}</span> | ||
) : ( | ||
<Link here={path} key={path}> | ||
{v} | ||
</Link> | ||
); | ||
|
||
result.push(breadcrumb); | ||
|
||
// Add a "/" separator after each segment except for the last one | ||
if (!isLast) { | ||
result.push( | ||
<p className="split" key={`${path}/`}> | ||
<span className="split" key={`${path}/`}> | ||
/ | ||
</p> | ||
</span> | ||
); | ||
path += "/"; | ||
} | ||
path += "/"; | ||
} | ||
console.log(result); | ||
|
||
return <div className="Breadcrumbs">{result}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import terms from './terms.json'; | ||
import linkedDefinitions from './linked-definitions.jsx'; | ||
|
||
function EntryPage() { | ||
const { termKey } = useParams(); | ||
const [termContent, setTermContent] = useState(null); | ||
|
||
useEffect(() => { | ||
const termData = terms.find(term => term.terms[termKey]); | ||
if (termData) { | ||
setTermContent(termData.terms[termKey]); | ||
} else { | ||
console.error(`Term "${termKey}" not found`); | ||
} | ||
}, [termKey]); | ||
|
||
if (!termContent) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const linkedDefinition = linkedDefinitions[termKey]?.definition || termContent.definition; | ||
|
||
return ( | ||
<div> | ||
<h1>{termContent.term}</h1> | ||
<p>{linkedDefinition}</p> | ||
{/* Render other content based on term data */} | ||
</div> | ||
); | ||
} | ||
|
||
export default EntryPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import Search from './components/Search'; | ||
import index from './searchIndex'; | ||
import terms from './terms'; | ||
|
||
function Home() { | ||
const [searchResults, setSearchResults] = useState([]); | ||
const navigate = useNavigate(); | ||
|
||
const handleSearch = (query) => { | ||
console.log('Searching for:', query); | ||
const results = index.search(query); | ||
console.log('Search results:', results); | ||
const formattedResults = results.map((result) => ({ | ||
term: result.ref, | ||
})); | ||
setSearchResults(formattedResults); | ||
console.log('Updated searchResults:', formattedResults); | ||
}; | ||
|
||
const allTerms = Object.keys(terms["0"]["terms"]); | ||
|
||
return ( | ||
<div> | ||
<h2>Search the Education DAO Glossary:</h2> | ||
<Search onSearch={handleSearch} /> | ||
<ul> | ||
{searchResults.map((result) => ( | ||
<li | ||
key={result.term} | ||
onClick={() => navigate(`/term/${result.term}`)} | ||
style={{ | ||
cursor: allTerms.includes(result.term) ? 'pointer' : 'default', | ||
}} | ||
> | ||
{result.term} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,17 @@ | ||
import { useMemo } from "react"; | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export function Link({ to, here, children }) { | ||
if (to && here) { | ||
throw new Error(); | ||
} | ||
const loc = useMemo(() => { | ||
let location; | ||
if (here) { | ||
location = `/${here}`; | ||
} else { | ||
location = urlToPath(); | ||
location.push(to); | ||
location = `/${location.join("/")}`; | ||
} | ||
return location; | ||
}, [to, here]); | ||
export function Link({ to, children }) { | ||
const navigate = useNavigate(); | ||
|
||
const preventReload = (event) => { | ||
const handleClick = (event) => { | ||
event.preventDefault(); | ||
console.log(loc); | ||
window.history.pushState({}, "", loc); | ||
const navigationEvent = new PopStateEvent("navigate"); | ||
window.dispatchEvent(navigationEvent); | ||
navigate(to); | ||
}; | ||
|
||
return ( | ||
<a href={loc} onClick={preventReload}> | ||
<a href={to} onClick={handleClick}> | ||
{children} | ||
</a> | ||
); | ||
} | ||
|
||
export function urlToPath() { | ||
return window.location.pathname | ||
.slice(1) | ||
.split("/") | ||
.filter((v) => v.length) | ||
.map((v) => decodeURIComponent(v)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.Definition { | ||
.Term { | ||
max-width: 35rem; | ||
} | ||
.declaration { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
const Definition = ({ definition }) => { | ||
return <div>{definition}</div>; | ||
}; | ||
|
||
export default Definition; |
Oops, something went wrong.