chore: Fixing linter warnings
This commit is contained in:
parent
f9e3236253
commit
8225009e96
25 changed files with 20 additions and 187 deletions
|
@ -1,64 +1,8 @@
|
||||||
import React from 'react'
|
|
||||||
import { useState } from 'react'
|
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import Link from 'next/link'
|
|
||||||
// Shared components
|
|
||||||
import Logo from 'shared/components/logos/freesewing.js'
|
|
||||||
import PrimaryNavigation from 'shared/components/navigation/primary'
|
|
||||||
import get from 'lodash.get'
|
|
||||||
import Right from 'shared/components/icons/right.js'
|
|
||||||
import Left from 'shared/components/icons/left.js'
|
|
||||||
// Site components
|
// Site components
|
||||||
import Header from 'site/components/header'
|
import Header from 'site/components/header'
|
||||||
import Footer from 'site/components/footer'
|
import Footer from 'site/components/footer'
|
||||||
|
|
||||||
export const PageTitle = ({ app, slug, title }) => {
|
|
||||||
if (title) return <h1>{title}</h1>
|
|
||||||
if (slug) return <h1>{get(app.navigation, slug.split('/')).__title}</h1>
|
|
||||||
|
|
||||||
return <h1>FIXME: This page has no title</h1>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Breadcrumbs = ({ app, slug=false, title }) => {
|
|
||||||
if (!slug) return null
|
|
||||||
const crumbs = []
|
|
||||||
const chunks = slug.split('/')
|
|
||||||
for (const i in chunks) {
|
|
||||||
const j = parseInt(i)+parseInt(1)
|
|
||||||
const page = get(app.navigation, chunks.slice(0,j))
|
|
||||||
if (page) crumbs.push([page.__linktitle, '/'+chunks.slice(0,j).join('/'), (j < chunks.length)])
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ul className="flex flex-row flex-wrap gap-2 font-bold">
|
|
||||||
<li>
|
|
||||||
<Link href="/">
|
|
||||||
<a title="To the homepage" className="text-base-content">
|
|
||||||
<Logo size={24} fill="currentColor" stroke={false}/>
|
|
||||||
</a>
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
{crumbs.map(crumb => (
|
|
||||||
<React.Fragment key={crumb[1]}>
|
|
||||||
<li className="text-base-content">»</li>
|
|
||||||
<li>
|
|
||||||
{crumb[2]
|
|
||||||
? (
|
|
||||||
<Link href={crumb[1]}>
|
|
||||||
<a title={crumb[0]} className="text-secondary hover:text-secondary-focus">
|
|
||||||
{crumb[0]}
|
|
||||||
</a>
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
: <span className="text-base-content">{crumb[0]}</span>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
</React.Fragment>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const LayoutWrapper = ({ app, title=false, children=[] }) => {
|
const LayoutWrapper = ({ app, title=false, children=[] }) => {
|
||||||
|
|
||||||
const startNavigation = () => {
|
const startNavigation = () => {
|
||||||
|
@ -70,7 +14,6 @@ const LayoutWrapper = ({ app, title=false, children=[] }) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
router.events?.on('routeChangeStart', startNavigation)
|
router.events?.on('routeChangeStart', startNavigation)
|
||||||
router.events?.on('routeChangeComplete', app.stopLoading)
|
router.events?.on('routeChangeComplete', app.stopLoading)
|
||||||
const slug = router.asPath.slice(1)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`
|
<div className={`
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useSwipeable } from 'react-swipeable'
|
import { useSwipeable } from 'react-swipeable'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useHotkeys } from 'react-hotkeys-hook'
|
|
||||||
// Layouts components
|
// Layouts components
|
||||||
import LayoutWrapper from 'site/components/wrappers/layout'
|
import LayoutWrapper from 'site/components/wrappers/layout'
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { readdirSync } from 'fs'
|
import { readdirSync } from 'fs'
|
||||||
import i18nConfig from './next-i18next.config.js'
|
import i18nConfig from './next-i18next.config.js'
|
||||||
import { designs, plugins, packages } from '../../config/software/index.mjs'
|
import { designs, plugins } from '../../config/software/index.mjs'
|
||||||
import { banner } from '../../scripts/banner.mjs'
|
import { banner } from '../../scripts/banner.mjs'
|
||||||
|
|
||||||
const getDirectories = source =>
|
|
||||||
readdirSync(source, { withFileTypes: true })
|
|
||||||
.filter(dirent => dirent.isDirectory())
|
|
||||||
.map(dirent => dirent.name)
|
|
||||||
|
|
||||||
const pkgs = getDirectories(path.resolve(`../`))
|
|
||||||
|
|
||||||
let greeting = false
|
let greeting = false
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
import React from 'react'
|
|
||||||
import Page from 'site/components/wrappers/page.js'
|
import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import Head from 'next/head'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { defaultVersion, formatVersionTitle, formatVersionUri } from 'site/components/version-picker.js'
|
import { formatVersionTitle } from 'site/components/version-picker.js'
|
||||||
import TutorialIcon from 'shared/components/icons/tutorial.js'
|
|
||||||
import DesignIcon from 'shared/components/icons/design.js'
|
|
||||||
import BoxIcon from 'shared/components/icons/box.js'
|
|
||||||
import CogIcon from 'shared/components/icons/cog.js'
|
|
||||||
import Layout from 'site/components/layouts/bare'
|
import Layout from 'site/components/layouts/bare'
|
||||||
import Popout from 'shared/components/popout'
|
import { PageTitle } from 'site/components/wrappers/layout'
|
||||||
import { PageTitle, Breadcrumbs } from 'site/components/wrappers/layout'
|
|
||||||
import availableVersions from 'site/available-versions.json'
|
import availableVersions from 'site/available-versions.json'
|
||||||
|
|
||||||
const DesignLinks = ({ list, prefix='', version=false }) => {
|
const DesignLinks = ({ list, prefix='', version=false }) => {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import Page from 'site/components/wrappers/page.js'
|
import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import Link from 'next/link'
|
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import Layout from 'site/components/layouts/bare'
|
import Layout from 'site/components/layouts/bare'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import Navigation, { Icons } from 'shared/components/navigation/primary'
|
import { Icons } from 'shared/components/navigation/primary'
|
||||||
|
|
||||||
const HomePage = (props) => {
|
const HomePage = (props) => {
|
||||||
const app = useApp()
|
const app = useApp()
|
||||||
|
|
|
@ -4,14 +4,9 @@ import useApp from 'site/hooks/useApp.js'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { defaultVersion, formatVersionTitle, formatVersionUri } from 'site/components/version-picker.js'
|
import { formatVersionTitle } from 'site/components/version-picker.js'
|
||||||
import TutorialIcon from 'shared/components/icons/tutorial.js'
|
|
||||||
import DesignIcon from 'shared/components/icons/design.js'
|
|
||||||
import BoxIcon from 'shared/components/icons/box.js'
|
|
||||||
import CogIcon from 'shared/components/icons/cog.js'
|
|
||||||
import Layout from 'site/components/layouts/bare'
|
import Layout from 'site/components/layouts/bare'
|
||||||
import Popout from 'shared/components/popout'
|
import { PageTitle } from 'site/components/wrappers/layout'
|
||||||
import { PageTitle, Breadcrumbs } from 'site/components/wrappers/layout'
|
|
||||||
import availableVersions from 'site/available-versions.json'
|
import availableVersions from 'site/available-versions.json'
|
||||||
|
|
||||||
const DesignLinks = ({ list, prefix='', version=false }) => {
|
const DesignLinks = ({ list, prefix='', version=false }) => {
|
||||||
|
@ -59,10 +54,6 @@ const VersionListPage = ({ section=false, version=false }) => {
|
||||||
const app = useApp()
|
const app = useApp()
|
||||||
const { t } = useTranslation(['app'])
|
const { t } = useTranslation(['app'])
|
||||||
|
|
||||||
const title = section
|
|
||||||
? app.navigation[section].__title
|
|
||||||
: t('designs')
|
|
||||||
|
|
||||||
const currentDesigns = []
|
const currentDesigns = []
|
||||||
for (const section in app.designs) currentDesigns.push(...app.designs[section])
|
for (const section in app.designs) currentDesigns.push(...app.designs[section])
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ const loadDesign = async (design, setExamples) => {
|
||||||
const Design = ({ design }) => {
|
const Design = ({ design }) => {
|
||||||
const { t } = useTranslation(['patterns'])
|
const { t } = useTranslation(['patterns'])
|
||||||
const {
|
const {
|
||||||
code="Anonymous",
|
|
||||||
difficulty=3,
|
difficulty=3,
|
||||||
} = configs[design]
|
} = configs[design]
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,8 @@ import OsiLogo from 'shared/components/logos/osi.js'
|
||||||
import CreativeCommonsLogo from 'shared/components/logos/cc.js'
|
import CreativeCommonsLogo from 'shared/components/logos/cc.js'
|
||||||
import CcByLogo from 'shared/components/logos/cc-by.js'
|
import CcByLogo from 'shared/components/logos/cc-by.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import PageLink from 'shared/components/page-link'
|
|
||||||
import DocsLink from 'shared/components/docs-link'
|
import DocsLink from 'shared/components/docs-link'
|
||||||
import PinkedRibbon from 'shared/components/pinked-ribbon.js'
|
import PinkedRibbon from 'shared/components/pinked-ribbon.js'
|
||||||
import Worm from 'shared/components/worm.js'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
|
||||||
import DiscordIcon from 'shared/components/icons/discord.js'
|
import DiscordIcon from 'shared/components/icons/discord.js'
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import Link from 'next/link'
|
|
||||||
// Shared components
|
// Shared components
|
||||||
import Aside from 'shared/components/navigation/aside'
|
import Aside from 'shared/components/navigation/aside'
|
||||||
import ThemePicker from 'shared/components/theme-picker'
|
import ThemePicker from 'shared/components/theme-picker'
|
||||||
|
@ -21,10 +20,7 @@ const DefaultLayout = ({ app, title=false, crumbs=false, children=[] }) => {
|
||||||
{title && (
|
{title && (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs title={title} crumbs={breadcrumbs} />
|
<Breadcrumbs title={title} crumbs={breadcrumbs} />
|
||||||
{title
|
<h1>{title}</h1>
|
||||||
? <h1>{title}</h1>
|
|
||||||
: <h1>{app.getTitle(slug)}</h1>
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { capitalize } from 'shared/utils.js'
|
import { capitalize } from 'shared/utils.js'
|
||||||
import Link from 'next/link'
|
|
||||||
import { getConfig } from 'shared/designs/index.js'
|
import { getConfig } from 'shared/designs/index.js'
|
||||||
import Popout from 'shared/components/popout.js'
|
import Popout from 'shared/components/popout.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
|
@ -6,21 +6,6 @@ import PageLink from 'shared/components/page-link.js'
|
||||||
const PatternMeasurements = ({ pattern, before=null, after=null }) => {
|
const PatternMeasurements = ({ pattern, before=null, after=null }) => {
|
||||||
const { t } = useTranslation(['measurements'])
|
const { t } = useTranslation(['measurements'])
|
||||||
|
|
||||||
const sortMeasurements = (measurements) => {
|
|
||||||
if (typeof measurements === 'undefined') return []
|
|
||||||
let sorted = []
|
|
||||||
let translated = {}
|
|
||||||
for (let m of measurements) {
|
|
||||||
let translation = intl.messages['measurements.' + m] || m
|
|
||||||
translated[translation] = m
|
|
||||||
}
|
|
||||||
let order = Object.keys(translated)
|
|
||||||
order.sort()
|
|
||||||
for (let m of order) sorted.push(translated[m])
|
|
||||||
|
|
||||||
return sorted
|
|
||||||
}
|
|
||||||
|
|
||||||
const measurements = {}
|
const measurements = {}
|
||||||
for (const m of configs[pattern].measurements) {
|
for (const m of configs[pattern].measurements) {
|
||||||
measurements[m] = {
|
measurements[m] = {
|
||||||
|
|
|
@ -52,21 +52,6 @@ const renderOptions = (groups, pattern, t) => {
|
||||||
const PatternOptions = ({ pattern, before=null, after=null }) => {
|
const PatternOptions = ({ pattern, before=null, after=null }) => {
|
||||||
const { t } = useTranslation([`o_${pattern}`, 'og'])
|
const { t } = useTranslation([`o_${pattern}`, 'og'])
|
||||||
|
|
||||||
const sortOptions = (options) => {
|
|
||||||
if (typeof options === 'undefined') return []
|
|
||||||
const sorted = []
|
|
||||||
const translated = {}
|
|
||||||
for (const o of options) {
|
|
||||||
const translation = intl.messages['measurements.' + o] || o
|
|
||||||
translated[translation] = o
|
|
||||||
}
|
|
||||||
const order = Object.keys(translated)
|
|
||||||
order.sort()
|
|
||||||
for (const o of order) sorted.push(translated[o])
|
|
||||||
|
|
||||||
return sorted
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{before}
|
{before}
|
||||||
|
|
|
@ -25,7 +25,6 @@ const LayoutWrapper = ({
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
router.events?.on('routeChangeStart', startNavigation)
|
router.events?.on('routeChangeStart', startNavigation)
|
||||||
router.events?.on('routeChangeComplete', () => app.stopLoading())
|
router.events?.on('routeChangeComplete', () => app.stopLoading())
|
||||||
const slug = router.asPath.slice(1)
|
|
||||||
const [collapsePrimaryNav, setCollapsePrimaryNav] = useState(workbench || false)
|
const [collapsePrimaryNav, setCollapsePrimaryNav] = useState(workbench || false)
|
||||||
const [collapseAltMenu, setCollapseAltMenu] = useState(false)
|
const [collapseAltMenu, setCollapseAltMenu] = useState(false)
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,6 @@ import Docs from 'site/components/layouts/docs'
|
||||||
// Add feeds
|
// Add feeds
|
||||||
import Feeds from 'site/components/feeds.js'
|
import Feeds from 'site/components/feeds.js'
|
||||||
|
|
||||||
const layouts = {
|
|
||||||
docs: Docs,
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This component should wrap all page content */
|
/* This component should wrap all page content */
|
||||||
const PageWrapper= ({
|
const PageWrapper= ({
|
||||||
title="FIXME: No title set",
|
title="FIXME: No title set",
|
||||||
|
|
|
@ -3,16 +3,12 @@ import useApp from 'site/hooks/useApp.js'
|
||||||
import TimeAgo from 'react-timeago'
|
import TimeAgo from 'react-timeago'
|
||||||
import MdxWrapper from 'shared/components/wrappers/mdx'
|
import MdxWrapper from 'shared/components/wrappers/mdx'
|
||||||
import mdxCompiler from 'shared/mdx/compiler'
|
import mdxCompiler from 'shared/mdx/compiler'
|
||||||
import Markdown from 'react-markdown'
|
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import Lightbox from 'shared/components/lightbox.js'
|
import Lightbox from 'shared/components/lightbox.js'
|
||||||
import ImageWrapper from 'shared/components/wrappers/img.js'
|
import ImageWrapper from 'shared/components/wrappers/img.js'
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import { strapiHost } from 'shared/config/freesewing.mjs'
|
import { strapiHost } from 'shared/config/freesewing.mjs'
|
||||||
import { strapiImage } from 'shared/utils.js'
|
import { strapiImage } from 'shared/utils.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
|
||||||
|
|
||||||
const strapi = "https://posts.freesewing.org"
|
|
||||||
|
|
||||||
const Author = ({ author }) => (
|
const Author = ({ author }) => (
|
||||||
<div id="author" className="flex flex-col lg:flex-row m-auto p-2 items-center">
|
<div id="author" className="flex flex-col lg:flex-row m-auto p-2 items-center">
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import Page from 'site/components/wrappers/page.js'
|
import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import Popout from 'shared/components/popout.js'
|
|
||||||
import Link from 'next/link'
|
|
||||||
import PageLink from 'shared/components/page-link'
|
import PageLink from 'shared/components/page-link'
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
|
@ -4,7 +4,6 @@ import mdxLoader from 'shared/mdx/loader'
|
||||||
import MdxWrapper from 'shared/components/wrappers/mdx'
|
import MdxWrapper from 'shared/components/wrappers/mdx'
|
||||||
import TocWrapper from 'shared/components/wrappers/toc'
|
import TocWrapper from 'shared/components/wrappers/toc'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import HelpUs from 'site/components/help-us.js'
|
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import components from 'site/components/mdx/index.js'
|
import components from 'site/components/mdx/index.js'
|
||||||
// MDX paths
|
// MDX paths
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { useEffect } from 'react'
|
|
||||||
import Page from 'site/components/wrappers/page.js'
|
import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import mdxLoader from 'shared/mdx/loader'
|
import mdxLoader from 'shared/mdx/loader'
|
||||||
|
@ -37,7 +36,7 @@ export default DocsPage
|
||||||
*/
|
*/
|
||||||
export async function getStaticProps({ params, locale }) {
|
export async function getStaticProps({ params, locale }) {
|
||||||
|
|
||||||
const { mdx, intro, toc, frontmatter } = await mdxLoader(
|
const { mdx, frontmatter } = await mdxLoader(
|
||||||
locale,
|
locale,
|
||||||
'org',
|
'org',
|
||||||
['docs']
|
['docs']
|
||||||
|
|
|
@ -2,11 +2,10 @@ import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import Popout from 'shared/components/popout.js'
|
import Popout from 'shared/components/popout.js'
|
||||||
import Link from 'next/link'
|
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import Layout from 'site/components/layouts/bare'
|
import Layout from 'site/components/layouts/bare'
|
||||||
import Navigation, { Icons } from 'shared/components/navigation/primary'
|
import { Icons } from 'shared/components/navigation/primary'
|
||||||
import DownIcon from 'shared/components/icons/down.js'
|
import DownIcon from 'shared/components/icons/down.js'
|
||||||
|
|
||||||
const HomePage = (props) => {
|
const HomePage = (props) => {
|
||||||
|
|
|
@ -3,8 +3,6 @@ import useApp from 'site/hooks/useApp.js'
|
||||||
import TimeAgo from 'react-timeago'
|
import TimeAgo from 'react-timeago'
|
||||||
import MdxWrapper from 'shared/components/wrappers/mdx'
|
import MdxWrapper from 'shared/components/wrappers/mdx'
|
||||||
import mdxCompiler from 'shared/mdx/compiler'
|
import mdxCompiler from 'shared/mdx/compiler'
|
||||||
import Markdown from 'react-markdown'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import PageLink from 'shared/components/page-link.js'
|
import PageLink from 'shared/components/page-link.js'
|
||||||
import Lightbox from 'shared/components/lightbox.js'
|
import Lightbox from 'shared/components/lightbox.js'
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
|
@ -12,8 +10,6 @@ import { strapiHost } from 'shared/config/freesewing.mjs'
|
||||||
import { strapiImage } from 'shared/utils.js'
|
import { strapiImage } from 'shared/utils.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
||||||
const strapi = "https://posts.freesewing.org"
|
|
||||||
|
|
||||||
const Maker = ({ maker }) => {
|
const Maker = ({ maker }) => {
|
||||||
const { t } = useTranslation(['posts'])
|
const { t } = useTranslation(['posts'])
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,11 @@
|
||||||
import Page from 'site/components/wrappers/page.js'
|
import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import TimeAgo from 'react-timeago'
|
|
||||||
import MdxWrapper from 'shared/components/wrappers/mdx'
|
|
||||||
import mdxCompiler from 'shared/mdx/compiler'
|
|
||||||
import Markdown from 'react-markdown'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import { strapiHost } from 'shared/config/freesewing.mjs'
|
import { strapiHost } from 'shared/config/freesewing.mjs'
|
||||||
import { strapiImage } from 'shared/utils.js'
|
import { strapiImage } from 'shared/utils.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import designs from 'shared/config/designs.json'
|
import designs from 'shared/config/designs.json'
|
||||||
import { PreviewTile } from '../index.js'
|
import { PreviewTile } from '../index.js'
|
||||||
import PageLink from 'shared/components/page-link.js'
|
|
||||||
|
|
||||||
const DesignPosts = ({ design, posts }) => {
|
|
||||||
const { t } = useTranslation(['patterns'])
|
|
||||||
return (
|
|
||||||
<div className='py-8'>
|
|
||||||
<div className={`
|
|
||||||
flex flex-row overflow-visible
|
|
||||||
-mr-8 pl-8
|
|
||||||
md:-mr-12 md:pl-12
|
|
||||||
`}>
|
|
||||||
{posts.slice(0, 10).map(post => <PreviewTile
|
|
||||||
img={`${strapiHost}${post?.image?.sizes?.medium?.url}`}
|
|
||||||
slug={post.slug}
|
|
||||||
title={post.title}
|
|
||||||
key={post.slug}
|
|
||||||
/>)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const DesignIndexPage = (props) => {
|
const DesignIndexPage = (props) => {
|
||||||
const app = useApp()
|
const app = useApp()
|
||||||
|
@ -68,7 +42,7 @@ const DesignIndexPage = (props) => {
|
||||||
md:-mr-12 md:pl-12
|
md:-mr-12 md:pl-12
|
||||||
`}>
|
`}>
|
||||||
{props.posts.map(post => <PreviewTile
|
{props.posts.map(post => <PreviewTile
|
||||||
img={`${strapiHost}${post?.image?.sizes?.medium?.url}`}
|
img={`${strapiHost}${post.image?.sizes?.medium?.url}`}
|
||||||
slug={post.slug}
|
slug={post.slug}
|
||||||
title={post.title}
|
title={post.title}
|
||||||
key={post.slug}
|
key={post.slug}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import PageLink from 'shared/components/page-link.js'
|
import PageLink from 'shared/components/page-link.js'
|
||||||
import TimeAgo from 'react-timeago'
|
|
||||||
import { strapiHost } from 'shared/config/freesewing.mjs'
|
import { strapiHost } from 'shared/config/freesewing.mjs'
|
||||||
import { strapiImage } from 'shared/utils.js'
|
import { strapiImage } from 'shared/utils.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
@ -37,7 +36,7 @@ const DesignPosts = ({ design, posts }) => {
|
||||||
md:-mr-12 md:pl-12
|
md:-mr-12 md:pl-12
|
||||||
`}>
|
`}>
|
||||||
{posts.slice(0, 10).map(post => <PreviewTile
|
{posts.slice(0, 10).map(post => <PreviewTile
|
||||||
img={`${strapiHost}${post?.image?.sizes?.medium?.url}`}
|
img={`${strapiHost}${post.image?.sizes?.medium?.url}`}
|
||||||
slug={post.slug}
|
slug={post.slug}
|
||||||
title={post.title}
|
title={post.title}
|
||||||
key={post.slug}
|
key={post.slug}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import Page from 'site/components/wrappers/page.js'
|
||||||
import useApp from 'site/hooks/useApp.js'
|
import useApp from 'site/hooks/useApp.js'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import PageLink from 'shared/components/page-link.js'
|
import PageLink from 'shared/components/page-link.js'
|
||||||
import TimeAgo from 'react-timeago'
|
|
||||||
import { strapiHost } from 'shared/config/freesewing.mjs'
|
import { strapiHost } from 'shared/config/freesewing.mjs'
|
||||||
import { strapiImage } from 'shared/utils.js'
|
import { strapiImage } from 'shared/utils.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
@ -42,7 +41,7 @@ const DesignPosts = ({ design, posts }) => {
|
||||||
md:-mr-12 md:pl-12
|
md:-mr-12 md:pl-12
|
||||||
`} style={{maxWidth: "calc(100vw - 3rem)"}}>
|
`} style={{maxWidth: "calc(100vw - 3rem)"}}>
|
||||||
{posts.slice(0, 10).map(post => <PreviewTile
|
{posts.slice(0, 10).map(post => <PreviewTile
|
||||||
img={`${strapiHost}${post?.image?.sizes?.medium?.url}`}
|
img={`${strapiHost}${post.image?.sizes?.medium?.url}`}
|
||||||
slug={post.slug}
|
slug={post.slug}
|
||||||
title={post.title}
|
title={post.title}
|
||||||
key={post.slug}
|
key={post.slug}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import themes from 'shared/themes/index.js'
|
|
||||||
import LocaleIcon from 'shared/components/icons/i18n.js'
|
import LocaleIcon from 'shared/components/icons/i18n.js'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
|
@ -2,16 +2,16 @@ import rough from 'roughjs/bundled/rough.cjs.js'
|
||||||
|
|
||||||
const getAttributes = (element) => Array.prototype.slice.call(element.attributes)
|
const getAttributes = (element) => Array.prototype.slice.call(element.attributes)
|
||||||
|
|
||||||
const getNum = (element, attributes) => attributes.map(attr => parseFloat(element.getAttribute(attr), 10))
|
const getNum = (element, attributes) => attributes.map(attr => parseFloat(element.getAttribute(attr)))
|
||||||
|
|
||||||
const getDiam = (element, attributes) => attributes.map(attr => 2 * parseFloat(element.getAttribute(attr), 10))
|
const getDiam = (element, attributes) => attributes.map(attr => 2 * parseFloat(element.getAttribute(attr)))
|
||||||
|
|
||||||
const getCoords = (element, attribute) => element
|
const getCoords = (element, attribute) => element
|
||||||
.getAttribute(attribute)
|
.getAttribute(attribute)
|
||||||
.trim()
|
.trim()
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.filter(item => item.length > 0)
|
.filter(item => item.length > 0)
|
||||||
.map(item => item.trim().split(',').map(num => parseFloat(num, 10)))
|
.map(item => item.trim().split(',').map(num => parseFloat(num)))
|
||||||
|
|
||||||
const getSettings = element => {
|
const getSettings = element => {
|
||||||
const settings = {};
|
const settings = {};
|
||||||
|
@ -25,7 +25,7 @@ const getSettings = element => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(element.hasAttribute('stroke-width') && !element.getAttribute('stroke-width').includes('%')) {
|
if(element.hasAttribute('stroke-width') && !element.getAttribute('stroke-width').includes('%')) {
|
||||||
settings.strokeWidth = parseFloat(element.getAttribute('stroke-width', 10));
|
settings.strokeWidth = parseFloat(element.getAttribute('stroke-width'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
|
@ -69,10 +69,10 @@ const coarse = (svg, options) => {
|
||||||
'y2'
|
'y2'
|
||||||
];
|
];
|
||||||
|
|
||||||
const flatten = () => {
|
const flatten = (...args) => {
|
||||||
const rv = []
|
const rv = []
|
||||||
for(let i = 0; i < arguments.length; i++) {
|
for(let i = 0; i < args.length; i++) {
|
||||||
const arr = arguments[i]
|
const arr = args[i]
|
||||||
for(let j = 0; j < arr.length; j++) {
|
for(let j = 0; j < arr.length; j++) {
|
||||||
rv.push(arr[j])
|
rv.push(arr[j])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue